From 8db8c851ad1568d61ed50a4d087e6de2b475cf5f Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 14 Apr 2020 19:58:41 +0100 Subject: [PATCH] Always set `load-true-file-name' where `load-file-name' is set too. Fix bug#40620. * lisp/cus-dep.el (custom-make-dependencies): Set load-true-file-name. * lisp/emacs-lisp/package.el (package-quickstart-refresh): Likewise. * lisp/international/mule.el (load-with-code-conversion): Likewise. * lisp/loadup.el (load-true-file-name): Likewise. --- lisp/cus-dep.el | 1 + lisp/emacs-lisp/autoload.el | 4 +++- lisp/emacs-lisp/package.el | 3 ++- lisp/international/mule.el | 5 +++-- lisp/loadup.el | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el index fd307a5c04e..e2c2ebe5f42 100644 --- a/lisp/cus-dep.el +++ b/lisp/cus-dep.el @@ -90,6 +90,7 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" (string-match "\\`\\(.*\\)\\.el\\'" file) (let ((name (or generated-autoload-load-name ; see bug#5277 (file-name-nondirectory (match-string 1 file)))) + (load-true-file-name file) (load-file-name file)) (if (save-excursion (re-search-forward diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 6180bee2aa7..d9a43c23299 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -167,7 +167,9 @@ expression, in which case we want to handle forms differently." define-inline cl-defun cl-defmacro cl-defgeneric cl-defstruct pcase-defmacro)) (macrop car) - (setq expand (let ((load-file-name file)) (macroexpand form))) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) (memq (car expand) '(progn prog1 defalias))) (make-autoload expand file 'expansion)) ;Recurse on the expansion. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 4312ab9ca9a..b33e4897a01 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -3965,7 +3965,8 @@ activations need to be changed, such as when `package-load-list' is modified." (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) (pfile (prin1-to-string file))) - (insert "(let ((load-file-name " pfile "))\n") + (insert "(let ((load-true-file-name " pfile ")\ +(load-file-name " pfile "))\n") (insert-file-contents file) ;; Fixup the special #$ reader form and throw away comments. (while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move) diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 72e8cad9d62..363df13dfe6 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -320,8 +320,9 @@ Return t if file exists." (when purify-flag (push (purecopy file) preloaded-file-list)) (unwind-protect - (let ((load-file-name fullname) - (set-auto-coding-for-load t) + (let ((load-true-file-name fullname) + (load-file-name fullname) + (set-auto-coding-for-load t) (inhibit-file-name-operation nil)) (with-current-buffer buffer ;; So that we don't get completely screwed if the diff --git a/lisp/loadup.el b/lisp/loadup.el index 3cc47bc91fa..7cf2cb01c33 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -566,6 +566,7 @@ lost after dumping"))) ;; Don't keep `load-file-name' set during the top-level session! ;; Otherwise, it breaks a lot of code which does things like ;; (or load-file-name byte-compile-current-file). +(setq load-true-file-name nil) (setq load-file-name nil) (eval top-level) -- 2.39.5