fix(lib): file!: lower current-load-list priority

Also changes it to consider base buffer's filename (for `eval`
contexts).
This commit is contained in:
Henrik Lissner
2024-09-11 14:12:04 -04:00
parent f8f2b28580
commit 4ca5819532

View File

@ -312,14 +312,13 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
(defmacro file! () (defmacro file! ()
"Return the file of the file this macro was called." "Return the file of the file this macro was called."
(or (or (bound-and-true-p byte-compile-current-file)
;; REVIEW: Use `macroexp-file-name' once 27 support is dropped. load-file-name
(let ((file (car (last current-load-list)))) (buffer-file-name (buffer-base-buffer)) ; for `eval'
(if (stringp file) file)) ;; REVIEW: Use `macroexp-file-name' once 27 support is dropped.
(bound-and-true-p byte-compile-current-file) (let ((file (car (last current-load-list))))
load-file-name (if (stringp file) file))
buffer-file-name ; for `eval' (error "file!: cannot deduce the current file path")))
(error "file!: cannot deduce the current file path")))
(defmacro dir! () (defmacro dir! ()
"Return the directory of the file in which this macro was called." "Return the directory of the file in which this macro was called."