GNU bug report logs -
#36830
26.2; find-file-visit-truename is not honored as file local variable
Previous Next
Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>
Date: Sun, 28 Jul 2019 15:22:01 UTC
Severity: normal
Found in version 26.2
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Gustavo Barros <gusbrs.2016 <at> 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
This bug report was last modified 5 years and 301 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.