GNU bug report logs -
#7767
23.2.91; file-local-variables-alist should have the permanent-local property
Previous Next
Reported by: Alex Harsanyi <harsanyi <at> mac.com>
Date: Sat, 1 Jan 2011 04:43:02 UTC
Severity: normal
Found in version 23.2.91
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7767 in the body.
You can then email your comments to 7767 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7767
; Package
emacs
.
(Sat, 01 Jan 2011 04:43:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Harsanyi <harsanyi <at> mac.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 01 Jan 2011 04:43:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Here is a scenario that illustrates the problem. Save the following
into a file named hello.cc:
----------
#include <iostream>
int main()
{
std::cout << "Hello World\n";
}
/*
Local Variables:
mode: c++
compile-command: "g++ -o hello hello.cc"
End:
*/
----------
After visiting this file in Emacs, and typing M-x compile RET, I expect
the default compilation command to be the one set in the local variables
section of the file. Instead it is "make -k" which is the default one
for the `compile-command' variable.
I tried to debug the problem and it seems that `hack-local-variables'
will collect the local variables into `file-local-variables-alist' than
run the hook `before-hack-local-variables-hook' which containts the
function `c-before-hack-hook'.
`c-before-hack-hook' will see the `mode' variable and call `c++-mode'
which than will call `kill-all-local-variables' setting
`file-local-variables-alist' to nil so that the remaining variables are
not processed.
Adding the `permanent-local' property to `file-local-variables-alist'
seems to fix the problem.
Note that the problem does not seem too occur if the mode is set to 'c',
but it does for 'c++' and 'python'. I'm not sure why this is.
This happens both on the trunk and on the emacs-23 branch.
In GNU Emacs 23.2.91.1 (x86_64-apple-darwin10.5.0, NS apple-appkit-1038.35)
of 2010-12-31 on karinji-2.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure '--with-ns''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_AU.UTF-8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: C++/l
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent input:
C-x C-f ~ / P r o <tab> h e <tab> <return> M-x c o
m p i l e <return> C-g M-x r e p o r t - e m <tab>
<return> C-g C-h f h a c k <tab> l o <tab> <return>
<help-echo> <help-echo> <help-echo> <down-mouse-1>
<mouse-2> <help-echo> <wheel-down> <wheel-down> <double-wheel-down>
<down-mouse-1> <mouse-1> C-v C-v C-v C-v <down-mouse-1>
<mouse-movement> <mouse-movement> <drag-mouse-1> s-w
M-w <help-echo> <down-mouse-1> <mouse-1> M-x <up>
<return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [2 times]
Type C-x 1 to delete the help window.
uncompressing files.el.gz...done
Loading vc-bzr...done
call-interactively: Attempt to delete the sole visible or iconified frame
Load-path shadows:
None found.
Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock
hashcash mail-utils vc-bzr sha1 hex-util jka-compr find-func help-mode
view help-fns emacsbug compile comint ring cc-mode cc-fonts cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs regexp-opt tooltip
ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
cus-face files text-properties overlay md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote
make-network-process dbusbind ns multi-tty emacs)
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7767
; Package
emacs
.
(Sat, 01 Jan 2011 19:32:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 7767 <at> debbugs.gnu.org (full text, mbox):
> I tried to debug the problem and it seems that `hack-local-variables'
> will collect the local variables into `file-local-variables-alist' than
> run the hook `before-hack-local-variables-hook' which containts the
> function `c-before-hack-hook'.
> `c-before-hack-hook' will see the `mode' variable and call `c++-mode'
> which than will call `kill-all-local-variables' setting
> `file-local-variables-alist' to nil so that the remaining variables are
> not processed.
It sounds like cc-mode does something odd here.
> Adding the `permanent-local' property to `file-local-variables-alist'
> seems to fix the problem.
My first impression is rather that this would work around the problem
introduced by cc-mode. So I'd first want to make sure that cc-mode has
a good reason to call c++-mode from before-hack-local-variables-hook.
> This happens both on the trunk and on the emacs-23 branch.
Alan, could you enlighten us?
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7767
; Package
emacs
.
(Sat, 01 Jan 2011 23:20:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 7767 <at> debbugs.gnu.org (full text, mbox):
On 2 Jan 2011, at 3:38 AM, Stefan Monnier wrote:
>> I tried to debug the problem and it seems that `hack-local-variables'
>> will collect the local variables into `file-local-variables-alist' than
>> run the hook `before-hack-local-variables-hook' which containts the
>> function `c-before-hack-hook'.
>> `c-before-hack-hook' will see the `mode' variable and call `c++-mode'
>> which than will call `kill-all-local-variables' setting
>> `file-local-variables-alist' to nil so that the remaining variables are
>> not processed.
>
> It sounds like cc-mode does something odd here.
On further investigation, this only happens when the mode setting
changes the mode of the file. That is, a file named "hello.c" with a
"mode: c++" setting. It does not happen otherwise, because
`hack-one-local-variable' will not enable a major mode if it is
already set for the file.
However, `c-before-hack-hook' does enable the mode itself via a call to
`hack-one-local-variable'.
Best Regards,
Alex.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7767
; Package
emacs
.
(Sun, 02 Jan 2011 03:52:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 7767 <at> debbugs.gnu.org (full text, mbox):
close 7767
thanks
>>> I tried to debug the problem and it seems that `hack-local-variables'
>>> will collect the local variables into `file-local-variables-alist' than
>>> run the hook `before-hack-local-variables-hook' which containts the
>>> function `c-before-hack-hook'.
>>> `c-before-hack-hook' will see the `mode' variable and call `c++-mode'
>>> which than will call `kill-all-local-variables' setting
>>> `file-local-variables-alist' to nil so that the remaining variables are
>>> not processed.
>>
>> It sounds like cc-mode does something odd here.
> On further investigation, this only happens when the mode setting
> changes the mode of the file. That is, a file named "hello.c" with a
> "mode: c++" setting. It does not happen otherwise, because
> `hack-one-local-variable' will not enable a major mode if it is
> already set for the file.
> However, `c-before-hack-hook' does enable the mode itself via a call to
> `hack-one-local-variable'.
On further investigation, I see that in modes other than cc-mode,
a similar problem appears: the mode is set properly and the local
variables are set correctly, but file-local-variables-alist ends up nil
in the buffer (including when hack-local-variables-hook is run), which
is not right.
More specifically, it's the same bug that manifests itself differently
because in the non-cc case, the file-local-variables-alist gets set to
nil a bit later, more specifically it's set right after reading
file-local-variables-alist to set up the loop that calls
hack-one-local-variable.
So, I agree with your original analysis and have installed the change
below to the emacs-23 branch. Thank you,
Stefan
=== modified file 'lisp/files.el'
--- lisp/files.el 2010-12-04 21:45:17 +0000
+++ lisp/files.el 2011-01-02 03:47:28 +0000
@@ -2788,6 +2788,7 @@
specified. The actual value in the buffer may differ from VALUE,
if it is changed by the major or minor modes, or by the user.")
(make-variable-buffer-local 'file-local-variables-alist)
+(put 'file-local-variables-alist 'permanent-local t)
(defvar dir-local-variables-alist nil
"Alist of directory-local variable settings in the current buffer.
bug closed, send any further explanations to Alex Harsanyi <harsanyi <at> mac.com>
Request was from
Stefan Monnier <monnier <at> iro.umontreal.ca>
to
control <at> debbugs.gnu.org
.
(Sun, 02 Jan 2011 03:52:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 30 Jan 2011 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 139 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.