bug#58883:

Alan Mackenzie <[email protected]> Tue, 8 Nov 2022 12:21:02 +0000
Newsgroups gmane.emacs.cc-mode.general
Message-ID <Y2pJrocD2j+pICqQ@ACM>
Hello, Po.

On Tue, Nov 08, 2022 at 18:02:12 +0800, Po Lu wrote:
> Alan Mackenzie <[email protected]> writes:

> > Hello, Po.

> > On Tue, Nov 08, 2022 at 08:25:31 +0800, Po Lu wrote:
> >> Alan Mackenzie <[email protected]> writes:

> > [ .... ]

> >> > I have a fix for this, I think, but it overlaps with an earlier fix to
> >> > bug #58883.  I sent you a patch on Sunday 2022-10-30 for this earlier
> >> > bug.  Did you get this patch?  If so, have you any reaction to it?

> >> I think it got lost in the bulk mail folder (but I can't find it there
> >> either, so maybe a mailer screwup?)

> >> So would you please send it again?  TIA.

> > OK, here it is!

> > Thanks!

> > [ I've set the Subject: to bug#58883, and the Cc: to
> > [email protected]. ]

> That seems to solve this problem (bug#58883) for me.

Excellent!  I've committed the patch, and I'm closing the bug with this
post.

> However, I'm beginning to see a general pattern here.  When the mistaken
> type classification is corrected, bad fortification above the last edit
> is not removed.  Shouldn't that be fixed also?

I'm gradually fixing it.

The mechanism is that when C Mode sees what it takes to be a type, from
the context, c-forward-type returns the symbol 'maybe.

Later on in the processing, the analysis of the C code "confirms" that
this 'maybe actually is a type, and it gets promoted to 'found, and
entered into the c-found-types list.  At the same time, other occurrences
of the type throughout the buffer are fontified as types.

This mechanism is not foolproof, and goes wrong when a statement is
partially typed.  Rather than correcting the mistakenly fontified
"types", which would be more difficult, I'm concentrating on not
promoting a 'maybe type to a 'found type too enthusiasically.

The problem here is that CC Mode isn't a compiler, and doesn't do very
deep analysis on the source.  The new mode with tree sitter will likely
do much better on such troublesome sources in the future.  Sorry!

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).