From 712cc158772697058c1436a6e5bacc00d262f49c Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Mon, 2 Oct 2017 14:42:13 +0000 Subject: [PATCH] Fix a CC Mode brace stack cache bug. * lisp/progmodes/cc-engine.el (c-update-brace-stack): Call c-beginning-of-current-token after a failing search operation, to ensure we don't cache a point inside a token. --- lisp/progmodes/cc-engine.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 05b391a3d38..9d65383e258 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -5410,8 +5410,7 @@ comment at the start of cc-engine.el for more info." ;; value. (let (match kwd-sym (prev-match-pos 1) (s (cdr stack)) - (bound-<> (car stack)) - ) + (bound-<> (car stack))) (save-excursion (cond ((and bound-<> (<= to bound-<>)) @@ -5472,6 +5471,9 @@ comment at the start of cc-engine.el for more info." (setq s (cdr s)))) ((c-keyword-member kwd-sym 'c-flat-decl-block-kwds) (push 0 s)))) + ;; The failing `c-syntactic-re-search-forward' may have left us in the + ;; middle of a token, which might be a significant token. Fix this! + (c-beginning-of-current-token) (cons (point) (cons bound-<> s))))) -- 2.39.5