bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36830: 26.2; find-file-visit-truename is not honored as file local v


From: Lars Ingebrigtsen
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

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))))
 
 (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 via email to

[Prev in Thread] Current Thread [Next in Thread]