From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <348B9E68-4760-4A8A-BE36-9D983576A4A4@mac.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1293942232 19731 80.91.229.12 (2 Jan 2011 04:23:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 2 Jan 2011 04:23:52 +0000 (UTC) Cc: 7767@debbugs.gnu.org To: Alex Harsanyi Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 02 05:23:47 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PZFTu-0000ux-8u for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Jan 2011 05:23:46 +0100 Original-Received: from localhost ([127.0.0.1]:44910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZFTt-00051R-In for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Jan 2011 23:23:45 -0500 Original-Received: from [140.186.70.92] (port=44764 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZFTn-0004yX-11 for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 23:23:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZFTl-0001T2-UG for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 23:23:38 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZFTl-0001Sw-RN for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 23:23:37 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PZEzB-0008HS-Vg; Sat, 01 Jan 2011 22:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Jan 2011 03:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7767 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7767-submit@debbugs.gnu.org id=B7767.129394030631801 (code B ref 7767); Sun, 02 Jan 2011 03:52:01 +0000 Original-Received: (at 7767) by debbugs.gnu.org; 2 Jan 2011 03:51:46 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZEyv-0008Gr-LB for submit@debbugs.gnu.org; Sat, 01 Jan 2011 22:51:46 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZEyt-0008Gc-Gh; Sat, 01 Jan 2011 22:51:44 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEANKGH01Ld/TY/2dsb2JhbACkR3S7OYVKBIRljhs X-IronPort-AV: E=Sophos;i="4.60,261,1291611600"; d="scan'208";a="86888675" Original-Received: from 75-119-244-216.dsl.teksavvy.com (HELO pastel.home) ([75.119.244.216]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 01 Jan 2011 22:58:45 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 6AAF058DFC; Sat, 1 Jan 2011 22:58:45 -0500 (EST) In-Reply-To: <348B9E68-4760-4A8A-BE36-9D983576A4A4@mac.com> (Alex Harsanyi's message of "Sun, 2 Jan 2011 07:26:36 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 01 Jan 2011 22:52:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42997 Archived-At: 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.