From unknown Mon Jun 16 23:47:40 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23407 <23407@debbugs.gnu.org> To: bug#23407 <23407@debbugs.gnu.org> Subject: Status: .dir-local settings get obliterated on running a major mode function. Reply-To: bug#23407 <23407@debbugs.gnu.org> Date: Tue, 17 Jun 2025 06:47:40 +0000 retitle 23407 .dir-local settings get obliterated on running a major mode f= unction. reassign 23407 emacs submitter 23407 Alan Mackenzie severity 23407 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 06:28:41 2016 Received: (at submit) by debbugs.gnu.org; 30 Apr 2016 10:28:41 +0000 Received: from localhost ([127.0.0.1]:56394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awS8f-0007kd-KX for submit@debbugs.gnu.org; Sat, 30 Apr 2016 06:28:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awS8e-0007kO-3F for submit@debbugs.gnu.org; Sat, 30 Apr 2016 06:28:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awS8O-000833-VX for submit@debbugs.gnu.org; Sat, 30 Apr 2016 06:28:31 -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 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awS8O-00081z-TX for submit@debbugs.gnu.org; Sat, 30 Apr 2016 06:28:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awS8D-0002zl-7N for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2016 06:28:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awS7x-0007uW-Fl for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2016 06:28:05 -0400 Received: from mail.muc.de ([193.149.48.3]:40318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awS7x-0007rT-6f for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2016 06:27:57 -0400 Received: (qmail 41797 invoked by uid 3782); 30 Apr 2016 10:27:46 -0000 Received: from acm.muc.de (p5B146848.dip0.t-ipconnect.de [91.20.104.72]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 30 Apr 2016 12:27:45 +0200 Received: (qmail 4700 invoked by uid 1000); 30 Apr 2016 10:27:44 -0000 Date: Sat, 30 Apr 2016 10:27:44 +0000 To: bug-gnu-emacs@gnu.org Subject: .dir-local settings get obliterated on running a major mode function. Message-ID: <20160430102744.GA4644@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-Debbugs-Envelope-To: submit 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: -4.4 (----) Hello, Emacs. In the master branch (I'm sure it's the same in the emacs-25 branch, too): 1. start Emacs with emacs -Q 2. Visit any emacs lisp file which is part of Emacs with C-x C-f. 3. Do C-h C-v indent-tabs-mode . The *Help* buffer starts off with: indent-tabs-mode is a variable defined in `C source code'. Its value is nil Original value was t Local in buffer follow.el; global value is t . The local value comes from the .dir-locals in the top level Emacs directory. 4. Do M-x emacs-lisp-mode. 5. Again do C-h C-v indent-tabs-mode . This time, the *Help* buffer starts off with: indent-tabs-mode is a variable defined in `C source code'. Its value is t . This is different from the first *Help* buffer. 6. This is a bug. On running a major mode, directory local settings should be respected. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 06:53:43 2016 Received: (at 23407) by debbugs.gnu.org; 30 Apr 2016 10:53:43 +0000 Received: from localhost ([127.0.0.1]:56403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awSWs-0008Kx-W2 for submit@debbugs.gnu.org; Sat, 30 Apr 2016 06:53:43 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awSWr-0008Kl-HC for 23407@debbugs.gnu.org; Sat, 30 Apr 2016 06:53:41 -0400 Received: by mail-wm0-f65.google.com with SMTP id r12so9761272wme.0 for <23407@debbugs.gnu.org>; Sat, 30 Apr 2016 03:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=hQMDD4tjVnvnd70u/QKm4zDzy5yiiKFRHY2siTMA8t8=; b=bxZOaBelPNj24eBXe7lfK2UWkOCalgfDEGZwxTVgJPuH7HMeTcqzyGAmQc/KVaAxLj MCMF/PnYPFBjO5mFZAHG3yW5lEGihiWPe4FN3y+Hgijw415f5CW+JUIT34t/uIjemjrz gMVN/Yzeg8eAzTWjixzO1scIOtqNlWzuZczxMQDO1IbkRGV0Yy2KvqefqGcUrKwdMoGI ZfGT6AMvNtLfmfM/EKW/BJzCJgdYdF8YcZjLBKfu/k0cEKuvDIVY3bjZzb4BNJ8Uh0TE FXMyProiN25FjP0M9M+WLxJulczqclNvSsTLdYd6ajo8ZsAh15NMFlNHCnw3mw5RW4/S V+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=hQMDD4tjVnvnd70u/QKm4zDzy5yiiKFRHY2siTMA8t8=; b=bOlHEWMt4Lli0qkdlytt3FlOVzj3DY0BYslSJpcQeDJCsQSkcAg4mAdop/+RG9oEYR xKq+4LL2+3Q8w2gB4K3M4gceYX3TpRl21Q1MZQYruMEZ6i98p1YZbdbdtRb1Uro7G60s lt5M911Fi/D3E5pg6bvw7m++M5M/nvS7YnzKsQgyWIqCOkIaaIKLdMUTFprr6uknxcvE lzryaKpiwMZDIcE4BJumil4mH3UunHiL5gj4sQ9blcU/4ewymnCY7ELmbUad5RceVCNL LTYFB6oqJAxhfUonGK5NSfrGgVUJyR91NAZWcNiR8FqTSXsABnmlYoqIcz009mCNdX+u tBRw== X-Gm-Message-State: AOPr4FXCyi+WFz0W4rxFlOHyHfetNVfCX30IG5HP/Pu4xg574YUYyvqJ3Nkfyhxe7c16Lg== X-Received: by 10.194.248.135 with SMTP id ym7mr26757815wjc.174.1462013615906; Sat, 30 Apr 2016 03:53:35 -0700 (PDT) Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id jd4sm18770187wjb.43.2016.04.30.03.53.34 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 30 Apr 2016 03:53:35 -0700 (PDT) Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. To: Alan Mackenzie , 23407@debbugs.gnu.org References: <20160430102744.GA4644@acm.fritz.box> From: Dmitry Gutov Message-ID: <439e6745-a762-e6b7-b7f0-690ba2a5eda2@yandex.ru> Date: Sat, 30 Apr 2016 13:53:33 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1 MIME-Version: 1.0 In-Reply-To: <20160430102744.GA4644@acm.fritz.box> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 23407 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: -0.5 (/) On 04/30/2016 01:27 PM, Alan Mackenzie wrote: > 4. Do M-x emacs-lisp-mode. > 5. Again do C-h C-v indent-tabs-mode . This time, the *Help* > buffer starts off with: > > indent-tabs-mode is a variable defined in `C source code'. > Its value is t > > . This is different from the first *Help* buffer. I can see this too, in emacs-25. From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 14:50:44 2016 Received: (at 23407) by debbugs.gnu.org; 30 Apr 2016 18:50:45 +0000 Received: from localhost ([127.0.0.1]:58389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awZyW-0003fL-Oc for submit@debbugs.gnu.org; Sat, 30 Apr 2016 14:50:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awZyU-0003f5-Sk for 23407@debbugs.gnu.org; Sat, 30 Apr 2016 14:50:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awZyG-00037t-8t for 23407@debbugs.gnu.org; Sat, 30 Apr 2016 14:50:34 -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]:34598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awZy3-00032t-CH; Sat, 30 Apr 2016 14:50:15 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1awZxw-0005hz-AZ; Sat, 30 Apr 2016 14:50:08 -0400 From: Glenn Morris To: Alan Mackenzie Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. References: <20160430102744.GA4644@acm.fritz.box> X-Spook: Plague Drug Enforcement Agency cryptographic Emergency X-Ran: niy6:p-)uqFUr\j!g0^Lxwd`7(>~TLueBG3zfr/l67Wm`YzjWQ (Alan Mackenzie's message of "Sat, 30 Apr 2016 10:27:44 +0000") Message-ID: <0joa8rszhb.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain 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: 23407 Cc: 23407@debbugs.gnu.org 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 (------) It's the same with file-local variables, and it always has been. I don't think this is a bug. 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 debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 14:53:39 2016 Received: (at 23407) by debbugs.gnu.org; 30 Apr 2016 18:53:40 +0000 Received: from localhost ([127.0.0.1]:58401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awa1L-0003kn-HS for submit@debbugs.gnu.org; Sat, 30 Apr 2016 14:53:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56261) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awa1K-0003kX-0P for 23407@debbugs.gnu.org; Sat, 30 Apr 2016 14:53:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awa15-00043w-SP for 23407@debbugs.gnu.org; Sat, 30 Apr 2016 14:53:29 -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]:34638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awa0v-000408-PG; Sat, 30 Apr 2016 14:53:13 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1awa0p-00064J-RX; Sat, 30 Apr 2016 14:53:07 -0400 From: Glenn Morris To: Alan Mackenzie Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> X-Spook: counter terrorism Pandemic Disaster assistance Los Zetas X-Ran: +~SW[5XqKyDSAH[=QPt`mX)KMIv"Lc{Faz>C:N2cwlfzW.K%oLVt,;eE.BU4R)I`i?|@/S X-Hue: white X-Debbugs-No-Ack: yes X-Attribution: GM Date: Sat, 30 Apr 2016 14:53:07 -0400 In-Reply-To: <0joa8rszhb.fsf@fencepost.gnu.org> (Glenn Morris's message of "Sat, 30 Apr 2016 14:50:08 -0400") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain 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: 23407 Cc: 23407@debbugs.gnu.org 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 (------) PS dupe of http://debbugs.gnu.org/15577 From debbugs-submit-bounces@debbugs.gnu.org Sun May 01 17:28:52 2016 Received: (at 23407) by debbugs.gnu.org; 1 May 2016 21:28:52 +0000 Received: from localhost ([127.0.0.1]:32881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awyv6-0003rw-DL for submit@debbugs.gnu.org; Sun, 01 May 2016 17:28:52 -0400 Received: from mail.muc.de ([193.149.48.3]:60451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awyv3-0003rn-Uc for 23407@debbugs.gnu.org; Sun, 01 May 2016 17:28:50 -0400 Received: (qmail 60318 invoked by uid 3782); 1 May 2016 21:28:48 -0000 Received: from acm.muc.de (p579E946C.dip0.t-ipconnect.de [87.158.148.108]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 01 May 2016 23:28:46 +0200 Received: (qmail 2291 invoked by uid 1000); 1 May 2016 21:28:46 -0000 Date: Sun, 1 May 2016 21:28:46 +0000 To: Glenn Morris Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: <20160501212846.GA4228@acm.fritz.box> References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 23407 Cc: yary , 23407@debbugs.gnu.org, Stefan Monnier , Dmitry Gutov 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: -1.0 (-) Hello, Glenn. On Sat, Apr 30, 2016 at 02:53:07PM -0400, Glenn Morris wrote: > PS dupe of http://debbugs.gnu.org/15577 More fully known as: Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode Date: Wed, 9 Oct 2013 16:14:00 -0400 From: yary Thanks for the reference. I'd actually searched debbugs for ".dir-locals" and found nothing. Anyhow, I've hacked a patch together. The idea is to call `hack-local-variables' from `run-mode-hooks' rather than from `normal-mode'. Of course, it's never quite that simple. The main thing is that the local variables are now set with the major mode rather than with the visiting of the file. So file/directory local variables are now not lost on setting the major mode. The following patch is based on the master branch from earlier on today. diff --git a/lisp/files.el b/lisp/files.el index 132ebce..940a9ac 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2322,8 +2322,13 @@ normal-mode ;; s-a-m and h-l-v may parse the same regions, looking for "mode:". (with-demoted-errors "File mode specification error: %s" (set-auto-mode)) - (with-demoted-errors "File local-variables error: %s" - (hack-local-variables))) + ;; delay-mode-hooks is set when `byte-compile-file' is the caller. + ;; It is essential that we call `hack-local-variables' in order to + ;; set up `lexical-binding', since `run-mode-hooks' is prevented + ;; from doing its job. + (when delay-mode-hooks + (with-demoted-errors "File local-variables error: %s" + (hack-local-variables 'no-mode)))) ;; 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 @@ -3297,11 +3302,15 @@ hack-local-variables-filter ;; TODO? Warn once per file rather than once per session? (defvar hack-local-variables--warned-lexical nil) -(defun hack-local-variables (&optional mode-only) +(defun hack-local-variables (&optional handle-mode) "Parse and put into effect this buffer's local variables spec. Uses `hack-local-variables-apply' to apply the variables. -If MODE-ONLY is non-nil, all we do is check whether a \"mode:\" +If HANDLE-MODE is nil, we apply all the specified local +variables. If HANDLE-MODE is neither nil nor t, we do the same, +except that any settings of `mode' are ignored. + +If HANDLE-MODE is t, all we do is check whether a \"mode:\" is specified, and return the corresponding mode symbol, or nil. In this case, we try to ignore minor-modes, and only return a major-mode. @@ -3319,7 +3328,7 @@ hack-local-variables (let ((enable-local-variables (and local-enable-local-variables enable-local-variables)) result) - (unless mode-only + (unless (eq handle-mode t) (setq file-local-variables-alist nil) (with-demoted-errors "Directory-local variables error: %s" ;; Note this is a no-op if enable-local-variables is nil. @@ -3327,18 +3336,19 @@ hack-local-variables ;; This entire function is basically a no-op if enable-local-variables ;; is nil. All it does is set file-local-variables-alist to nil. (when enable-local-variables - ;; This part used to ignore enable-local-variables when mode-only - ;; was non-nil. That was inappropriate, eg consider the + ;; This part used to ignore enable-local-variables when handle-mode + ;; was t. That was inappropriate, eg consider the ;; (artificial) example of: ;; (setq local-enable-local-variables nil) ;; Open a file foo.txt that contains "mode: sh". ;; It correctly opens in text-mode. ;; M-x set-visited-file name foo.c, and it incorrectly stays in text-mode. (unless (or (inhibit-local-variables-p) - ;; If MODE-ONLY is non-nil, and the prop line specifies a + ;; If HANDLE-MODE is t, and the prop line specifies a ;; mode, then we're done, and have no need to scan further. - (and (setq result (hack-local-variables-prop-line mode-only)) - mode-only)) + (and (setq result (hack-local-variables-prop-line + (eq handle-mode t))) + (eq handle-mode t))) ;; Look for "Local variables:" line in last page. (save-excursion (goto-char (point-max)) @@ -3393,7 +3403,7 @@ hack-local-variables (goto-char (point-min)) (while (not (or (eobp) - (and mode-only result))) + (and (eq handle-mode t) result))) ;; Find the variable name; (unless (looking-at hack-local-variable-regexp) (error "Malformed local variable line: %S" @@ -3410,7 +3420,7 @@ hack-local-variables (forward-char 1) (let ((read-circle nil)) (setq val (read (current-buffer)))) - (if mode-only + (if (eq handle-mode t) (and (eq var 'mode) ;; Specifying minor-modes via mode: is ;; deprecated, but try to reject them anyway. @@ -3432,6 +3442,7 @@ hack-local-variables ;; to use 'thisbuf's name in the ;; warning message. (or (buffer-file-name thisbuf) "")))))) + ((and (eq var 'mode) handle-mode)) (t (ignore-errors (push (cons (if (eq var 'eval) @@ -3440,8 +3451,8 @@ hack-local-variables val) result)))))) (forward-line 1)))))))) ;; Now we've read all the local variables. - ;; If MODE-ONLY is non-nil, return whether the mode was specified. - (if mode-only result + ;; If HANDLE-MODE is t, return whether the mode was specified. + (if (eq handle-mode t) result ;; Otherwise, set the variables. (hack-local-variables-filter result nil) (hack-local-variables-apply))))) diff --git a/lisp/subr.el b/lisp/subr.el index 5f8d830..162ac21 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1732,10 +1732,14 @@ after-change-major-mode-hook (defun run-mode-hooks (&rest hooks) "Run mode hooks `delayed-mode-hooks' and HOOKS, or delay HOOKS. -If the variable `delay-mode-hooks' is non-nil, does not run any hooks, +Call `hack-local-variables' to set up file local and directory local +variables. + +If the variable `delay-mode-hooks' is non-nil, does not do anything, just adds the HOOKS to the list `delayed-mode-hooks'. Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', -`delayed-mode-hooks' (in reverse order), HOOKS, and finally +`delayed-mode-hooks' (in reverse order), HOOKS, then runs +`hack-local-variables' and finally runs the hook `after-change-major-mode-hook'. Major mode functions should use this instead of `run-hooks' when running their FOO-mode-hook." (if delay-mode-hooks @@ -1746,6 +1750,9 @@ run-mode-hooks (setq hooks (nconc (nreverse delayed-mode-hooks) hooks)) (setq delayed-mode-hooks nil) (apply 'run-hooks (cons 'change-major-mode-after-body-hook hooks)) + (if (buffer-file-name) + (with-demoted-errors "File local-variables error: %s" + (hack-local-variables 'no-mode))) (run-hooks 'after-change-major-mode-hook))) (defmacro delay-mode-hooks (&rest body) -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon May 02 00:02:20 2016 Received: (at 23407) by debbugs.gnu.org; 2 May 2016 04:02:20 +0000 Received: from localhost ([127.0.0.1]:32922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ax53r-0006dX-TX for submit@debbugs.gnu.org; Mon, 02 May 2016 00:02:20 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:3267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ax53p-0006dK-IN for 23407@debbugs.gnu.org; Mon, 02 May 2016 00:02:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CYDQA731xV/0uLxEVcgxCEAshgBAICgTw8EQEBAQEBAQGBCkEFg10BAQMBViMFCwsOJhIUGA0kiDcIzyMBAQEBBgEBAQEeizqFBQeELQEEkDSJOZlSgUUjgjuBWSKCeAEBAQ X-IPAS-Result: A0CYDQA731xV/0uLxEVcgxCEAshgBAICgTw8EQEBAQEBAQGBCkEFg10BAQMBViMFCwsOJhIUGA0kiDcIzyMBAQEBBgEBAQEeizqFBQeELQEEkDSJOZlSgUUjgjuBWSKCeAEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="221264334" Received: from 69-196-139-75.dsl.teksavvy.com (HELO pastel.home) ([69.196.139.75]) by ironport2-out.teksavvy.com with ESMTP; 02 May 2016 00:02:11 -0400 Received: by pastel.home (Postfix, from userid 20848) id B8F206037C; Mon, 2 May 2016 00:02:11 -0400 (EDT) From: Stefan Monnier To: Alan Mackenzie Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> Date: Mon, 02 May 2016 00:02:11 -0400 In-Reply-To: <20160501212846.GA4228@acm.fritz.box> (Alan Mackenzie's message of "Sun, 1 May 2016 21:28:46 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 23407 Cc: yary , Glenn Morris , 23407@debbugs.gnu.org, Dmitry Gutov 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: 0.3 (/) > Anyhow, I've hacked a patch together. The idea is to call > `hack-local-variables' from `run-mode-hooks' rather than from > `normal-mode'. Good idea. > + ;; delay-mode-hooks is set when `byte-compile-file' is the caller. > + ;; It is essential that we call `hack-local-variables' in order to > + ;; set up `lexical-binding', since `run-mode-hooks' is prevented > + ;; from doing its job. > + (when delay-mode-hooks > + (with-demoted-errors "File local-variables error: %s" > + (hack-local-variables 'no-mode)))) But this seems terribly brittle. Do we care about delay-mode-hooks (as the code says) or about byte-compile-file (as the comment says)? If it's the former, then the comment needs to be fixed, if it's the latter, than we need to find some other way to tell this code what's going on. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon May 02 03:39:24 2016 Received: (at 23407) by debbugs.gnu.org; 2 May 2016 07:39:24 +0000 Received: from localhost ([127.0.0.1]:32984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ax8Rw-0005DN-Cc for submit@debbugs.gnu.org; Mon, 02 May 2016 03:39:24 -0400 Received: from mail.muc.de ([193.149.48.3]:42004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ax8Rt-0005DE-TZ for 23407@debbugs.gnu.org; Mon, 02 May 2016 03:39:23 -0400 Received: (qmail 27879 invoked by uid 3782); 2 May 2016 07:39:19 -0000 Received: from acm.muc.de (p548A435F.dip0.t-ipconnect.de [84.138.67.95]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 02 May 2016 09:39:18 +0200 Received: (qmail 3463 invoked by uid 1000); 2 May 2016 07:10:15 -0000 Date: Mon, 2 May 2016 07:10:15 +0000 To: Stefan Monnier Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: <20160502071015.GA2048@acm.fritz.box> References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 23407 Cc: yary , Glenn Morris , 23407@debbugs.gnu.org, Dmitry Gutov 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: -1.0 (-) Hello, Stefan. Thanks for looking at my patch. On Mon, May 02, 2016 at 12:02:11AM -0400, Stefan Monnier wrote: > > Anyhow, I've hacked a patch together. The idea is to call > > `hack-local-variables' from `run-mode-hooks' rather than from > > `normal-mode'. > Good idea. > > + ;; delay-mode-hooks is set when `byte-compile-file' is the caller. > > + ;; It is essential that we call `hack-local-variables' in order to > > + ;; set up `lexical-binding', since `run-mode-hooks' is prevented > > + ;; from doing its job. > > + (when delay-mode-hooks > > + (with-demoted-errors "File local-variables error: %s" > > + (hack-local-variables 'no-mode)))) > But this seems terribly brittle. Do we care about delay-mode-hooks (as > the code says) or about byte-compile-file (as the comment says)? This bit of code was necessitated by: ######################################################################### commit 3ba6b3a9c1e0565ee5f45f11a9c09702a24f8453 Author: Artur Malabarba Date: Sun Apr 12 03:23:35 2015 +0100 Speed up byte-compilation and autoload generation by avoiding mode-hooks This prevents emacs-lisp-mode-hook from being run everytime an autoload file is generated, which can account for a fraction of package installation time depending on the hooks the user has configured. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use * delay-mode-hooks. * lisp/emacs-lisp/autoload.el (autoload-find-file) (autoload-find-generated-file): Use delay-mode-hooks. ######################################################################### if hack-local-variables isn't run, lexical-binding (for example) doesn't get set up, and make bootstrap fails. > If it's the former, then the comment needs to be fixed, if it's the > latter, than we need to find some other way to tell this code what's > going on. I don't really understand the question. Sure, that bit of code is ugly. But the comment both motivates ("it's `byte-compile-file''s fault") and explains the problem (which is that `delay-mode-hooks' being set would prevent `run-mode-hook', and thus `hack-local-variable' from running). It is possible that other stuff might call `normal-mode' like this. What sort of changes do you advocate for the comment (or for the code)? > Stefan -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Tue May 03 14:10:51 2016 Received: (at 23407) by debbugs.gnu.org; 3 May 2016 18:10:51 +0000 Received: from localhost ([127.0.0.1]:35649 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axemZ-0002cz-3U for submit@debbugs.gnu.org; Tue, 03 May 2016 14:10:51 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:49510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axemX-0002cp-8i for 23407@debbugs.gnu.org; Tue, 03 May 2016 14:10:50 -0400 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u43IAjHH002084; Tue, 3 May 2016 14:10:46 -0400 Received: by pastel.home (Postfix, from userid 20848) id E5CE760139; Tue, 3 May 2016 14:10:45 -0400 (EDT) From: Stefan Monnier To: Alan Mackenzie Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> <20160502071015.GA2048@acm.fritz.box> Date: Tue, 03 May 2016 14:10:45 -0400 In-Reply-To: <20160502071015.GA2048@acm.fritz.box> (Alan Mackenzie's message of "Mon, 2 May 2016 07:10:15 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: ** X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 2.2 X-NAI-Spam-Rules: 4 Rules triggered GMAIL_UNAME_2_DOT=1, GMAIL_UNAME_2_DOT_W_NOFROM_SGMAIL=1, NOFROM_SGMAIL=0.2, RV5661=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5661> : inlines <4753> : streams <1629440> : uri <2202488> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 23407 Cc: yary , Glenn Morris , 23407@debbugs.gnu.org, Dmitry Gutov 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.3 (--) >> > + ;; delay-mode-hooks is set when `byte-compile-file' is the caller. >> > + ;; It is essential that we call `hack-local-variables' in order to >> > + ;; set up `lexical-binding', since `run-mode-hooks' is prevented >> > + ;; from doing its job. >> > + (when delay-mode-hooks >> > + (with-demoted-errors "File local-variables error: %s" >> > + (hack-local-variables 'no-mode)))) >> But this seems terribly brittle. Do we care about delay-mode-hooks (as >> the code says) or about byte-compile-file (as the comment says)? > This bit of code was necessitated by: > ######################################################################### > commit 3ba6b3a9c1e0565ee5f45f11a9c09702a24f8453 > Author: Artur Malabarba > Date: Sun Apr 12 03:23:35 2015 +0100 > > Speed up byte-compilation and autoload generation by avoiding mode-hooks > > This prevents emacs-lisp-mode-hook from being run everytime an > autoload file is generated, which can account for a fraction of > package installation time depending on the hooks the user has > configured. > > * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use > * delay-mode-hooks. > > * lisp/emacs-lisp/autoload.el (autoload-find-file) > (autoload-find-generated-file): Use delay-mode-hooks. > ######################################################################### Hmm... so you're working around someone else's hack! > if hack-local-variables isn't run, lexical-binding (for example) doesn't > get set up, and make bootstrap fails. Of course: hack-local-variables should be run unconditionally. >> If it's the former, then the comment needs to be fixed, if it's the >> latter, than we need to find some other way to tell this code what's >> going on. > I don't really understand the question. Sure, that bit of code is ugly. > But the comment both motivates ("it's `byte-compile-file''s fault") and > explains the problem (which is that `delay-mode-hooks' being set would > prevent `run-mode-hook', and thus `hack-local-variable' from running). > It is possible that other stuff might call `normal-mode' like this. > What sort of changes do you advocate for the comment (or for the code)? How 'bout doing (setq-local hack-local-variables--done t) in hack-local-variables, and then testing that instead of testing delay-mode-hooks? Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu May 05 07:24:16 2016 Received: (at 23407-done) by debbugs.gnu.org; 5 May 2016 11:24:16 +0000 Received: from localhost ([127.0.0.1]:38756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHOB-0004ko-SS for submit@debbugs.gnu.org; Thu, 05 May 2016 07:24:15 -0400 Received: from mail.muc.de ([193.149.48.3]:35361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHOB-0004kh-3F for 23407-done@debbugs.gnu.org; Thu, 05 May 2016 07:24:15 -0400 Received: (qmail 72419 invoked by uid 3782); 5 May 2016 11:24:13 -0000 Date: 5 May 2016 11:24:13 -0000 Message-ID: <20160505112413.72418.qmail@mail.muc.de> From: Alan Mackenzie To: 23407-done@debbugs.gnu.org Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. 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-Debbugs-Envelope-To: 23407-done Cc: Alan Mackenzie 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 savannah master branch. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu May 05 07:39:29 2016 Received: (at 23407) by debbugs.gnu.org; 5 May 2016 11:39:29 +0000 Received: from localhost ([127.0.0.1]:38776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHcv-0006kx-LZ for submit@debbugs.gnu.org; Thu, 05 May 2016 07:39:29 -0400 Received: from mail.muc.de ([193.149.48.3]:50990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayHcu-0006kp-8X for 23407@debbugs.gnu.org; Thu, 05 May 2016 07:39:28 -0400 Received: (qmail 74824 invoked by uid 3782); 5 May 2016 11:39:27 -0000 Received: from acm.muc.de (p548C62E6.dip0.t-ipconnect.de [84.140.98.230]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 05 May 2016 13:39:25 +0200 Received: (qmail 13206 invoked by uid 1000); 5 May 2016 11:39:25 -0000 Date: Thu, 5 May 2016 11:39:25 +0000 To: Stefan Monnier Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: <20160505113925.GB1950@acm.fritz.box> References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> <20160502071015.GA2048@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 23407 Cc: yary , Glenn Morris , 23407@debbugs.gnu.org, Dmitry Gutov 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 (--) Hello, Stefan. On Tue, May 03, 2016 at 02:10:45PM -0400, Stefan Monnier wrote: > >> > + ;; delay-mode-hooks is set when `byte-compile-file' is the caller. > >> > + ;; It is essential that we call `hack-local-variables' in order to > >> > + ;; set up `lexical-binding', since `run-mode-hooks' is prevented > >> > + ;; from doing its job. > >> > + (when delay-mode-hooks > >> > + (with-demoted-errors "File local-variables error: %s" > >> > + (hack-local-variables 'no-mode)))) > >> But this seems terribly brittle. Do we care about delay-mode-hooks (as > >> the code says) or about byte-compile-file (as the comment says)? [ .... ] > Hmm... so you're working around someone else's hack! Yes, so is life. > > if hack-local-variables isn't run, lexical-binding (for example) doesn't > > get set up, and make bootstrap fails. > Of course: hack-local-variables should be run unconditionally. > >> If it's the former, then the comment needs to be fixed, if it's the > >> latter, than we need to find some other way to tell this code what's > >> going on. > > I don't really understand the question. Sure, that bit of code is ugly. > > But the comment both motivates ("it's `byte-compile-file''s fault") and > > explains the problem (which is that `delay-mode-hooks' being set would > > prevent `run-mode-hook', and thus `hack-local-variable' from running). > > It is possible that other stuff might call `normal-mode' like this. > > What sort of changes do you advocate for the comment (or for the code)? > How 'bout doing > (setq-local hack-local-variables--done t) > in hack-local-variables, and then testing that instead of testing > delay-mode-hooks? That's even more horrible. What I've done is tidy up the comment (which now makes no reference to byte-compile-file) and committed the change. > Stefan -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu May 05 08:54:04 2016 Received: (at 23407) by debbugs.gnu.org; 5 May 2016 12:54:04 +0000 Received: from localhost ([127.0.0.1]:38846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayIn5-00006l-UU for submit@debbugs.gnu.org; Thu, 05 May 2016 08:54:04 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:44875) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayIn4-00006Y-6u for 23407@debbugs.gnu.org; Thu, 05 May 2016 08:54:02 -0400 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u45Cs0Rt025075; Thu, 5 May 2016 08:54:01 -0400 Received: by pastel.home (Postfix, from userid 20848) id B767960090; Thu, 5 May 2016 08:54:00 -0400 (EDT) From: Stefan Monnier To: Alan Mackenzie Subject: Re: bug#23407: .dir-local settings get obliterated on running a major mode function. Message-ID: References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> <20160502071015.GA2048@acm.fritz.box> <20160505113925.GB1950@acm.fritz.box> Date: Thu, 05 May 2016 08:54:00 -0400 In-Reply-To: <20160505113925.GB1950@acm.fritz.box> (Alan Mackenzie's message of "Thu, 5 May 2016 11:39:25 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5663=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5663> : inlines <4762> : streams <1630403> : uri <2203675> X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 23407 Cc: yary , Glenn Morris , 23407@debbugs.gnu.org, Dmitry Gutov 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: -3.4 (---) >> (setq-local hack-local-variables--done t) >> in hack-local-variables, and then testing that instead of testing >> delay-mode-hooks? > That's even more horrible. Huh? It makes it clear what's going on: the find-file part of the code wants to make sure that hack-local-variables is called, so hack-local-variables sets a var when it's called, and find-file checks it to know whether that's been done or not. It's reliable and contrary to the code you had, it doesn't need to care about packages unrelated to find-file nor to hack-local-variables, nor about variables which are similarly unrelated to find-file nor to hack-local-variables. Stefan From unknown Mon Jun 16 23:47:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 03 Jun 2016 11:24:03 +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