summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
-rw-r--r--lisp/progmodes/cc-mode.el34
1 files changed, 25 insertions, 9 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 7a111017074..f6d36f5670c 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -639,6 +639,8 @@ that requires a literal mode spec at compile time."
;; doesn't work with filladapt but it's better than nothing.
(set (make-local-variable 'fill-paragraph-function) 'c-fill-paragraph)
+ ;; Initialize the cache for `c-looking-at-or-maybe-in-bracelist'.
+ (setq c-laomib-cache nil)
;; Initialize the three literal sub-caches.
(c-truncate-lit-pos-cache 1)
;; Initialize the cache of brace pairs, and opening braces/brackets/parens.
@@ -2054,7 +2056,9 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
(if c-get-state-before-change-functions
(mapc (lambda (fn)
(funcall fn beg end))
- c-get-state-before-change-functions))))
+ c-get-state-before-change-functions))
+
+ (c-laomib-invalidate-cache beg end)))
(c-clear-string-fences))))
(c-truncate-lit-pos-cache beg)
;; The following must be done here rather than in `c-after-change'
@@ -2205,7 +2209,8 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
old-pos
(new-pos pos)
capture-opener
- bod-lim bo-decl)
+ bod-lim bo-decl
+ paren-state containing-brace)
(goto-char (c-point 'bol new-pos))
(unless lit-start
(setq bod-lim (c-determine-limit 500))
@@ -2224,12 +2229,16 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
(setq old-pos (point))
(let (pseudo)
(while
- (progn
- (c-syntactic-skip-backward "^;{}" bod-lim t)
- (and (eq (char-before) ?})
- (save-excursion
- (backward-char)
- (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state))))))
+ (and
+ ;; N.B. `c-syntactic-skip-backward' doesn't check (> (point)
+ ;; lim) and can loop if that's not the case.
+ (> (point) bod-lim)
+ (progn
+ (c-syntactic-skip-backward "^;{}" bod-lim t)
+ (and (eq (char-before) ?})
+ (save-excursion
+ (backward-char)
+ (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state)))))))
(goto-char pseudo))
t)
(> (point) bod-lim)
@@ -2262,7 +2271,14 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
(and (eq (char-before) ?{)
(save-excursion
(backward-char)
- (consp (c-looking-at-or-maybe-in-bracelist))))
+ (setq paren-state (c-parse-state))
+ (while
+ (and
+ (setq containing-brace
+ (c-pull-open-brace paren-state))
+ (not (eq (char-after containing-brace) ?{))))
+ (consp (c-looking-at-or-maybe-in-bracelist
+ containing-brace containing-brace))))
)))
(not (bobp)))
(backward-char)) ; back over (, [, <.