diff options
| author | Stefan Monnier | 2021-01-23 16:04:36 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2021-01-23 16:04:36 -0500 |
| commit | 1559cc445a306b61b2a47c710e049ea26fe5265d (patch) | |
| tree | 5791f5bb8af6d4c353c1b135a79ef849caefc01d | |
| parent | b7068be5c410c5592856aeebd7aa4d62b1dc68e5 (diff) | |
| download | emacs-1559cc445a306b61b2a47c710e049ea26fe5265d.tar.gz emacs-1559cc445a306b61b2a47c710e049ea26fe5265d.zip | |
Fix missing file&line info in "Unknown defun property" warnings
* lisp/emacs-lisp/byte-run.el (defmacro, defun): Use
`macroexp--warn-and-return` rather than `message`.
* lisp/emacs-lisp/macroexp.el: Fix `macroexp--compiling-p`.
(macroexp--warn-and-return): Don't try and detect repetition on forms
like `nil`.
(macroexp-macroexpand): Don't forget to bind `macroexpand-all-environment`.
| -rw-r--r-- | lisp/emacs-lisp/byte-run.el | 16 | ||||
| -rw-r--r-- | lisp/emacs-lisp/macroexp.el | 14 |
2 files changed, 19 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 0f8dd5a2842..88f362d24f0 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el | |||
| @@ -232,8 +232,11 @@ The return value is undefined. | |||
| 232 | #'(lambda (x) | 232 | #'(lambda (x) |
| 233 | (let ((f (cdr (assq (car x) macro-declarations-alist)))) | 233 | (let ((f (cdr (assq (car x) macro-declarations-alist)))) |
| 234 | (if f (apply (car f) name arglist (cdr x)) | 234 | (if f (apply (car f) name arglist (cdr x)) |
| 235 | (message "Warning: Unknown macro property %S in %S" | 235 | (macroexp--warn-and-return |
| 236 | (car x) name)))) | 236 | (format-message |
| 237 | "Unknown macro property %S in %S" | ||
| 238 | (car x) name) | ||
| 239 | nil)))) | ||
| 237 | decls))) | 240 | decls))) |
| 238 | ;; Refresh font-lock if this is a new macro, or it is an | 241 | ;; Refresh font-lock if this is a new macro, or it is an |
| 239 | ;; existing macro whose 'no-font-lock-keyword declaration | 242 | ;; existing macro whose 'no-font-lock-keyword declaration |
| @@ -301,9 +304,12 @@ The return value is undefined. | |||
| 301 | (cdr body) | 304 | (cdr body) |
| 302 | body))) | 305 | body))) |
| 303 | nil) | 306 | nil) |
| 304 | (t (message "Warning: Unknown defun property `%S' in %S" | 307 | (t |
| 305 | (car x) name))))) | 308 | (macroexp--warn-and-return |
| 306 | decls)) | 309 | (format-message "Unknown defun property `%S' in %S" |
| 310 | (car x) name) | ||
| 311 | nil))))) | ||
| 312 | decls)) | ||
| 307 | (def (list 'defalias | 313 | (def (list 'defalias |
| 308 | (list 'quote name) | 314 | (list 'quote name) |
| 309 | (list 'function | 315 | (list 'function |
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 37844977f8f..aa49bccc8d0 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el | |||
| @@ -127,7 +127,7 @@ and also to avoid outputting the warning during normal execution." | |||
| 127 | (cond | 127 | (cond |
| 128 | ((null msg) form) | 128 | ((null msg) form) |
| 129 | ((macroexp--compiling-p) | 129 | ((macroexp--compiling-p) |
| 130 | (if (gethash form macroexp--warned) | 130 | (if (and (consp form) (gethash form macroexp--warned)) |
| 131 | ;; Already wrapped this exp with a warning: avoid inf-looping | 131 | ;; Already wrapped this exp with a warning: avoid inf-looping |
| 132 | ;; where we keep adding the same warning onto `form' because | 132 | ;; where we keep adding the same warning onto `form' because |
| 133 | ;; macroexpand-all gets right back to macroexpanding `form'. | 133 | ;; macroexpand-all gets right back to macroexpanding `form'. |
| @@ -138,9 +138,10 @@ and also to avoid outputting the warning during normal execution." | |||
| 138 | ,form))) | 138 | ,form))) |
| 139 | (t | 139 | (t |
| 140 | (unless compile-only | 140 | (unless compile-only |
| 141 | (message "%s%s" (if (stringp load-file-name) | 141 | (message "%sWarning: %s" |
| 142 | (concat (file-relative-name load-file-name) ": ") | 142 | (if (stringp load-file-name) |
| 143 | "") | 143 | (concat (file-relative-name load-file-name) ": ") |
| 144 | "") | ||
| 144 | msg)) | 145 | msg)) |
| 145 | form)))) | 146 | form)))) |
| 146 | 147 | ||
| @@ -180,8 +181,9 @@ and also to avoid outputting the warning during normal execution." | |||
| 180 | 181 | ||
| 181 | (defun macroexp-macroexpand (form env) | 182 | (defun macroexp-macroexpand (form env) |
| 182 | "Like `macroexpand' but checking obsolescence." | 183 | "Like `macroexpand' but checking obsolescence." |
| 183 | (let ((new-form | 184 | (let* ((macroexpand-all-environment env) |
| 184 | (macroexpand form env))) | 185 | (new-form |
| 186 | (macroexpand form env))) | ||
| 185 | (if (and (not (eq form new-form)) ;It was a macro call. | 187 | (if (and (not (eq form new-form)) ;It was a macro call. |
| 186 | (car-safe form) | 188 | (car-safe form) |
| 187 | (symbolp (car form)) | 189 | (symbolp (car form)) |