diff options
author | Andrea Corallo <akrl@sdf.org> | 2021-02-26 19:54:59 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2021-02-26 19:54:59 +0100 |
commit | 5c922cc3a4b0677805a678267df2b7598e92bb83 (patch) | |
tree | f7680e085436621332230c7a46df36ad4048310b /lisp/emacs-lisp/macroexp.el | |
parent | cedc55041ea5179dcb389845d2d0e3562060cab9 (diff) | |
parent | 496fa1c03b1b3ce4aa9872751e9fac45167766c2 (diff) | |
download | emacs-5c922cc3a4b0677805a678267df2b7598e92bb83.tar.gz emacs-5c922cc3a4b0677805a678267df2b7598e92bb83.tar.bz2 emacs-5c922cc3a4b0677805a678267df2b7598e92bb83.zip |
Merge remote-tracking branch 'savannah/master' into native-comp
Diffstat (limited to 'lisp/emacs-lisp/macroexp.el')
-rw-r--r-- | lisp/emacs-lisp/macroexp.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 0934e43e66a..d52aee5a4ad 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -112,7 +112,7 @@ and also to avoid outputting the warning during normal execution." (funcall (eval (cadr form))) (byte-compile-constant nil))) -(defun macroexp--compiling-p () +(defun macroexp-compiling-p () "Return non-nil if we're macroexpanding for the compiler." ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this ;; macro-expansion will be processed by the byte-compiler, we check @@ -120,13 +120,26 @@ and also to avoid outputting the warning during normal execution." (member '(declare-function . byte-compile-macroexpand-declare-function) macroexpand-all-environment)) +(defun macroexp-file-name () + "Return the name of the file from which the code comes. +Returns nil when we do not know. +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." + ;; `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)) (defun macroexp--warn-and-return (msg form &optional compile-only) (let ((when-compiled (lambda () (byte-compile-warn "%s" msg)))) (cond ((null msg) form) - ((macroexp--compiling-p) + ((macroexp-compiling-p) (if (and (consp form) (gethash form macroexp--warned)) ;; Already wrapped this exp with a warning: avoid inf-looping ;; where we keep adding the same warning onto `form' because |