From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23407: .dir-local settings get obliterated on running a major mode function. Date: Mon, 2 May 2016 07:10:15 +0000 Message-ID: <20160502071015.GA2048@acm.fritz.box> References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1462174841 26118 80.91.229.3 (2 May 2016 07:40:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 May 2016 07:40:41 +0000 (UTC) Cc: yary , 23407@debbugs.gnu.org, Dmitry Gutov To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 02 09:40:30 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ax8T0-0000S7-Gm for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 May 2016 09:40:30 +0200 Original-Received: from localhost ([::1]:35585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ax8Sw-0001Zm-P1 for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 May 2016 03:40:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ax8Sn-0001LR-JH for bug-gnu-emacs@gnu.org; Mon, 02 May 2016 03:40:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ax8Sb-0004nQ-RO for bug-gnu-emacs@gnu.org; Mon, 02 May 2016 03:40:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ax8Sb-0004mN-O8 for bug-gnu-emacs@gnu.org; Mon, 02 May 2016 03:40:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ax8SY-0005F7-76 for bug-gnu-emacs@gnu.org; Mon, 02 May 2016 03:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 May 2016 07:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23407 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23407-submit@debbugs.gnu.org id=B23407.146217476420055 (code B ref 23407); Mon, 02 May 2016 07:40:02 +0000 Original-Received: (at 23407) by debbugs.gnu.org; 2 May 2016 07:39:24 +0000 Original-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 Original-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 Original-Received: (qmail 27879 invoked by uid 3782); 2 May 2016 07:39:19 -0000 Original-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 Original-Received: (qmail 3463 invoked by uid 1000); 2 May 2016 07:10:15 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:117556 Archived-At: 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).