all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alex Harsanyi <harsanyi@mac.com>
Cc: 7767@debbugs.gnu.org
Subject: bug#7767: 23.2.91; file-local-variables-alist should have the permanent-local property
Date: Sat, 01 Jan 2011 22:58:45 -0500	[thread overview]
Message-ID: <jwv4o9s6jzs.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <348B9E68-4760-4A8A-BE36-9D983576A4A4@mac.com> (Alex Harsanyi's message of "Sun, 2 Jan 2011 07:26:36 +0800")

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.






      reply	other threads:[~2011-01-02  3:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-01  4:12 bug#7767: 23.2.91; file-local-variables-alist should have the permanent-local property Alex Harsanyi
2011-01-01 19:38 ` Stefan Monnier
2011-01-01 23:26   ` Alex Harsanyi
2011-01-02  3:58     ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv4o9s6jzs.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=7767@debbugs.gnu.org \
    --cc=harsanyi@mac.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.