summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-02-24 17:16:00 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2021-02-24 17:16:00 -0500
commitb7f67d432ba9d4a3247fa9553093ab1db82e00fe (patch)
tree6c41d9a786c39b032e34688c3500731fda28d0d9 /lisp/emacs-lisp
parent46b54e5bb42f26a57f6cdbedf83bd80c6c717a4f (diff)
downloademacs-b7f67d432ba9d4a3247fa9553093ab1db82e00fe.tar.gz
emacs-b7f67d432ba9d4a3247fa9553093ab1db82e00fe.tar.bz2
emacs-b7f67d432ba9d4a3247fa9553093ab1db82e00fe.zip
* lisp/emacs-lisp/macroexp.el (macroexp-file-name): Work in `eval-buffer`
Rely on `current-load-list` instead of `load-file-name`. * lisp/emacs-lisp/bytecomp.el (byte-compile-close-variables): Change the var we override accordingly.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/emacs-lisp/macroexp.el6
2 files changed, 6 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 26fab31b961..7aae8c0c6a4 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1731,7 +1731,7 @@ It is too wide if it has any lines longer than the largest of
;; This is used in `macroexp-file-name' to make sure that
;; loading file A which does (byte-compile-file B) won't
;; cause macro calls in B to think they come from A.
- (load-file-name nil)
+ (current-load-list (list nil))
)
,@body))
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index a6b0985e6c7..d52aee5a4ad 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -127,7 +127,11 @@ A non-nil result is expected to be reliable when called from a macro in order
to find the file in which the macro's call was found, and it should be
reliable as well when used at the top-level of a file.
Other uses risk returning non-nil value that point to the wrong file."
- (or load-file-name (bound-and-true-p byte-compile-current-file)))
+ ;; `eval-buffer' binds `current-load-list' but not `load-file-name',
+ ;; so prefer using it over using `load-file-name'.
+ (let ((file (car (last current-load-list))))
+ (or (if (stringp file) file)
+ (bound-and-true-p byte-compile-current-file))))
(defvar macroexp--warned (make-hash-table :test #'equal :weakness 'key))