From: Alan Mackenzie Date: Sun, 29 Aug 2021 14:03:57 +0000 (+0000) Subject: C++ Mode: handle compound identifiers preceding brace lists correctly X-Git-Tag: emacs-28.0.90~1274 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9a1d54814e7970638d8fed56c84389b6c49a55cb;p=emacs.git C++ Mode: handle compound identifiers preceding brace lists correctly * lisp/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): early in function, check alternatively for c-back-over-compound-identifier when doing c-backward-token-2. * bracelist-36.{cc,res}: New test files. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 5d2e41ae575..c305cae754e 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12288,12 +12288,15 @@ comment at the start of cc-engine.el for more info." pos2 in-paren parens-before-brace paren-state paren-pos) - (setq res (c-backward-token-2 1 t lim)) + (setq res + (or (progn (c-backward-syntactic-ws) + (c-back-over-compound-identifier)) + (c-backward-token-2 1 t lim))) ;; Checks to do only on the first sexp before the brace. ;; Have we a C++ initialization, without an "="? (if (and (c-major-mode-is 'c++-mode) (cond - ((and (or (not (eq res 0)) + ((and (or (not (memq res '(t 0))) (eq (char-after) ?,)) (setq paren-state (c-parse-state)) (setq paren-pos (c-pull-open-brace paren-state)) @@ -12317,7 +12320,7 @@ comment at the start of cc-engine.el for more info." (t nil)) (save-excursion (cond - ((or (not (eq res 0)) + ((or (not (memq res '(t 0))) (eq (char-after) ?,)) (and (setq paren-state (c-parse-state)) (setq paren-pos (c-pull-open-brace paren-state))