Subject: Re: bug#36802: CC Mode 5.34 (C/*l); Spurious indentation in line after open #include

From: Alan Mackenzie <[email-masked]>
Date: Fri, 26 Jul 2019 18:41:53 +0000

Hello, Richard.

On Fri, Jul 26, 2019 at 13:13:33 +0100, Richard Copley wrote:
> Hi Alan,

> [BTW, I didn't really mean to move this discussion to a private email. That
> was just clumsiness on my part. I have no objection to any of it being
> published. We can join the bug thread if you want.]

I've just put it back into the bug thread.

> On Thu, 25 Jul 2019 at 17:56, Alan Mackenzie <[email-masked]> wrote:

> > Hello, Richard.

> > On Thu, Jul 25, 2019 at 16:35:01 +0100, Richard Copley wrote:
> > > On Thu, 25 Jul 2019 at 10:23, Alan Mackenzie <[email-masked]> wrote:

> > [ .... ]

> > > > Here is the patch, again.  I'm very confident that this fixes the bug
> > > > properly.  Unless I hear otherwise within a day or two, I'll be
> > > > committing this patch and closing the bug.

> > > > diff -r 2e20f0567ddf cc-engine.el
> > > > --- a/cc-engine.el      Tue Jul 23 09:45:20 2019 +0000
> > > > +++ b/cc-engine.el      Tue Jul 23 13:00:17 2019 +0000
> > > > @@ -278,6 +278,11 @@
> > > >      (setcdr c-macro-cache nil)
> > > >      (setq c-macro-cache-start-pos beg
> > > >           c-macro-cache-syntactic nil
> > > > +         c-macro-cache-no-comment nil))
> > > > +   ((and c-macro-cache-start-pos
> > > > +        (< beg (c-macro-cache-start-pos)))   <=====================
> > > > +    (setq c-macro-cache-start-pos beg
> > > > +         c-macro-cache-syntactic nil
> > > >           c-macro-cache-no-comment nil))))

> > > >  (defun c-macro-is-genuine-p ()

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

> > > > [ .... ]

> > > Hi Alan,
> > > The byte-compiler complains that c-macro-cache-start-pos is not
> > > defined as a function.

> > That's wierd.  I tested it.  I _must_ have tested it.  But it's wrong,
> > and non-workable.  On the marked line, the parentheses around
> > c-macro-cache-start-pos should not be there.  Maybe I should take a day's
> > rest.  Sorry about the nuisance.

> Thank you, the apology is not at all necessary, but I very much appreciate
> it anyway.

> It /is/ weird. I didn't notice it at all at first (I saw the compiler
> warning during a rebuild, later) but it looks like it should signal an
> error.

More precisely, it should signal an error at run-time.

> Are errors suppressed there, do you think? If not, I suppose I wasn't
> testing that code path, though I did intend to.

However if a run-time error happens during fontification, the
fontification routine is removed from the hook fontification-functions,
or sometimes from after-change-functions, leaving fontification not
working rather than Emacs remaining hopelessly hung.  Maybe this
happened.

> > Please try this instead:

> > diff -r 2e20f0567ddf cc-engine.el
> > --- a/cc-engine.el      Tue Jul 23 09:45:20 2019 +0000
> > +++ b/cc-engine.el      Thu Jul 25 16:51:48 2019 +0000
> > @@ -278,6 +278,11 @@
> >      (setcdr c-macro-cache nil)
> >      (setq c-macro-cache-start-pos beg
> >           c-macro-cache-syntactic nil
> > +         c-macro-cache-no-comment nil))
> > +   ((and c-macro-cache-start-pos
> > +        (< beg c-macro-cache-start-pos))
> > +    (setq c-macro-cache-start-pos beg
> > +         c-macro-cache-syntactic nil
> >           c-macro-cache-no-comment nil))))

> >  (defun c-macro-is-genuine-p ()

> Thanks, I am trying that. It seems no different (?weirdly). I currently
> have three patches (of yours) against master: the above for #36802, the
> other short patch for #36801, and the longer patch for #36397.

Yes:

#36397: A M-q in a comment causes 'args-out-of-range'.
#36801: In origin[x];, x is being wrongly fontified.
#36802: Spurious indentation in line after open #include.

That's rather a lot.  ;-(  Let's see if we can get one or more of these
closed over the weekend.

Have a good weekend!

-- 
Alan Mackenzie (Nuremberg, Germany).