Subject: Re: bug#19206: 25.0.50; CC Mode tracks wrong source files

From: Alan Mackenzie <[email-masked]>
Date: Tue, 2 Dec 2014 12:02:26 +0000

Hello, Sebastian.

On Tue, Dec 02, 2014 at 12:03:21PM +0100, Sebastian Wiesner wrote:

> > Am 30.11.2014 um 19:42 schrieb Alan Mackenzie <[email-masked]>:

> > Hello, again, Sebastian.

> > On Fri, Nov 28, 2014 at 10:25:42PM -0000, Alan Mackenzie wrote:
> >> Hello, Sebastian.
> >> In article <[email-masked]> you wrote:
> >>> CC Mode tracks wrong source files when a CC Mode derived mode is
> >>> installed non-interactively.

[ .... ]

> > OK.  The problem was that CC Mode was using the flag
> > `load-in-progress' to assume that a CC Mode file was being loaded,
> > for example by a `require' form inside a compilation of another CC
> > Mode file.  This assumption breaks down when another file, such as
> > cc-miscompile.el, while loading, initiates compilation of a CC Mode
> > derivative.

[ .... ]

> > No, that wouldn't work.  What I've implemented is when both loading
> > and byte-compilation are active at the same time, CC Mode walks down
> > the lisp stack to discover which one of them is actually active.

> Well, if you say… I find this “solution” horrifying, but I am probably
> just unable to appreciate the full complexity of this issue.

It is horrifying.  I spent quite some time over the weekend searching for
a better solution, without success.  The issue is quite simple: when
loading and compiling are nested in some unknown order, how do you
determine which of them is the "innermost" activity?

But, then again, maybe I could bind the "compilation flags" to nil around
each invocation of `load' inside the CC Mode compilation system.  Yes,
I'll give that a try.

> > Please try the following patch, which seems to work in the test case you
> > supplied, in the real situation, and let me know how well it works.  The
> > d-mode.elc produced can be successfully loaded into the Emacs that built
> > it.

> Do I need to build a patched Emacs to try it?

You need to rebuild CC Mode, but not necessarily the Emacs core.  This
should do the job:

    emacs -Q -batch -f batch-byte-compile path/to/lisp/progmodes/cc-*.el

, or you could just do a `make' from the main Emacs directory, possibly
deleting cc-*.elc first, just to make sure.

But feel free to wait until I've tried the alternative, better, approach
above.  I'll get back to you later.

-- 
Alan Mackenzie (Nuremberg, Germany).