From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#36830: 26.2; find-file-visit-truename is not honored as file local variable Date: Fri, 23 Aug 2019 23:07:51 +0300 Message-ID: <83d0gvk5m0.fsf@gnu.org> References: <87d0hufamm.fsf@gmail.com> <87ftlsfp3v.fsf@gnus.org> <87h8688233.fsf@gmail.com> <874l27btck.fsf@gnus.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="260896"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36830@debbugs.gnu.org, gusbrs.2016@gmail.com To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 23 22:08:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1Fr0-0015ki-Ql for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 22:08:10 +0200 Original-Received: from localhost ([::1]:33946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1Fqz-0004c7-LS for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 16:08:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53993) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1Fqt-0004bn-Pc for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 16:08:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1Fqs-0000LF-P9 for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 16:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1Fqs-0000L5-Li for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 16:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1Fqs-00087V-EY for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 16:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Aug 2019 20:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36830 X-GNU-PR-Package: emacs Original-Received: via spool by 36830-submit@debbugs.gnu.org id=B36830.156659086931186 (code B ref 36830); Fri, 23 Aug 2019 20:08:02 +0000 Original-Received: (at 36830) by debbugs.gnu.org; 23 Aug 2019 20:07:49 +0000 Original-Received: from localhost ([127.0.0.1]:41243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1Fqf-00086w-3l for submit@debbugs.gnu.org; Fri, 23 Aug 2019 16:07:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45469) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1Fqd-00086g-3e for 36830@debbugs.gnu.org; Fri, 23 Aug 2019 16:07:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i1FqY-00006u-0i; Fri, 23 Aug 2019 16:07:42 -0400 Original-Received: from [176.228.60.248] (port=4106 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i1FqX-00046j-GX; Fri, 23 Aug 2019 16:07:41 -0400 In-reply-to: <874l27btck.fsf@gnus.org> (message from Lars Ingebrigtsen on Fri, 23 Aug 2019 20:59:55 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: 209.51.188.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:165725 Archived-At: > From: Lars Ingebrigtsen > Date: Fri, 23 Aug 2019 20:59:55 +0200 > Cc: 36830@debbugs.gnu.org > > (if find-file-visit-truename > (setq buffer-file-name (expand-file-name buffer-file-truename))) > > [...] > > (after-find-file error (not nowarn))) > > `after-find-file' is the function that interprets the file local > variables, so we're setting the buffer file name before we've set that > variable locally. > > One option would be to re-check the variable after `after-find-file', > but that seems a bit hacky. > > Any opinions? I don't think this variable was designed to be set from file-local variables block. Visiting a file and naming its buffer are two racy actions, and where there's a race there will be chicken-and-egg type of problems. > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -2413,7 +2413,11 @@ find-file-noselect-1 > (setq buffer-file-coding-system 'no-conversion) > (set-buffer-major-mode buf) > (setq-local find-file-literally t)) > - (after-find-file error (not nowarn))) > + (after-find-file error (not nowarn)) > + ;; In case `find-file-visit-truename' is set as a file-local > + ;; variable, recompute the buffer file name. > + (when find-file-visit-truename > + (setq buffer-file-name (expand-file-name buffer-file-truename)))) I expect such renaming to cause future bugs, FWIW. Or maybe not, but this is beyond hacky, IMO. Maybe we should just document that this variable cannot be file-local.