Subject: Re: bug#41284: 26.3; cc-mode: Incorrect font locking of static functions

From: Alan Mackenzie <[email-masked]>
Date: Sun, 17 May 2020 19:26:38 +0000

Hello, George.

On Fri, May 15, 2020 at 13:03:39 +0100, George O'Hara wrote:
> Hi Eli!

> Yes, I do mean the other way round.
> I made a post on the Emacs SE with images last night, which may be useful
> to link here.
> https://emacs.stackexchange.com/questions/58509/static-function-highlighting-locking-in-c?noredirect=1#comment91178_58509

Could you please try out the following patch.  The file cc-langs.el is in
directory .../emacs/lisp/progmodes.  Because the change is in a macro,
you will need to rebuild all of cc-*.el to get a clean build.  (If you
want any help with the patching or byte compiling, feel free to send me
private email.)

The patch increases considerably the number of keywords which can come
after the "int", when previously they had to come before it.  Please let
us all know whether the patch actually fixes the bug satisfactorally.
Thanks!

diff -r de83a122cf12 cc-langs.el
--- a/cc-langs.el	Fri May 15 19:04:24 2020 +0000
+++ b/cc-langs.el	Sun May 17 19:12:39 2020 +0000
@@ -3402,8 +3402,14 @@
 The end of the first submatch is taken as the end of the operator.
 Identifier syntax is in effect when this is matched (see
 `c-identifier-syntax-table')."
-  t (if (c-lang-const c-type-modifier-kwds)
-	(concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>")
+  t (if (or (c-lang-const c-type-modifier-kwds) (c-lang-const c-modifier-kwds))
+        (concat
+	 (regexp-opt (c--delete-duplicates
+		      (append (c-lang-const c-type-modifier-kwds)
+			      (c-lang-const c-modifier-kwds))
+		      :test 'string-equal)
+		     t)
+	 "\\>")
       ;; Default to a regexp that never matches.
       "\\`a\\`")
   ;; Check that there's no "=" afterwards to avoid matching tokens

> As an aside, I accidentally posted this bug twice. Is there a way I can
> close the other issue?

> Kind regards

> On Fri, 15 May 2020 at 12:57, Eli Zaretskii <[email-masked]> wrote:

> > > From: "George O'Hara" <[email-masked]>
> > > Date: Fri, 15 May 2020 12:15:42 +0100

> > > >From 'emacs -Q', C-x C-f and create a buffer called 'test.c'.
> > > In this buffer, type:

> > > static int some_function();
> > > int static another_function();

> > > some_function is not highlighted, while another_function is.

> > You mean, the other way around, no?

-- 
Alan Mackenzie (Nuremberg, Germany).