diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index 54e473f46..4975e9b11 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -243,19 +243,16 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." ;; ;;; Sugars -(defun dir! () - "Returns the directory of the emacs lisp file this function is called from." - (when-let (path (file!)) - (directory-file-name (file-name-directory path)))) +(defmacro file! () + "Return the file of the file this macro was called." + (or (macroexp-file-name) + load-file-name + buffer-file-name ; for `eval' + (error "file!: cannot deduce the current file path"))) -(defun file! () - "Return the emacs lisp file this function is called from." - (cond (load-in-progress load-file-name) - ((bound-and-true-p byte-compile-current-file)) - ((stringp (car-safe current-load-list)) - (car current-load-list)) - (buffer-file-name) - ((error "Cannot get this file-path")))) +(defmacro dir! () + "Return the directory of the file this macro was called." + (file-name-directory (macroexpand '(file!)))) ;; REVIEW Should I deprecate this? The macro's name is so long... (defalias 'letenv! 'with-environment-variables)