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: Thu, 5 May 2016 11:39:25 +0000 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1462448442 25593 80.91.229.3 (5 May 2016 11:40:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 May 2016 11:40:42 +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 Thu May 05 13: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 1ayHdt-0001hG-Hr for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 May 2016 13:40:29 +0200 Original-Received: from localhost ([::1]:53231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayHdp-0004XZ-Nl for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 May 2016 07:40:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayHdg-0004IQ-VP for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 07:40:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayHdV-0000xI-2e for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 07:40:11 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayHdU-0000wR-Vs for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 07:40:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ayHdR-0006ln-IJ for bug-gnu-emacs@gnu.org; Thu, 05 May 2016 07:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 May 2016 11:40:01 +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.146244836925979 (code B ref 23407); Thu, 05 May 2016 11:40:01 +0000 Original-Received: (at 23407) by debbugs.gnu.org; 5 May 2016 11:39:29 +0000 Original-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 Original-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 Original-Received: (qmail 74824 invoked by uid 3782); 5 May 2016 11:39:27 -0000 Original-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 Original-Received: (qmail 13206 invoked by uid 1000); 5 May 2016 11:39:25 -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:117839 Archived-At: 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).