Subject: Wierd fontification in brackets in C++ Mode. [Was bug#36397: CC Mode 5.34 (C++//l); Bad highlighting on inserting a string]

From: Alan Mackenzie <[email-masked]>
Date: Tue, 23 Jul 2019 10:40:15 +0000

Hello again, Richard.

On Mon, Jul 22, 2019 at 20:47:22 +0100, Richard Copley wrote:

[ .... ]

> 3. (This one's reproducible and 'stable' -- it's dependent only on the
> current buffer contents, and not on the path that got us there.) With these
> buffer contents:

> order[x];
> origin[y];
> counterpane[z];

> ... "x" and "y" are highlighted as types, and "z" is not (expected: none of
> the three subscripts are highlighted). There's apparently something special
> about the identifiers "order" and "origin".

OK, I've tracked this one down to a regexp not testing for end of word.

I'm pretty sure the following patch fixes it, but would you please do the
usual with it anyway.  As this changes a Lisp macro, the entire CC Mode
needs to be rebuilt after patching.

Thanks!

diff -r 2e20f0567ddf cc-langs.el
--- a/cc-langs.el	Tue Jul 23 09:45:20 2019 +0000
+++ b/cc-langs.el	Tue Jul 23 10:34:14 2019 +0000
@@ -1480,7 +1480,7 @@
 
 (c-lang-defconst c-pre-lambda-tokens-re
   ;; Regexp matching any token in the list `c-pre-lambda-tokens'.
-  t (regexp-opt (c-lang-const c-pre-lambda-tokens)))
+  t (c-make-keywords-re t (c-lang-const c-pre-lambda-tokens)))
 (c-lang-defvar c-pre-lambda-tokens-re (c-lang-const c-pre-lambda-tokens-re))
 
 ;;; Syntactic whitespace.

-- 
Alan Mackenzie (Nuremberg, Germany).