From 3c36a345d8f5af34a832f78fcd3df1a9b8fd0780 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 27 Jul 2019 17:00:12 +0200 Subject: [PATCH] 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. --- core/core-lib.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 09a762a3e..b962f489e 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -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."