GNU bug report logs - #23460
25.1.50; Strange behavior in local variables like start-comment

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Thu, 5 May 2016 20:37:02 UTC

Severity: normal

Merged with 23463

Found in version 25.1.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #22 received at 23460 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 23460 <at> debbugs.gnu.org
Subject: Re: 25.1.50; Strange behavior in local variables like start-comment
Date: Thu, 05 May 2016 22:35:23 +0000
[Message part 1 (text/plain, inline)]
>
> I haven't actually looked at that yet.  But where, with respect to
> setting the major mode, does the outshine function look at
> comment-start?
>

Yes


> Were you doing anything involving changing the major mode at the time?
> (See below.)
>

Apologies for that misleading first version of the MWE; the issue I am
seeing has nothing to do with changing major mode (I think).

Thanks for taking the trouble to create this minimal test code.  It
> makes it so much easier to understand when people do this.  :-)
>

No worries. But unintentional I caused more trouble for you by posting an
incorrect version of MWE (the 1st version). The second version I posted few
minutes back is thoroughly tested in both emacs-25 and master and has no
outshine.el dependency i.e. you can focus only on that 2nd version of MWE.

OK.  Have a look at the *Messages* buffer.  You will see the messages
> come in pairs:  (I actually did this in a C Mode buffer.)
>
>     `comment-start' = `/* '
>     `comment-start' is undefined, it's value is: `nil'
>
> But in the echo area, you will only see the second one.
>
> > I have tested this only for comment-start. But I suspect this might
> affect
> > buffer local vars in general?
>
> I think so, too.  When you visit a buffer, Emacs calls `normal-mode' to
> determine and set the major mode.  The first thing `normal-mode' does is
> to call `fundamental-mode'.  This invokes `change-major-mode-hook',
> which outputs the first "comment-start" message.  Then
> `fundamental-mode' kills all local variables, including `comment-start'.
>
> `normal-mode' then determines the correct major mode, and calls it.
> This invokes `change-major-mode-hook' again, which outputs the second
> "comment-start" message with the `nil'.  The major mode is then fully
> set up, including giving a value to `comment-start'.
>
> So, this code seems to be working the way it's intended to.


Thank you for that detailed explanation. I was not aware of the major mode
changes that were happening behind the scenes.


> What is
> outshine doing that triggers a problem in this area?


The outshine-mode-function function is actually added to
outline-minor-mode-hook. I have updated MWE version 2 with that in mind.

Is it doing things
> with the `change-major-mode-hook' that involve using `comment-start'?
> Maybe this is the problem.
>

No, it does not use change-major-mode-hook. But it does depend on the
buffer local value of comment-start.

In summary, the 2nd version of my MWE should help you consistently show the
behavior difference between emacs-25 and master.
-- 

-- 
Kaushal Modi
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 76 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.