Subject: bug#58795: CC Mode 5.35.1 (ObjC//l); Incorrect fontification of structs and enums

From: Alan Mackenzie <[email-masked]>
Date: Fri, 28 Oct 2022 12:28:07 +0000

Hello, Po.

Thanks indeed for the bug report.

On Wed, Oct 26, 2022 at 20:51:48 +0800, Po Lu via CC-Mode-help wrote:
> Package: cc-mode

> Go to src/nsfont.m in the master branch of Emacs's source repository.
> Notice every "enum gs_font_xxx" and "struct gs_font_data" identifier is
> fontified as a type.  Here are some examples:

> struct gs_font_data
> {
>   int specified;
>   enum gs_font_slant slant;
>   enum gs_font_weight weight;
>   enum gs_font_width width;
>   bool monospace_p;
>   char *family_name;
> };

> here, slant, weight and width are fontified as types.

> static void
> ns_done_font_data (struct gs_font_data *data)
> {
>   if (data->specified & GS_SPECIFIED_FAMILY)
>     xfree (data->family_name);
> }

> here, data is fontified as a type.

[ .... ]

The problem was a missing entry for objc-mode in one of the keyword
tables in CC Mode.  This was easy to find and correct.  :-)

The fix also seems to have fixed bug #58796, so I've merged the two bugs.

I've committed the fix to the master branch, so could you please update
your Emacs 29 and check that everything in these bugs is fixed, then let
me know.  Then I can close the two bugs.  Thanks!

The amazing thing is that this bug could have lain undiscovered for so
long.

> here, "dat" and "t" are fontified as types.  However, if part of this
> function definition is not visible and is later scrolled into the
> window, "dat" and "t" will not be fontified as types in that newly
> visible part.

> Emacs  : GNU Emacs 29.0.50 (build 7, x86_64-pc-linux-gnu, NS gnustep-gui-0.29.0)
>  of 2022-10-26
> Package: CC Mode 5.35.1 (ObjC//l)
> Buffer Style: GNU
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit)

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).