From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 31 23:42:32 2010 Received: (at submit) by debbugs.gnu.org; 1 Jan 2011 04:42:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PYtIV-0001g5-78 for submit@debbugs.gnu.org; Fri, 31 Dec 2010 23:42:31 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PYsir-0000us-Ow for submit@debbugs.gnu.org; Fri, 31 Dec 2010 23:05:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PYspd-0004a1-2S for submit@debbugs.gnu.org; Fri, 31 Dec 2010 23:12:42 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:47873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PYspc-0004Zr-WD for submit@debbugs.gnu.org; Fri, 31 Dec 2010 23:12:41 -0500 Received: from [140.186.70.92] (port=45851 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PYspa-0004nd-CN for bug-gnu-emacs@gnu.org; Fri, 31 Dec 2010 23:12:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PYspY-0004ZD-Q3 for bug-gnu-emacs@gnu.org; Fri, 31 Dec 2010 23:12:37 -0500 Received: from outbound-mail02.westnet.com.au ([203.10.1.243]:51512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PYspY-0004Z5-FA for bug-gnu-emacs@gnu.org; Fri, 31 Dec 2010 23:12:36 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjQSAKs3Hk06B8wmPGdsb2JhbAAMiDGcDAEBAQE1vQiDEoI4BIRj X-IronPort-AV: E=Sophos;i="4.60,257,1291564800"; d="scan'208";a="120308438" Received: from 58-7-204-38.dyn.iinet.net.au (HELO [10.0.1.3]) ([58.7.204.38]) by outbound-mail02.westnet.com.au with ESMTP/TLS/AES128-SHA; 01 Jan 2011 12:12:33 +0800 From: Alex Harsanyi Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: 23.2.91; file-local-variables-alist should have the permanent-local property Date: Sat, 1 Jan 2011 12:12:31 +0800 Message-Id: To: bug-gnu-emacs@gnu.org Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 31 Dec 2010 23:42:28 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) Here is a scenario that illustrates the problem. Save the following into a file named hello.cc: ---------- #include 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 h e M-x c o m p i l e C-g M-x r e p o r t - e m C-g C-h f h a c k l o C-v C-v C-v C-v s-w M-w M-x 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) From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 01 14:32:01 2011 Received: (at 7767) by debbugs.gnu.org; 1 Jan 2011 19:32:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZ7BI-0004WY-Eo for submit@debbugs.gnu.org; Sat, 01 Jan 2011 14:32:01 -0500 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 1PZ7BG-0004WG-DO for 7767@debbugs.gnu.org; Sat, 01 Jan 2011 14:31:58 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAKIRH01Ld/TY/2dsb2JhbACkRHS8B4VKBIRljhs X-IronPort-AV: E=Sophos;i="4.60,261,1291611600"; d="scan'208";a="86877082" 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 14:38:59 -0500 Received: by pastel.home (Postfix, from userid 20848) id C990E58D59; Sat, 1 Jan 2011 14:38:58 -0500 (EST) From: Stefan Monnier To: Alex Harsanyi Subject: Re: bug#7767: 23.2.91; file-local-variables-alist should have the permanent-local property Message-ID: References: Date: Sat, 01 Jan 2011 14:38:58 -0500 In-Reply-To: (Alex Harsanyi's message of "Sat, 1 Jan 2011 12:12:31 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 7767 Cc: 7767@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 01 18:19:42 2011 Received: (at 7767) by debbugs.gnu.org; 1 Jan 2011 23:19:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZAjd-0000qv-Ti for submit@debbugs.gnu.org; Sat, 01 Jan 2011 18:19:42 -0500 Received: from outbound-mail01.westnet.com.au ([203.10.1.242]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZAjb-0000qg-4q for 7767@debbugs.gnu.org; Sat, 01 Jan 2011 18:19:40 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvYSANZGH006B8wmPGdsb2JhbAAMiDecDAEBAQE1vAqFSgSEYw X-IronPort-AV: E=Sophos;i="4.60,261,1291564800"; d="scan'208";a="121567311" Received: from 58-7-204-38.dyn.iinet.net.au (HELO [10.0.1.3]) ([58.7.204.38]) by outbound-mail01.westnet.com.au with ESMTP/TLS/AES128-SHA; 02 Jan 2011 07:26:37 +0800 Subject: Re: bug#7767: 23.2.91; file-local-variables-alist should have the permanent-local property Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Alex Harsanyi In-Reply-To: Date: Sun, 2 Jan 2011 07:26:36 +0800 Content-Transfer-Encoding: 7bit Message-Id: <348B9E68-4760-4A8A-BE36-9D983576A4A4@mac.com> References: To: Stefan Monnier X-Mailer: Apple Mail (2.1082) X-Spam-Score: -4.5 (----) X-Debbugs-Envelope-To: 7767 Cc: 7767@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) 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. From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 01 22:51:46 2011 Received: (at 7767) by debbugs.gnu.org; 2 Jan 2011 03:51:46 +0000 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 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" 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 Received: by pastel.home (Postfix, from userid 20848) id 6AAF058DFC; Sat, 1 Jan 2011 22:58:45 -0500 (EST) From: Stefan Monnier To: Alex Harsanyi Subject: Re: bug#7767: 23.2.91; file-local-variables-alist should have the permanent-local property Message-ID: References: <348B9E68-4760-4A8A-BE36-9D983576A4A4@mac.com> Date: Sat, 01 Jan 2011 22:58:45 -0500 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) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 7767 Cc: 7767@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) 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. From unknown Mon Jun 16 23:41:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 30 Jan 2011 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator