Subject: Re: bug#36801: CC Mode 5.34 (C/*l); Weird fontification in brackets in C++ Mode

From: Alan Mackenzie <[email-masked]>
Date: Thu, 25 Jul 2019 10:36:27 +0000

Hello, Richard.

Thanks for the bug report.

On Wed, Jul 24, 2019 at 20:51:47 +0100, Richard Copley wrote:
> Package: cc-mode

> With these buffer contents:

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

> ... "x" and "y" are highlighted as types [EDIT: keywords],
> and "z" is not.

> Reproduced below is the story so far, which comes after a discussion
> of unrelated matters at bug#36397.

> On Tue, 23 Jul 2019 at 11:40, Alan Mackenzie <[email-masked]> wrote:

>     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.

And here is that patch.  I'm confident that the patch is the right fix
for the bug, so I will be committing it and closing the bug, unless I
hear anything against it in the next day or two.

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.

> Package: cc-mode

> Emacs  : GNU Emacs 27.0.50 (build 1, x86_64-w64-mingw32)
>  of 2019-07-23
> Package: CC Mode 5.34 (C/*l)
> Buffer Style: gnu
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes
> gen-string-delim gen-comment-delim syntax-properties 1-bit)

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).