From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen 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 20:59:55 +0200 Message-ID: <874l27btck.fsf@gnus.org> References: <87d0hufamm.fsf@gmail.com> <87ftlsfp3v.fsf@gnus.org> <87h8688233.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="88964"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36830@debbugs.gnu.org To: Gustavo Barros Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 23 21:26:39 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 1i1FCo-000N36-OT for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 21:26:38 +0200 Original-Received: from localhost ([::1]:33372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1FCn-0002rV-4y for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 15:26:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44565) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1Eo3-0002JX-NI for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 15:01:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1Eo2-0007yV-Aq for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 15:01:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1Eo2-0007yO-7g for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 15:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1Eo2-0006BV-4e for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 15:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Aug 2019 19:01: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.156658680423632 (code B ref 36830); Fri, 23 Aug 2019 19:01:02 +0000 Original-Received: (at 36830) by debbugs.gnu.org; 23 Aug 2019 19:00:04 +0000 Original-Received: from localhost ([127.0.0.1]:41196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1En4-00068o-Vb for submit@debbugs.gnu.org; Fri, 23 Aug 2019 15:00:03 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:51104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1En2-000688-3L for 36830@debbugs.gnu.org; Fri, 23 Aug 2019 15:00:01 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1Emx-0001cj-TC; Fri, 23 Aug 2019 20:59:58 +0200 In-Reply-To: <87h8688233.fsf@gmail.com> (Gustavo Barros's message of "Fri, 23 Aug 2019 10:04:48 -0300") 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:165719 Archived-At: Gustavo Barros writes: > Sure. The file from which I reported, and which I include here now, was > just a dummy file with the variable of interest set to true with > `add-file-local-variable`: Thanks; I'm able to reproduce the bug in Emacs 27, too. I'm not sure what the fix is, though. Here's how it's set: (defun find-file-noselect-1 (buf filename nowarn rawfile truename number) [...] (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? diff --git a/lisp/files.el b/lisp/files.el index f76635017d..bde8a466d0 100644 --- 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)))) (current-buffer)))) (defun insert-file-contents-literally (filename &optional visit beg end replace) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no