Fix file! not returning filename in some cases

There are scenarios where load-file-name is set, but load-in-progress is
not. It is safe to assume the value of load-file-name is always what we
want.

Also: file! now throws an error if it can't find the directory.
Otherwise we have to deal with roundabout errors from other places that
expect file! to never fail.
This commit is contained in:
Henrik Lissner 2019-07-27 17:00:12 +02:00
parent 21a27b52d8
commit 3c36a345d8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -188,10 +188,11 @@ at the values with which this function was called."
(defun file! ()
"Return the emacs lisp file this macro is called from."
(cond ((bound-and-true-p byte-compile-current-file))
(load-in-progress load-file-name)
(load-file-name)
((stringp (car-safe current-load-list))
(car current-load-list))
(buffer-file-name)))
(buffer-file-name)
((error "Cannot get this file-path"))))
(defun dir! ()
"Returns the directory of the emacs lisp file this macro is called from."