From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Oct 2013 20:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 15577@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.138134967232091 (code B ref -1); Wed, 09 Oct 2013 20:15:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Oct 2013 20:14:32 +0000 Received: from localhost ([127.0.0.1]:38542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VU09P-0008LX-B0 for submit@debbugs.gnu.org; Wed, 09 Oct 2013 16:14:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47264) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VU09L-0008LL-UZ for submit@debbugs.gnu.org; Wed, 09 Oct 2013 16:14:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VU09K-0002j2-50 for submit@debbugs.gnu.org; Wed, 09 Oct 2013 16:14:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU09K-0002iy-2a for submit@debbugs.gnu.org; Wed, 09 Oct 2013 16:14:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU09I-00081a-Aw for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2013 16:14:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VU09G-0002i8-MZ for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2013 16:14:24 -0400 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:35876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU09G-0002i4-CL for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2013 16:14:22 -0400 Received: by mail-wi0-f182.google.com with SMTP id ez12so1476890wid.15 for ; Wed, 09 Oct 2013 13:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=j/45ITTET18EbG2oOxrUDu6WGptHg4dCWWkN2yZUSHI=; b=uKqKTTpDJM6/2SfoLMvJzzVWHejpFTB9Q5n7hlh2gp+GwkXXD975Fq3GwlOINtdqU1 4F8UIznsjpqfcN73EPUppc14yIA8sH1fhIOyRc6if0bAyZEAobL6gyVzmAXMwbcL2buz bo+8OLqSHx1+bO18SjtrHG0oSA9Xug5xPmbkbgqK0Tjkq1LTgM3txmXB0XdvWcAF0WS+ 0F7Qy9vawM0jtK7hoyFA5Tr7YEFjvmBJrVa5kdnFJ16fgdj2I9/QOQSYV+WnOXRuX+lD p9AkfYPiepmJ3fQbCImQtQkwTUz/4erg6ui4asagHzU/ps566S3LVi62iw6ihrUtpp2h 95JA== X-Received: by 10.194.78.78 with SMTP id z14mr8489640wjw.32.1381349660843; Wed, 09 Oct 2013 13:14:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Wed, 9 Oct 2013 13:14:00 -0700 (PDT) From: yary Date: Wed, 9 Oct 2013 16:14:00 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This bug report will be sent to the Bug-GNU-Emacs mailing list and the GNU bug tracker at debbugs.gnu.org. Please check that the From: line contains a valid email address. After a delay of up to one day, you should receive an acknowledgment at that address. Please write in English if possible, as the Emacs maintainers usually do not have translators for other languages. Please describe exactly what actions triggered the bug, and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': If I create a ".dir-locals.el" that applies to all major modes, such as: ((nil . ((tab-width . 3)))) It works when first opening any file under that directory- good. But, if I switch the buffer's major-mode, it loses the directory-local tab-width - and I've seen it lose other variables as well. An alternate case showing the same is to have a ".dir-locals.el" like: ((js-mode . ((tab-width . 3)))) and opening a non-JS file in the directory, such as an HTML file, and then switching to js-mode. Since I'm now editing the file in js-mode, I would want it to read the js-mode dir-local variables. Losing dir-locals seems like a bug to me, though perhaps there is a reason for it. I did notice from other dir-local-related bugs that they require some thought as to how to handle edge cases... In GNU Emacs 24.3.1 (i386-mingw-nt5.1.2600) of 2013-03-17 on MARVIN Windowing system distributor `Microsoft Corp.', version 5.1.2600 Configured using: `configure --with-gcc (4.7) --cflags -ID:/devel/emacs/libs/libXpm-3.5.8/include -ID:/devel/emacs/libs/libXpm-3.5.8/src -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include -ID:/devel/emacs/libs/giflib-4.1.4-1/include -ID:/devel/emacs/libs/jpeg-6b-4/include -ID:/devel/emacs/libs/tiff-3.8.2-1/include -ID:/devel/emacs/libs/gnutls-3.0.9/include -ID:/devel/emacs/libs/libiconv-1.13.1-1-dev/include -ID:/devel/emacs/libs/libxml2-2.7.8/include/libxml2' Important settings: value of $LANG: ENU locale-coding-system: cp1252 default enable-multibyte-characters: t Major mode: Info Minor modes in effect: yas-global-mode: t yas-minor-mode: t global-auto-complete-mode: t diff-auto-refine-mode: t recentf-mode: t desktop-save-mode: t 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-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Features: (shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums conf-mode sh-script smie executable info dos org-table org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks org-agenda org-info org-gnus org-docview org-bibtex bibtex org-bbdb face-remap gtags js json moz imenu thingatpt vc-git js2-mode-autoloads finder-inf undo-tree-autoloads package multi-web-mode mumamo-fun mumamo-chunks amrita desktop-autosave hide-lines yasnippet help-mode auto-complete-config auto-complete popup flymake-jslint flymake php-mode etags cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align speedbar sb-image ezimage dframe psvn derived log-edit pcvs-util add-log diff-mode elp ediff-merg ediff-diff ediff-wind ediff-mult ediff-help ediff-init ediff-util dired emacsw32 w32-integ w32shell w32-grep rebind ourcomments-widgets ourcomments-util rx cus-edit cus-start cus-load uniquify recentf tree-widget mm-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util url-parse auth-source eieio password-cache url-vars mailcap gnus gnus-ems nnheader gnus-util mail-utils mm-util mail-prsvr org ob-tangle ob-ref ob-lob ob-table org-footnote org-src ob-comint ob-keys org-pcomplete pcomplete org-list org-faces org-entities noutline outline org-version ob-emacs-lisp ob org-compat org-macs ob-eval org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs ido grep compile comint ansi-color ring bookmark pp apropos mumamo byte-opt warnings bytecomp byte-compile cconv advice help-fns advice-preload sgml-mode ruby-mode rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok mumamo-cmirr flyspell ispell desktop cc-engine cc-vars cc-defs new-key-seq-widget edmacro kmacro wid-edit hfyview easy-mmode easymenu htmlfontify cl-macs gv cl cl-lib noprint nxhtml-loader emacsw32-eol time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar 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 minibuffer loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process w32 multi-tty emacs) From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Oct 2013 21:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary Cc: 15577@debbugs.gnu.org Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138135492912440 (code B ref 15577); Wed, 09 Oct 2013 21:43:02 +0000 Received: (at 15577) by debbugs.gnu.org; 9 Oct 2013 21:42:09 +0000 Received: from localhost ([127.0.0.1]:38681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VU1WD-0003Ea-FX for submit@debbugs.gnu.org; Wed, 09 Oct 2013 17:42:09 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:60416) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VU1WB-0003ES-B4 for 15577@debbugs.gnu.org; Wed, 09 Oct 2013 17:42:07 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1VU1WA-0005KN-3k; Wed, 09 Oct 2013 17:42:06 -0400 From: Glenn Morris References: X-Spook: bluebird MDA smuggle 2600 Magazine RSA Mafia advisors X-Ran: q|D3~-@m(t-U\|Xu`Iv% (yary's message of "Wed, 9 Oct 2013 16:14:00 -0400") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.2 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) yary wrote: > If I create a ".dir-locals.el" that applies to all major modes, such as: > ((nil . ((tab-width . 3)))) > It works when first opening any file under that directory- good. But, if > I switch the buffer's major-mode, it loses the directory-local > tab-width - File-local variables behave in the same way. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Oct 2013 18:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Glenn Morris Cc: 15577@debbugs.gnu.org Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138143008622910 (code B ref 15577); Thu, 10 Oct 2013 18:35:02 +0000 Received: (at 15577) by debbugs.gnu.org; 10 Oct 2013 18:34:46 +0000 Received: from localhost ([127.0.0.1]:41329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUL4P-0005xQ-SO for submit@debbugs.gnu.org; Thu, 10 Oct 2013 14:34:46 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:53809) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUL4M-0005xA-7h for 15577@debbugs.gnu.org; Thu, 10 Oct 2013 14:34:43 -0400 Received: by mail-wg0-f44.google.com with SMTP id n12so2442138wgh.11 for <15577@debbugs.gnu.org>; Thu, 10 Oct 2013 11:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Gydg2cx7ImKCC0qpePxKTc0uAv7+y2y66b6XyWtxX00=; b=C59AyhVfgKak1CothQHFKo/b547ar0a1JlH1C+Dcg2t0dThAQ9NQC+RgaiPeMJDWd3 0UpGiHtLDKWh+rRtOZh7PsGZ3jQoNreeKYz8/knxQRseLRhZUy7X0ZW6TjASl2yaXbHA wb3XgSSTNzdqe1HSGYzwjjguE7HnMmHheIRYOPtVsimmpwffDol1lfNsUjIEkurm0UoD 2gR/Ja9Lrsg2F0/Z18PP0A8n1R5V5VsK56HQqwBDsDQPQOaQDyYGhRKMiyj8FPQEe/A6 znK4njT7lYL5DF6HPeVoW366A0EI/T8lJ2DvpENVAL/1DrU7g9m6WixyA2kdt9fBMGQm 49DQ== X-Received: by 10.180.13.113 with SMTP id g17mr9069538wic.19.1381430081110; Thu, 10 Oct 2013 11:34:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Thu, 10 Oct 2013 11:34:20 -0700 (PDT) In-Reply-To: References: From: yary Date: Thu, 10 Oct 2013 14:34:20 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Before posting the mode-change-clobbering-locals behavior as a bug, I asked about it on stackoverflow, which generated a thorough explanation : http://stackoverflow.com/questions/19280851/how-to-keep-dir-local-variables-when-switching-major-modes -y On Wed, Oct 9, 2013 at 5:42 PM, Glenn Morris wrote: > yary wrote: > >> If I create a ".dir-locals.el" that applies to all major modes, such as: >> ((nil . ((tab-width . 3)))) >> It works when first opening any file under that directory- good. But, if >> I switch the buffer's major-mode, it loses the directory-local >> tab-width - > > File-local variables behave in the same way. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Oct 2013 21:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary Cc: 15577@debbugs.gnu.org Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138144045111396 (code B ref 15577); Thu, 10 Oct 2013 21:28:02 +0000 Received: (at 15577) by debbugs.gnu.org; 10 Oct 2013 21:27:31 +0000 Received: from localhost ([127.0.0.1]:41652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUNlb-0002xj-1G for submit@debbugs.gnu.org; Thu, 10 Oct 2013 17:27:31 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:54865) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUNlX-0002xa-R5 for 15577@debbugs.gnu.org; Thu, 10 Oct 2013 17:27:29 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1VUNlW-0006aU-MP; Thu, 10 Oct 2013 17:27:26 -0400 From: Glenn Morris References: X-Spook: CISU AK-47 afsatcom Manfurov White Water nitrate FIPS140 X-Ran: (V (yary's message of "Thu, 10 Oct 2013 14:34:20 -0400") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.2 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) yary wrote: > Before posting the mode-change-clobbering-locals behavior as a bug, I > asked about it on stackoverflow, which generated a thorough > explanation : http://stackoverflow.com/questions/19280851/how-to-keep-dir-local-variables-when-switching-major-modes I think it slightly impolite to post the same question to two different places at the same time. Anyway, are you happy with the answers you have, or do you want Emacs to change? It is a long-standing behaviour that local variables (file or directory) are only applied (by normal-mode) when you visit a file, and get clobbered by major-mode changes. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Oct 2013 21:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Glenn Morris Cc: yary , 15577@debbugs.gnu.org Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138144197017854 (code B ref 15577); Thu, 10 Oct 2013 21:53:02 +0000 Received: (at 15577) by debbugs.gnu.org; 10 Oct 2013 21:52:50 +0000 Received: from localhost ([127.0.0.1]:41687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUOA5-0004ds-6o for submit@debbugs.gnu.org; Thu, 10 Oct 2013 17:52:49 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:7231) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUO9r-0004dY-Mj for 15577@debbugs.gnu.org; Thu, 10 Oct 2013 17:52:47 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT X-IPAS-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35236229" Received: from 76-10-183-132.dsl.teksavvy.com (HELO pastel.home) ([76.10.183.132]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 10 Oct 2013 17:48:45 -0400 Received: by pastel.home (Postfix, from userid 20848) id 9835D60C28; Thu, 10 Oct 2013 17:52:33 -0400 (EDT) From: Stefan Monnier Message-ID: References: Date: Thu, 10 Oct 2013 17:52:33 -0400 In-Reply-To: (Glenn Morris's message of "Thu, 10 Oct 2013 17:27:26 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Anyway, are you happy with the answers you have, or do you want Emacs to > change? It is a long-standing behaviour that local variables (file or > directory) are only applied (by normal-mode) when you visit a file, and > get clobbered by major-mode changes. I do think it's at least undesirable behavior. Not sure how best to fix it, tho. We could try and setup file-local vars when we run after-change-major-mode-hook. Stefan From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Oct 2013 23:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138144676625512 (code B ref 15577); Thu, 10 Oct 2013 23:13:02 +0000 Received: (at 15577) by debbugs.gnu.org; 10 Oct 2013 23:12:46 +0000 Received: from localhost ([127.0.0.1]:41791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUPPS-0006dP-3l for submit@debbugs.gnu.org; Thu, 10 Oct 2013 19:12:46 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:45263) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUPPP-0006dG-0v for 15577@debbugs.gnu.org; Thu, 10 Oct 2013 19:12:44 -0400 Received: by mail-wi0-f181.google.com with SMTP id l12so205780wiv.2 for <15577@debbugs.gnu.org>; Thu, 10 Oct 2013 16:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=FZpPiTRRD/2R/SPpOjhG7/cfaf/PqVUUsGyC98vwe+4=; b=Yo8niw/5ZpoZvqP4Z6thWTv2JsolB9dsw2BbU+vHVylvzFtNEhuiD5VQSwBZf9UBxR 6w+f/LvwjsQX2cDJcVb8H+ZWQM7jnF+ziiGIiu/q+S2T0+0y6Z9DG5yA4AHcBfM2pLuV QhYH5jXtIyaPtJ0yoLWcWmwZ7ZHY4yS2wObLyr1fPN2U8PRnE+tMhIqAGPcaxnC9jrbk XL+yT1l5Z4Y57WbJn9JgudnN0YCCh9VhLmL6f3d9OE4eDoL5R/NcAX7KYw/GaLMs6ci+ QFaOTVXgpnV18PE8EzLAdVChIBlcXhPMONqqsBArvRDsUavPLDgU3+JoiHVoDeaJ2qGA Oy3g== X-Received: by 10.195.13.45 with SMTP id ev13mr14324984wjd.20.1381446762329; Thu, 10 Oct 2013 16:12:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Thu, 10 Oct 2013 16:12:22 -0700 (PDT) In-Reply-To: References: From: yary Date: Thu, 10 Oct 2013 19:12:22 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) @Glenn "slightly impolite to post the same question to two different places" -Understood, but this is a bug report, different purpose from Stackoverflow question- and thus "are you happy with the answers you have, or do you want Emacs to change?"- both! The answers are a workaround for the current situation, but are slightly imperfect, and as Stefan just wrote the current scheme is "at least undesirable behavior." The problem with the "(add-hook 'after-change-major-mode-hook 'hack-local-variables)" workaround and its variants, is when a major-mode is set by a file-local variable- changing major mode will reload the local variables, which will revert the major-mode again! And the trouble with current Emacs out-of-the-box behavior is not gaining the relevant file-local and dir-local variables for a new major-mode when changing to that major-mode. I'd like to see a well-thought-out solution in some future release. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Oct 2013 18:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138177612521858 (code B ref 15577); Mon, 14 Oct 2013 18:43:02 +0000 Received: (at 15577) by debbugs.gnu.org; 14 Oct 2013 18:42:05 +0000 Received: from localhost ([127.0.0.1]:49259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVn5f-0005gP-Su for submit@debbugs.gnu.org; Mon, 14 Oct 2013 14:42:04 -0400 Received: from mail-we0-f179.google.com ([74.125.82.179]:61789) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVn5c-0005eg-Tu for 15577@debbugs.gnu.org; Mon, 14 Oct 2013 14:42:01 -0400 Received: by mail-we0-f179.google.com with SMTP id w61so7581898wes.10 for <15577@debbugs.gnu.org>; Mon, 14 Oct 2013 11:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=7Wuvimydphhz8innCv3s1BaWG+tgtxP/B7mXqyHJAAs=; b=n97cmFYQzp3Pkw5m82EEOPm7JRVKHrUJewriLnJGZ02THTZOhamjpGc7ZybAxk30uc k4gGJ2bZ601SS9oicr/DK53r0WggribnmvgKVWAKvnGO7c3C8XX3LeYqd+OJzTp5Ksge SkyUPCPz0fz+qV8Gzo4kv+q/yVScQOecPKlQjYTopT60sQU4GJ90N7g9Vw6KVp6Zj61M a5GnHf0GGzERnJC9OgFkGMQkuIvtlvg9G4qsY/uvLEGTspkEplprW9YVHOSwIy4R2Dqy fjNzwDFONkTQuVU/2sWkBB1Rd4k7Tad9p3i3gehDNLzV/GADXFSYnljdDR79gA3S8Srf 8YyA== X-Received: by 10.194.110.138 with SMTP id ia10mr31271942wjb.3.1381776115007; Mon, 14 Oct 2013 11:41:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Mon, 14 Oct 2013 11:41:34 -0700 (PDT) In-Reply-To: References: From: yary Date: Mon, 14 Oct 2013 14:41:34 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Thinking about switching major modes more, my instinct is that the right solution involves being "smarter" both about which local variables to clear and reloading any {dir,file}-local variables for the new node. Basically, at the start, instead of calling "kill-all-local-variables", only clear the locals that were set as a consequence of the old mode. That is, if it was set directly by the old mode, or by dir-local matching the old mode, delete it. Don't delete a buffer-local variable if it was set explicitly by the user after opening during the editing session. Then after the new mode has set itself, recheck dir-locals and set any that match the new mode. Alas I don't use file-locals so am not sure how their use cases fit. Ignore any "mode:" specifiers and maybe "eval:" as well after the mode-change, I'd guess. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Oct 2013 14:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138193360414369 (code B ref 15577); Wed, 16 Oct 2013 14:27:02 +0000 Received: (at 15577) by debbugs.gnu.org; 16 Oct 2013 14:26:44 +0000 Received: from localhost ([127.0.0.1]:54338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWS3f-0003jg-Bo for submit@debbugs.gnu.org; Wed, 16 Oct 2013 10:26:43 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:57187) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWS3d-0003jS-85 for 15577@debbugs.gnu.org; Wed, 16 Oct 2013 10:26:41 -0400 Received: by mail-wi0-f171.google.com with SMTP id h11so2473606wiv.16 for <15577@debbugs.gnu.org>; Wed, 16 Oct 2013 07:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Z4TYfI5k3xL/lz6bM5F9YkxHjfRzV8ouvYMYaGyvcdw=; b=BPd8dz7IFmXr30SapLdpBfeieE2oXWPNfniC0Z2k7BFbXgjJAOQnKKeoXeTI6yPP0H /AoHcfSrnBL/QsoDnqbZ3oKcjFSbF7VCZWDAPcg48Ty+wHXmfm+YiswiJzJXgJZu7HFc NIfhk1VuDIw+p+vdYPwMZV9xxDamGPAiEfEN87VdIxyhaKbla9qkIgd6higw5FV+whIz 6la5qYdhao0F/zWWWXOMnZVql6gt2eegIYP1s2gs+bUnOARC4I/vLAaFyWm4Z9zlvopr z8eddKJG6eW+s+3v0kCx6paDo284AZZ0uu8HeK/ag1OWDbgw7y1K7yvKBVQrMySdjX7C vDnQ== X-Received: by 10.180.99.99 with SMTP id ep3mr2565532wib.11.1381933595277; Wed, 16 Oct 2013 07:26:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Wed, 16 Oct 2013 07:26:14 -0700 (PDT) In-Reply-To: References: From: yary Date: Wed, 16 Oct 2013 10:26:14 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) More thoughts, overturning my previous message of Oct 14th. I think I have the essence of the issues now. In my editing, I switch modes within a buffer (file) when working on: A. databases- SQL inside code, or non-SQL language inside SQL triggers B. web- HTML, CSS, JS is just the beginning... C. any language with heredocs (shell, python, perl)- sometimes have unrelated language blocks inside parent/wrapper code and I've had these undesirable local-variable issues caused by that mode switching: 1. dir-locals not being applied in the new mode 2. "manually" set local variables and minor-modes being lost. Issue #1 "dir locals" is a narrow use case. Dir locals are not intended to set a major mode; they are meant to set buffer-locals after the major mode is in place. Whether set by a .dir-locals,el file or dir-locals-set-* functions, the user is saying "buffers from files here in this mode should have those variables set" and is saying so clearly. So, to fix that issue, after switching major modes, it would be good to run "hack-dir-local-variables-non-file-buffer" to pick up any dir-locals for the new mode. Properly implementing that as an Emacs bug-fix is out of my skillset, though the tips from stackoverflow helped me put a workaround in my ~/.emacs Issue #2- "manually" set buffer-local's, and by extension file-local variables- is trickier. Trying to automate what happens there smells of unintended consequences. The answer here is an easier way for us to set the "permanent-local-hook" property for variables (eg "tab-width"), and minor-modes (eg "buffer-face-mode" with its new face). Then I & others who use file-locals can mark a particular item as "permanent" right in the file. Additionally, for other local variables that people might want to keep (eg set interactively), have an interactive command to mark a buffer-local variable or minor-mode as permanent. And also, allow describe-variable, describe-minor-mode to show/set the "permanent-local-hook" property. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Oct 2013 15:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138211106531492 (code B ref 15577); Fri, 18 Oct 2013 15:45:03 +0000 Received: (at 15577) by debbugs.gnu.org; 18 Oct 2013 15:44:25 +0000 Received: from localhost ([127.0.0.1]:57053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCDx-0008Bs-2D for submit@debbugs.gnu.org; Fri, 18 Oct 2013 11:44:25 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:49076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCDt-0008BY-6a for 15577@debbugs.gnu.org; Fri, 18 Oct 2013 11:44:22 -0400 Received: by mail-we0-f169.google.com with SMTP id q58so4001664wes.0 for <15577@debbugs.gnu.org>; Fri, 18 Oct 2013 08:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=GseDk7ManB1DGYKxXVYyQbkL69+jymwZRc44AnYrdgc=; b=DfYPsHW7SKd+nHYGQUuQFcuGPttpo7Kq0bwTCnjJr3VORRMEHH1NpN7u+KQzGhabm9 ZmgF5XHs4KoBi7+in1Pxq1Q/ffxc5omHRDKsNcE0l4omSlic2eLwYdjysphAnY56qKMt g9P7gx+NFP3p50wG4GtQHHH375TFMzd98j2TgVVI32EMbTRpMneoc0fpu1hxLL4+yV5d 6AEcmgtL8LrPBJi4O9nzq/cwwJjM7SbzPyOs/+1uX9e7V2YaG0pUOuz1mkkJoFFi2fTL 7xRzwCvqFG7NqWdG1mLOfloy7jl8QXHi6iCrFXdiJGJn0kao0A5/dVyq43EJ+Sm1ESTA ydbA== X-Received: by 10.180.99.99 with SMTP id ep3mr3022024wib.11.1382111055034; Fri, 18 Oct 2013 08:44:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Fri, 18 Oct 2013 08:43:54 -0700 (PDT) In-Reply-To: References: From: yary Date: Fri, 18 Oct 2013 11:43:54 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) My implementation thoughts for core-level fixes, after working on personal workarounds. For sub-issue #1 "dir-locals not being applied in the new mode," divide the responsibility for setting file-locals and dir-locals between `normal-mode find-file=t' and `define-derived-mode'. Just have `define-derived-mode' call `(hack-dir-local-variables)(hack-local-variables-apply)' unless it is being called as a result of `normal-mode t'. There's no change needed for the normal-mode function or anything it calls, except perhaps setting something that the define-derived-mode macro can check. For sub-issue #2 "an easier way for us to preserve minor-modes and buffer-local variables when switching modes"- I discovered this exchange showing it's been raised before https://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00366.html which resulted in adding the property `permanent-local-hook' to compliment the `permanent-local' property, facilitating minor-mode preservation. That was in the context of helping mode authors preserve specific minor-modes. In itself, it isn't enough for a generic minor-mode preservation but it can help. A function to preserve any minor-mode needs to a. Get all of that mode's customizable buffer-locals. Ideally the minor-mode, or emacs core, would provide a function for that purpose. If not, might be able to reliably get a list by creating a scratch buffer, saving results of `buffer-local-variables', enabling the minor mode in question, then mark the differences from a subsequent call to `buffer-local-variables'. b. Mark those variables as permanent-local Then either b1. Continue to allow major-mode changes to disable all minor-modes, but re-enable the user-requested minor-modes after calling kill-all-local-variables. This doesn't require any use of `permanent-local-hook'; the minor mode is being disabled and re-enabled and any hooks can be normally uninstalled & re-installed & re-run b2. Apply `permanent-local-hook' to all the minor-mode's hook functions. The minor mode might provide those symbols via a function for that purpose, or perhaps they could be auto-discovered. Alas I don't yet know enough about Emacs' minor-mode handling to get further with these thoughts. Thanks for bearing with me. -y From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Oct 2013 16:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.13821137798383 (code B ref 15577); Fri, 18 Oct 2013 16:30:02 +0000 Received: (at 15577) by debbugs.gnu.org; 18 Oct 2013 16:29:39 +0000 Received: from localhost ([127.0.0.1]:57100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCvh-0002B7-Tu for submit@debbugs.gnu.org; Fri, 18 Oct 2013 12:29:38 -0400 Received: from nctlincom01.orcon.net.nz ([60.234.4.69]:60055) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXCvd-0002Av-Hw for 15577@debbugs.gnu.org; Fri, 18 Oct 2013 12:29:35 -0400 Received: from mx7.orcon.net.nz (mx7.orcon.net.nz [219.88.242.57]) by nctlincom01.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9IGZYlF015769 for <15577@debbugs.gnu.org>; Sat, 19 Oct 2013 05:35:36 +1300 Received: from Debian-exim by mx7.orcon.net.nz with local (Exim 4.69) (envelope-from ) id 1VXCvX-0000rS-69 for 15577@debbugs.gnu.org; Sat, 19 Oct 2013 05:29:27 +1300 Received: from [121.99.86.188] (helo=[10.1.1.3]) by mx7.orcon.net.nz with esmtpa (Exim 4.69) (envelope-from ) id 1VXCvW-0000qQ-TM for 15577@debbugs.gnu.org; Sat, 19 Oct 2013 05:29:27 +1300 Message-ID: <526161D7.7040502@orcon.net.nz> Date: Sat, 19 Oct 2013 05:29:11 +1300 From: Phil Sainty User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-DSPAM-Check: by mx7.orcon.net.nz on Sat, 19 Oct 2013 05:29:27 +1300 X-DSPAM-Result: Innocent X-DSPAM-Processed: Sat Oct 19 05:29:27 2013 X-DSPAM-Confidence: 0.5426 X-DSPAM-Probability: 0.0000 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, default) X-Spam-Score: -3.00 () [Hold at 4.00] CC(NZ:-3) X-CanIt-Geo: ip=121.99.86.188; country=NZ; region=E7; city=Auckland; latitude=-36.8667; longitude=174.7667; http://maps.google.com/maps?q=-36.8667,174.7667&z=6 X-CanItPRO-Stream: base:default X-Canit-Stats-ID: 06KCEzzq3 - 2c75db5c9e25 - 20131019 X-Scanned-By: CanIt (www . roaringpenguin . com) on 172.16.100.174 X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) My gut feeling is that retaining (across a major mode change) the values of local variables which were set *interactively* probably isn't a practical thing to try to do? For starters we would have to flag variables as having been set interactively, otherwise there would be no way of telling which local values should be kept and which should be cleared. (e.g. if a major mode hook sets a local variable, we're not going to want to retain that when we change major modes.) But even knowing that a value was set interactively still isn't a *guarantee* that it should remain unchanged for the new major mode? What seems much simpler is to always hack-local-variables after a major mode change, and simply work out a solution to the associated problem with local 'mode' variables. If we do that, then all of the local variables which are *automatically* set for a given mode will be set correctly, which is all people actually need, most of the time. That seems to me like a "good enough" approach (and one which should be safer). At present `normal-mode' runs: (report-errors "File local-variables error: %s" (hack-local-variables)) My first thought was to just move that into `run-mode-hooks', but that relies upon the major mode function running its mode hook, which I presume isn't guaranteed (and maybe this is exactly why the code *does* run in `normal-mode'?) It's unclear to me whether this is a real concern, though -- can we assume that all major modes *will* call `kill-all-local-variables' and `run-mode-hooks'? Certainly all the non-derived major modes I've looked at in the Emacs lisp files take care of these steps manually. (Well... I suppose for any modes which don't do this housekeeping, there's actually nothing we can do to help in the situation when they are called interactively. So as long as we ensure that things work when `normal-mode' runs, and also when any *well-behaved* major mode is called interactively, we'll be doing everything that we can reasonably do.) So... how about this as a basic approach: * Define a new buffer-local variable to track whether local vars have been hacked (nil by default). This will obviously get reset in any given buffer when a mode calls `kill-all-local-variables'; and to take care of the case when `set-auto-mode' calls a 'badly-behaved' mode (one which does not kill local vars), we can also let-bind the variable to nil in normal-mode. * `normal-mode' then tests this variable before calling `hack-local-variables', only calling the function if the variable is nil. Most of the time, however, it will be non-nil, because... * `run-mode-hooks' calls `hack-local-variables' after it has run `after-change-major-mode-hook'. This is therefore the way that the vast majority of major modes will set the local vars, (but the code in `normal-mode' will still account for exceptions). See diffs below (from 24.3, and untested) for a possible implementation. This approach seems a little cleaner than the one used in the Stack Overflow workaround, as this way we are more consistent in *where* we call `hack-local-variables' for a given mode (the other approach would either call it after the mode change OR in normal-mode, depending on whether or not the mode was called interactively.) That leaves the problem of local 'mode' variables making it impossible to interactively call a different mode (because we immediately switch back to the mode specified by the local var). The code has me slightly confused here: `hack-one-local-variable' calls the mode function when there is a local mode variable, but my initial thought is that we only want to use a local mode var when running `set-auto-mode'? Yet set-auto-mode has already set the mode -- using the (hack-local-variables MODE-ONLY) look-up -- *before* we get to `hack-one-local-variable', so should the latter function actually ignore 'mode' vars instead? If we did that, then the problem would go away. I suspect I'm missing something here? Ah, okay; `autoload-find-file' is an example of code which could need a mode var to be processed directly by `hack-one-local-variable'. How about if we provide a new variable which determines whether or not local mode variables will be applied? Or maybe it should be an argument to `hack-local-variables'? By default we enable the behaviour, so there's no change for any code which hacks local variables directly; but in `normal-mode' and `run-mode-hooks' we explicitly disable it, so that mode variables are ignored. (n.b. The example code below does not implement this suggestion.) -Phil diff -u -L /usr/local/share/emacs/24.3/lisp/files.el.gz -L \#\ /tmp/jka-com2287tTC /tmp/buffer-content-2287HoO --- /usr/local/share/emacs/24.3/lisp/files.el.gz +++ # @@ -2172,13 +2172,17 @@ in that case, this function acts as if `enable-local-variables' were t." (interactive) (funcall (or (default-value 'major-mode) 'fundamental-mode)) - (let ((enable-local-variables (or (not find-file) enable-local-variables))) + (let ((enable-local-variables (or (not find-file) enable-local-variables)) + (local-variables-hacked nil)) ;; FIXME this is less efficient than it could be, since both ;; s-a-m and h-l-v may parse the same regions, looking for "mode:". (report-errors "File mode specification error: %s" (set-auto-mode)) - (report-errors "File local-variables error: %s" - (hack-local-variables))) + ;; Most major modes will hack local vars via `run-mode-hooks'; + ;; this catches the exceptions: + (unless local-variables-hacked + (report-errors "File local-variables error: %s" + (hack-local-variables)))) ;; Turn font lock off and on, to make sure it takes account of ;; whatever file local variables are relevant to it. (when (and font-lock-mode @@ -3140,6 +3144,11 @@ (assq-delete-all (car elt) file-local-variables-alist))) (push elt file-local-variables-alist))))) +(defvar local-variables-hacked nil + "Buffer-local variable which indicates whether `hack-local-variables' +has run for the current buffer.") +(make-variable-buffer-local 'local-variables-hacked) + (defun hack-local-variables (&optional mode-only) "Parse and put into effect this buffer's local variables spec. Uses `hack-local-variables-apply' to apply the variables. @@ -3277,7 +3286,8 @@ (if mode-only result ;; Otherwise, set the variables. (hack-local-variables-filter result nil) - (hack-local-variables-apply))))) + (hack-local-variables-apply) + (setq local-variables-hacked t))))) (defun hack-local-variables-apply () "Apply the elements of `file-local-variables-alist'. diff -u -L /usr/local/share/emacs/24.3/lisp/subr.el.gz -L \#\ /tmp/jka-com2287GnH /tmp/buffer-content-2287g7T --- /usr/local/share/emacs/24.3/lisp/subr.el.gz +++ # @@ -1588,7 +1588,9 @@ (setq hooks (nconc (nreverse delayed-mode-hooks) hooks)) (setq delayed-mode-hooks nil) (apply 'run-hooks (cons 'change-major-mode-after-body-hook hooks)) - (run-hooks 'after-change-major-mode-hook))) + (run-hooks 'after-change-major-mode-hook) + (report-errors "File Local-variables error: %s" + (hack-local-variables)))) (defmacro delay-mode-hooks (&rest body) "Execute BODY, but delay any `run-mode-hooks'. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2013 01:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138214553131225 (code B ref 15577); Sat, 19 Oct 2013 01:19:01 +0000 Received: (at 15577) by debbugs.gnu.org; 19 Oct 2013 01:18:51 +0000 Received: from localhost ([127.0.0.1]:57432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXLBq-00087Y-Aj for submit@debbugs.gnu.org; Fri, 18 Oct 2013 21:18:50 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:53547) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXLBn-00087J-1Q for 15577@debbugs.gnu.org; Fri, 18 Oct 2013 21:18:48 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFLd+GD/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFFLd+GD/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35853871" Received: from 75-119-225-131.dsl.teksavvy.com (HELO pastel.home) ([75.119.225.131]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 18 Oct 2013 21:18:40 -0400 Received: by pastel.home (Postfix, from userid 20848) id 7F8BC610B6; Fri, 18 Oct 2013 21:18:39 -0400 (EDT) From: Stefan Monnier Message-ID: References: Date: Fri, 18 Oct 2013 21:18:39 -0400 In-Reply-To: (yary's message of "Fri, 18 Oct 2013 11:43:54 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > For sub-issue #1 "dir-locals not being applied in the new mode," > divide the responsibility for setting file-locals and dir-locals > between `normal-mode find-file=t' and `define-derived-mode'. Just have > `define-derived-mode' call > `(hack-dir-local-variables)(hack-local-variables-apply)' unless it is > being called as a result of `normal-mode t'. There's no change needed > for the normal-mode function or anything it calls, except perhaps > setting something that the define-derived-mode macro can check. Yes, as mentioned earlier, a possible fix is to move the file-local and dir-local setup code from normal-mode to after-change-major-mode-hook. > a. Get all of that mode's customizable buffer-locals. Not sure what that is. > Ideally the minor-mode, or emacs core, would provide a function for > that purpose. It's probably not possible (not reliably at least) with the way minor modes are defined currently. Tho depending on what you mean it might be a non-issue. > b. Mark those variables as permanent-local There's no such thing, currently (we instead have to use a hack with change-major-mode-hook, along the lines of what you did). For minor-modes, what we could do is to check which buffer-local minor-modes are enabled, and to "simply" re-enable them in after-change-major-mode-hook. But there are some issues: - we have to find out which buffer-local minor-modes are enabled, which presumes we have some kind of list of minor-modes. We can probably use minor-mode-list for that, tho. - some minor modes are mode-specific; e.g. it doesn't make much sense to preserve reftex-mode when switching from latex-mode to haskell-mode. Stefan From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2013 19:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138220972614771 (code B ref 15577); Sat, 19 Oct 2013 19:09:01 +0000 Received: (at 15577) by debbugs.gnu.org; 19 Oct 2013 19:08:46 +0000 Received: from localhost ([127.0.0.1]:58194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXbtG-0003qA-08 for submit@debbugs.gnu.org; Sat, 19 Oct 2013 15:08:46 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:49253) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXbtD-0003pv-So for 15577@debbugs.gnu.org; Sat, 19 Oct 2013 15:08:44 -0400 Received: by mail-we0-f171.google.com with SMTP id t60so4928287wes.16 for <15577@debbugs.gnu.org>; Sat, 19 Oct 2013 12:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=uik3nXMtFqLzKW6MrkasuXbQqxUixuzDWTd0r0Mp2I0=; b=MrrvwCRkH7hfUbdxMRMdtc0iZ2RHIfOD3u1elG6s8ffgLtVwYr0ZGfS1GwSr6eIFd+ JjVKxkkyF2fmuwA4uviCQHFkYwS5kTxZpWjK6wlXePuaTsiWaCMVKlvDieOrUDUF2ZQo jRSpdjE0VrpydWsp64a1kXWzMxkdZ7mBqfBa2QRYIMBjmBbW/COPas9XwndUf/bwHvZe hwy5rtfJAkso2UlSqYY9RcQCLxY8k4dFyooCVasJ4TkVPOdslSCTpgoDILBDnGrhugIX exewDzLR+Uj689ZnNg0QFKeY4U+xvioS0AYfwtSNp7VBkCrJebuaefnNF96glnq4mQBe yUtQ== X-Received: by 10.180.185.101 with SMTP id fb5mr3864046wic.11.1382209717929; Sat, 19 Oct 2013 12:08:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Sat, 19 Oct 2013 12:08:17 -0700 (PDT) In-Reply-To: References: From: yary Date: Sat, 19 Oct 2013 15:08:17 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Fri, Oct 18, 2013 at 9:18 PM, Stefan Monnier wrote: >> For sub-issue #1 "dir-locals not being applied in the new mode," >> divide the responsibility for setting file-locals and dir-locals >> between `normal-mode find-file=t' and `define-derived-mode'. Just have >> `define-derived-mode' call >> `(hack-dir-local-variables)(hack-local-variables-apply)' unless it is >> being called as a result of `normal-mode t'. There's no change needed >> for the normal-mode function or anything it calls, except perhaps >> setting something that the define-derived-mode macro can check. > > Yes, as mentioned earlier, a possible fix is to move the file-local and > dir-local setup code from normal-mode to after-change-major-mode-hook. Moving dir-local setup code to after-change-major-mode-hook would be a simple fix for issue #1. File-local (as it is now) in after-change-major-mode-hook would cause some problems eg. if a file-local sets the mode! I'm opening a new bug for handling file-locals after major-mode-change, it's different enough to warrant its own discussion (and will also answer your questions about what I meant there), The initial report here was about dir-locals, which has a solution independent from the other buffer-local issues; let's just keep this bug#15577 about re-applying dir locals after a mode change. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2013 21:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.13822197187268 (code B ref 15577); Sat, 19 Oct 2013 21:56:01 +0000 Received: (at 15577) by debbugs.gnu.org; 19 Oct 2013 21:55:18 +0000 Received: from localhost ([127.0.0.1]:58315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXeUP-0001tA-8a for submit@debbugs.gnu.org; Sat, 19 Oct 2013 17:55:17 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:35612) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXeUN-0001st-AH for 15577@debbugs.gnu.org; Sat, 19 Oct 2013 17:55:15 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFsr+kq/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFFsr+kq/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35890344" Received: from 108-175-233-42.dsl.teksavvy.com (HELO pastel.home) ([108.175.233.42]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 19 Oct 2013 17:55:09 -0400 Received: by pastel.home (Postfix, from userid 20848) id 82691608B1; Sat, 19 Oct 2013 17:55:09 -0400 (EDT) From: Stefan Monnier Message-ID: References: Date: Sat, 19 Oct 2013 17:55:09 -0400 In-Reply-To: (yary's message of "Sat, 19 Oct 2013 15:08:17 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Moving dir-local setup code to after-change-major-mode-hook would be a > simple fix for issue #1. File-local (as it is now) in > after-change-major-mode-hook would cause some problems eg. if a > file-local sets the mode! Obviously if we move the mode-setting part, we introduce a bug, so we wouldn't move it (it's already handled separately for the same kind of reasons). Stefan From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Oct 2013 13:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Glenn Morris , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.13822740863247 (code B ref 15577); Sun, 20 Oct 2013 13:02:02 +0000 Received: (at 15577) by debbugs.gnu.org; 20 Oct 2013 13:01:26 +0000 Received: from localhost ([127.0.0.1]:58800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXsdJ-0000qI-NE for submit@debbugs.gnu.org; Sun, 20 Oct 2013 09:01:26 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:44665) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXsdH-0000q2-8e for 15577@debbugs.gnu.org; Sun, 20 Oct 2013 09:01:24 -0400 Received: by mail-wg0-f46.google.com with SMTP id m15so5391633wgh.1 for <15577@debbugs.gnu.org>; Sun, 20 Oct 2013 06:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PvWZm2FHfsln45t0A1moAz2Xp7986tHGVh9Z2irIh9c=; b=toM8ZIc1b9D6e0T1qYMctJ+Vxgey+nu8pgrDKNrNYa/wQ/ucpqFF0SyelzsvO9aDyL NpclANd0SINiRgU1zE/yu1s8+yo9Jh39Bf72qL/L4Ea+Wx75f32yRyuRO5p1WnPwawU4 8o2f0L3rY0U8Qt+CqLOUOPIZKChMN8DjnyMwXTsjxI588dau7u4BYRMZVH0hwfaE0Qcm qVpYgkkqHAhFSpaT4TKybZkTiNBfhrAxhujzdGhtW0brFb6rT1WmlNzhFjRFa7HWo7aJ gg1zQAxYN3p2wyQ2lW0B5mWAeahjnoZoN8RrSUqZPZrPZOLLoNk1WFlZVUBNvFO+1/Tb Xf+A== X-Received: by 10.194.104.42 with SMTP id gb10mr9712270wjb.16.1382274077477; Sun, 20 Oct 2013 06:01:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Sun, 20 Oct 2013 06:00:57 -0700 (PDT) In-Reply-To: References: From: yary Date: Sun, 20 Oct 2013 09:00:57 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) For anyone following this discussion, I moved the non-dir-local parts to: bug#15658: Easy way to make a file-local variable also permanent-local bug#15659: Simple method for preserving minor-mode >> Moving dir-local setup code to after-change-major-mode-hook would be a >> simple fix for issue #1. File-local (as it is now) in >> after-change-major-mode-hook would cause some problems eg. if a >> file-local sets the mode! > >Obviously if we move the mode-setting part, we introduce a bug, so we >wouldn't move it (it's already handled separately for the same kind of >reasons). Right. So it looks like a patch for moving dir-local setup to after-change-major-mode-hook is in order. Where I fall down in the implementation is figuring out what exactly changes so that I don't change behavior for find-file or kill-all-local-variables, and also don't set dir-locals twice when opening a file (without using defadvice which seems wrong in the core). Plus I'd have to get started as a contributor. Neither are insurmountable, though I think I don't have much more time to devote to these at the moment. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Oct 2013 13:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary , Stefan Monnier Cc: 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.13822763726801 (code B ref 15577); Sun, 20 Oct 2013 13:40:02 +0000 Received: (at 15577) by debbugs.gnu.org; 20 Oct 2013 13:39:32 +0000 Received: from localhost ([127.0.0.1]:58834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXtEC-0001la-0V for submit@debbugs.gnu.org; Sun, 20 Oct 2013 09:39:32 -0400 Received: from nctlincom02.orcon.net.nz ([60.234.4.76]:58894) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXtE6-0001lM-1g for 15577@debbugs.gnu.org; Sun, 20 Oct 2013 09:39:27 -0400 Received: from mx3.orcon.net.nz (mx3.orcon.net.nz [219.88.242.53]) by nctlincom02.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9KDe5mg008356 for <15577@debbugs.gnu.org>; Mon, 21 Oct 2013 02:40:05 +1300 Received: from Debian-exim by mx3.orcon.net.nz with local (Exim 4.69) (envelope-from ) id 1VXtE1-0008HY-TY for 15577@debbugs.gnu.org; Mon, 21 Oct 2013 02:39:21 +1300 Received: from [121.99.86.188] (helo=[10.1.1.3]) by mx3.orcon.net.nz with esmtpa (Exim 4.69) (envelope-from ) id 1VXtE1-0008Gk-NZ; Mon, 21 Oct 2013 02:39:21 +1300 Message-ID: <5263DCF3.7070501@orcon.net.nz> Date: Mon, 21 Oct 2013 02:38:59 +1300 From: Phil Sainty User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-DSPAM-Check: by mx3.orcon.net.nz on Mon, 21 Oct 2013 02:39:21 +1300 X-DSPAM-Result: Innocent X-DSPAM-Processed: Mon Oct 21 02:39:21 2013 X-DSPAM-Confidence: 0.5395 X-DSPAM-Probability: 0.0001 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, default) X-Spam-Score: -3.00 () [Hold at 4.00] CC(NZ:-3) X-CanIt-Geo: ip=121.99.86.188; country=NZ; region=E7; city=Auckland; latitude=-36.8667; longitude=174.7667; http://maps.google.com/maps?q=-36.8667,174.7667&z=6 X-CanItPRO-Stream: base:default X-Canit-Stats-ID: 05KDpE5ml - 41b3beee06f7 - 20131021 X-Scanned-By: CanIt (www . roaringpenguin . com) on 172.16.100.175 X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) I've been experimenting with this today (along the lines of http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-10/msg00534.html ) and one of the things I noticed which I'd not previously considered was the major mode switches which happen every time you enter the minibuffer. I expect that we should make an exception for those mode changes, as (a) that is going to be a far more frequent occurrence -- and for people who enable local variable processing for tramp buffers, probably annoyingly expensive to boot -- but more importantly (b) there surely aren't any actual use-cases for dir/file locals in the minibuffer? Does that sound sensible? -Phil From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Oct 2013 13:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Phil Sainty Cc: yary , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138236107018287 (code B ref 15577); Mon, 21 Oct 2013 13:12:02 +0000 Received: (at 15577) by debbugs.gnu.org; 21 Oct 2013 13:11:10 +0000 Received: from localhost ([127.0.0.1]:60399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYFGH-0004kr-AX for submit@debbugs.gnu.org; Mon, 21 Oct 2013 09:11:09 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:4687) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYFGE-0004kL-Nn for 15577@debbugs.gnu.org; Mon, 21 Oct 2013 09:11:07 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEBAQIBAQJTIwULCw4mEhQUBA0kiB4GDMEhkQoDk1+DSo1RgV6DEw X-IPAS-Result: Av8EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEBAQIBAQJTIwULCw4mEhQUBA0kiB4GDMEhkQoDk1+DSo1RgV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35964445" Received: from 69-196-176-151.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.151]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 21 Oct 2013 09:11:01 -0400 Received: by pastel.home (Postfix, from userid 20848) id B9AB46032F; Mon, 21 Oct 2013 09:11:00 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5263DCF3.7070501@orcon.net.nz> Date: Mon, 21 Oct 2013 09:11:00 -0400 In-Reply-To: <5263DCF3.7070501@orcon.net.nz> (Phil Sainty's message of "Mon, 21 Oct 2013 02:38:59 +1300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > I've been experimenting with this today (along the lines of > http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-10/msg00534.html ) > and one of the things I noticed which I'd not previously considered > was the major mode switches which happen every time you enter the > minibuffer. I don't see why that would be a problem: only the *Minibuf-N* buffer changes major mode (and not even that, really, because mini-buffers don't follow the rules w.r.t major modes). Stefan From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: yary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Oct 2013 13:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Phil Sainty , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138236184919530 (code B ref 15577); Mon, 21 Oct 2013 13:25:02 +0000 Received: (at 15577) by debbugs.gnu.org; 21 Oct 2013 13:24:09 +0000 Received: from localhost ([127.0.0.1]:60419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYFSq-00054v-S3 for submit@debbugs.gnu.org; Mon, 21 Oct 2013 09:24:09 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:58653) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYFSo-00054Q-U7 for 15577@debbugs.gnu.org; Mon, 21 Oct 2013 09:24:07 -0400 Received: by mail-wi0-f175.google.com with SMTP id hm4so3915359wib.2 for <15577@debbugs.gnu.org>; Mon, 21 Oct 2013 06:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=V9FLru2+DYlHVUj99m5ZX14CA3qeZUOhQI5E1oV4wh4=; b=M5m02Jr1ZtgC4HrBf2O/mtOkQ45MRm08YPPC97II14f2t8P1gKwClp0JTFbmYjbYPG jsAnqGO+ZVlk7655O8RSiOFehZLAFESCa3VrQmdEUr8rkJBaICufPiMYlKUPCJ9TCkhy /tLnOmBdvWL+mty4eZW9G8iSq9lF3Tx3lejXiKxn/Vy5LVPWYcS5cV6Nlk1tWxmbkV3i rLNq/NTvD7dSavZzZjLwnUCM3MwJq5y4Gp75MrfPWIKw4KeSaC6+HFMPKwFtTV1dCR4e lmSoSvQ6fMkRb99VIhpe3zMo3dMRYoKJqianEfgQg7dZvm7VsjwD+hgqzcsDy+jP/x5O UPUA== X-Received: by 10.194.178.166 with SMTP id cz6mr1822787wjc.53.1382361841158; Mon, 21 Oct 2013 06:24:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.83.72 with HTTP; Mon, 21 Oct 2013 06:23:41 -0700 (PDT) In-Reply-To: References: <5263DCF3.7070501@orcon.net.nz> From: yary Date: Mon, 21 Oct 2013 09:23:41 -0400 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Mon, Oct 21, 2013 at 9:11 AM, Stefan Monnier wrote: >> I've been experimenting with this today (along the lines of >> http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-10/msg00534.html ) >> and one of the things I noticed which I'd not previously considered >> was the major mode switches which happen every time you enter the >> minibuffer. > > I don't see why that would be a problem: only the *Minibuf-N* buffer > changes major mode (and not even that, really, because mini-buffers > don't follow the rules w.r.t major modes). I also noticed that going into the minibuffer would trigger mode-change hooks, and much hilarity ensued when I had a call to the debugger dropped in there... I don't have more to add other than I am following these posts with interest, and thanks for running it. Seems like you will be able to handle both file and dir-locals, and that splitting out file locals to bug #15658 was premature- I prefer the way you're going, since it keeps the permanence within the buffer; my proposal would have set the "permanent-local" property and alas properties are always global. From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Oct 2013 14:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: yary Cc: Phil Sainty , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138236540925263 (code B ref 15577); Mon, 21 Oct 2013 14:24:01 +0000 Received: (at 15577) by debbugs.gnu.org; 21 Oct 2013 14:23:29 +0000 Received: from localhost ([127.0.0.1]:60793 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGOG-0006ZN-Gb for submit@debbugs.gnu.org; Mon, 21 Oct 2013 10:23:28 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:39100) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGOD-0006Z7-Eq for 15577@debbugs.gnu.org; Mon, 21 Oct 2013 10:23:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35972508" Received: from 69-196-176-151.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.151]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 21 Oct 2013 10:23:18 -0400 Received: by pastel.home (Postfix, from userid 20848) id D33CB60458; Mon, 21 Oct 2013 10:23:12 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5263DCF3.7070501@orcon.net.nz> Date: Mon, 21 Oct 2013 10:23:12 -0400 In-Reply-To: (yary's message of "Mon, 21 Oct 2013 09:23:41 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > I prefer the way you're going, Just to clarify, in case there was some confusion: I'm not actually working on any of that. I'm just giving guidance for someone who wants to write a patch. Stefan "plenty of other things to do right now" From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Resent-From: "Phil Sainty" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Oct 2013 21:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "Stefan Monnier" Cc: yary , Phil Sainty , 15577 <15577@debbugs.gnu.org> Received: via spool by 15577-submit@debbugs.gnu.org id=B15577.138239272632393 (code B ref 15577); Mon, 21 Oct 2013 21:59:01 +0000 Received: (at 15577) by debbugs.gnu.org; 21 Oct 2013 21:58:46 +0000 Received: from localhost ([127.0.0.1]:33498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYNUr-0008QO-IU for submit@debbugs.gnu.org; Mon, 21 Oct 2013 17:58:45 -0400 Received: from nctlincom01.orcon.net.nz ([60.234.4.69]:43144) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYNUn-0008Q7-D0 for 15577@debbugs.gnu.org; Mon, 21 Oct 2013 17:58:43 -0400 Received: from mx5.orcon.net.nz (mx5.orcon.net.nz [219.88.242.55]) by nctlincom01.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9LM52wF021482 for <15577@debbugs.gnu.org>; Tue, 22 Oct 2013 11:05:02 +1300 Received: from Debian-exim by mx5.orcon.net.nz with local (Exim 4.69) (envelope-from ) id 1VYNUj-0002r8-FS for 15577@debbugs.gnu.org; Tue, 22 Oct 2013 10:58:37 +1300 Received: from [172.16.100.200] (helo=mail.orcon.net.nz) by mx5.orcon.net.nz with esmtp (Exim 4.69) (envelope-from ) id 1VYNUj-0002qZ-4r; Tue, 22 Oct 2013 10:58:37 +1300 Received: from 202.78.240.7 (SquirrelMail authenticated user 15631029) by mail.orcon.net.nz with HTTP; Tue, 22 Oct 2013 10:58:37 +1300 (NZDT) Message-ID: <54359.202.78.240.7.1382392717.squirrel@mail.orcon.net.nz> In-Reply-To: References: <5263DCF3.7070501@orcon.net.nz> Date: Tue, 22 Oct 2013 10:58:37 +1300 (NZDT) From: "Phil Sainty" User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-DSPAM-Check: by mx5.orcon.net.nz on Tue, 22 Oct 2013 10:58:37 +1300 X-DSPAM-Result: Innocent X-DSPAM-Processed: Tue Oct 22 10:58:37 2013 X-DSPAM-Confidence: 0.6168 X-DSPAM-Probability: 0.0000 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, default) X-Spam-Score: 0.00 () [Hold at 4.00] X-CanIt-Geo: No geolocation information available for 172.16.100.200 X-CanItPRO-Stream: base:default X-Canit-Stats-ID: 06KDW52x9 - 2a1779e0634b - 20131022 X-Scanned-By: CanIt (www . roaringpenguin . com) on 172.16.100.174 X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) >> I prefer the way you're going, > > Just to clarify, in case there was some confusion: I'm not actually > working on any of that. I'm just giving guidance for someone who > wants to write a patch. That comment may have been directed at me (and I do indeed intend to provide a patch). I need to rework some code to make the major mode variable detection more generally-available, as my existing solution to avoid applying a major mode local variable depends on hack-local-variables being called, but that doesn't happen in all cases. I think it's looking promising, though. -Phil From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 14:52:52 2016 Received: (at control) by debbugs.gnu.org; 30 Apr 2016 18:52:52 +0000 Received: from localhost ([127.0.0.1]:58397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awa0a-0003it-9N for submit@debbugs.gnu.org; Sat, 30 Apr 2016 14:52:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awa0Z-0003ic-33 for control@debbugs.gnu.org; Sat, 30 Apr 2016 14:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awa0K-0003qB-PR for control@debbugs.gnu.org; Sat, 30 Apr 2016 14:52:42 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awa0K-0003pK-Lq for control@debbugs.gnu.org; Sat, 30 Apr 2016 14:52:36 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1awa0G-00060x-1u for control@debbugs.gnu.org; Sat, 30 Apr 2016 14:52:32 -0400 Subject: control message for bug 23407 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Sat, 30 Apr 2016 14:52:32 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) merge 15577 23407 From unknown Sun Jun 15 08:41:39 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode References: Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 May 2016 11:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 15577-done@debbugs.gnu.org Cc: yary Received: via spool by 15577-done@debbugs.gnu.org id=D15577.146244760918531 (code D ref 15577); Thu, 05 May 2016 11:27:02 +0000 Received: (at 15577-done) by debbugs.gnu.org; 5 May 2016 11:26:49 +0000 Received: from localhost ([127.0.0.1]:38766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHQf-0004op-7Z for submit@debbugs.gnu.org; Thu, 05 May 2016 07:26:49 -0400 Received: from mail.muc.de ([193.149.48.3]:27004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHQd-0004oh-HF for 15577-done@debbugs.gnu.org; Thu, 05 May 2016 07:26:47 -0400 Received: (qmail 72791 invoked by uid 3782); 5 May 2016 11:26:46 -0000 Date: 5 May 2016 11:26:46 -0000 Message-ID: <20160505112646.72790.qmail@mail.muc.de> From: Alan Mackenzie Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.3-RELEASE (amd64)) X-Spam-Score: -2.1 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Bug fixed in the master branch of GNU's savannah Emacs repository. -- Alan Mackenzie (Nuremberg, Germany).