From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#23407: .dir-local settings get obliterated on running a major mode function. Date: Tue, 03 May 2016 14:10:45 -0400 Message-ID: References: <20160430102744.GA4644@acm.fritz.box> <0joa8rszhb.fsf@fencepost.gnu.org> <20160501212846.GA4228@acm.fritz.box> <20160502071015.GA2048@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1462299102 31723 80.91.229.3 (3 May 2016 18:11:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 May 2016 18:11:42 +0000 (UTC) Cc: yary , 23407@debbugs.gnu.org, Dmitry Gutov To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 03 20:11:31 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 1axenD-00077O-Ah for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 20:11:31 +0200 Original-Received: from localhost ([::1]:42659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axen9-0007fI-7r for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 14:11:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axemz-0007Sr-LV for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 14:11:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axemn-0006QN-SE for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 14:11:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axemn-0006Nz-Oq for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 14:11:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1axemk-0002dR-DL for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 14:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 May 2016 18:11: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.146229905110109 (code B ref 23407); Tue, 03 May 2016 18:11:02 +0000 Original-Received: (at 23407) by debbugs.gnu.org; 3 May 2016 18:10:51 +0000 Original-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 Original-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 Original-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 Original-Received: by pastel.home (Postfix, from userid 20848) id E5CE760139; Tue, 3 May 2016 14:10:45 -0400 (EDT) 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) 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-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:117671 Archived-At: >> > + ;; 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