all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Gustavo Barros <gusbrs.2016@gmail.com>
Cc: 36830@debbugs.gnu.org
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	[thread overview]
Message-ID: <874l27btck.fsf@gnus.org> (raw)
In-Reply-To: <87h8688233.fsf@gmail.com> (Gustavo Barros's message of "Fri, 23 Aug 2019 10:04:48 -0300")

Gustavo Barros <gusbrs.2016@gmail.com> 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))))
 \f
 (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





  reply	other threads:[~2019-08-23 18:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 15:21 bug#36830: 26.2; find-file-visit-truename is not honored as file local variable Gustavo Barros
2019-08-23  5:05 ` Lars Ingebrigtsen
2019-08-23 13:04   ` Gustavo Barros
2019-08-23 18:59     ` Lars Ingebrigtsen [this message]
2019-08-23 20:07       ` Eli Zaretskii
2019-08-23 21:38         ` Gustavo Barros
2019-08-25  5:39         ` Lars Ingebrigtsen
2019-08-25  7:31           ` Eli Zaretskii
2019-10-14 21:38             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874l27btck.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=36830@debbugs.gnu.org \
    --cc=gusbrs.2016@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.