diff options
| author | Jens Schmidt | 2023-09-29 22:04:43 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2023-10-05 14:00:36 -0400 |
| commit | 86e8f3150533da1ff5e8bf0afa87c3e97240b253 (patch) | |
| tree | f35201ccdefce1e6e9c441971667c53e0bb13998 | |
| parent | 095d64577c2393640f4859486d6db492203890e6 (diff) | |
| download | emacs-86e8f3150533da1ff5e8bf0afa87c3e97240b253.tar.gz emacs-86e8f3150533da1ff5e8bf0afa87c3e97240b253.zip | |
Silence macro expansion during completion at point
* lisp/emacs-lisp/macroexp.el (macroexp-inhibit-compiler-macros): Add
variable.
(macroexp--compiler-macro): Inspect that new variable and, if it is
non-nil, return the input form unchanged.
* lisp/progmodes/elisp-mode.el (elisp--local-variables): Silence
messages. Avoid compiler macros. (Bug#58148)
| -rw-r--r-- | lisp/emacs-lisp/macroexp.el | 20 | ||||
| -rw-r--r-- | lisp/progmodes/elisp-mode.el | 6 |
2 files changed, 19 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 3ef924a5c73..6eb670d6dc1 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el | |||
| @@ -105,13 +105,21 @@ each clause." | |||
| 105 | (macroexp--all-forms clause skip) | 105 | (macroexp--all-forms clause skip) |
| 106 | clause))) | 106 | clause))) |
| 107 | 107 | ||
| 108 | (defvar macroexp-inhibit-compiler-macros nil | ||
| 109 | "Inhibit application of compiler macros if non-nil.") | ||
| 110 | |||
| 108 | (defun macroexp--compiler-macro (handler form) | 111 | (defun macroexp--compiler-macro (handler form) |
| 109 | (condition-case-unless-debug err | 112 | "Apply compiler macro HANDLER to FORM and return the result. |
| 110 | (apply handler form (cdr form)) | 113 | Unless `macroexp-inhibit-compiler-macros' is non-nil, in which |
| 111 | (error | 114 | case return FORM unchanged." |
| 112 | (message "Warning: Optimization failure for %S: Handler: %S\n%S" | 115 | (if macroexp-inhibit-compiler-macros |
| 113 | (car form) handler err) | 116 | form |
| 114 | form))) | 117 | (condition-case-unless-debug err |
| 118 | (apply handler form (cdr form)) | ||
| 119 | (error | ||
| 120 | (message "Warning: Optimization failure for %S: Handler: %S\n%S" | ||
| 121 | (car form) handler err) | ||
| 122 | form)))) | ||
| 115 | 123 | ||
| 116 | (defun macroexp--funcall-if-compiled (_form) | 124 | (defun macroexp--funcall-if-compiled (_form) |
| 117 | "Pseudo function used internally by macroexp to delay warnings. | 125 | "Pseudo function used internally by macroexp to delay warnings. |
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 664299df288..ff90a744ea3 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el | |||
| @@ -460,7 +460,11 @@ use of `macroexpand-all' as a way to find the \"underlying raw code\".") | |||
| 460 | (message "Ignoring macroexpansion error: %S" err) form)))) | 460 | (message "Ignoring macroexpansion error: %S" err) form)))) |
| 461 | (sexp | 461 | (sexp |
| 462 | (unwind-protect | 462 | (unwind-protect |
| 463 | (let ((warning-minimum-log-level :emergency)) | 463 | ;; Silence any macro expansion errors when |
| 464 | ;; attempting completion at point (bug#58148). | ||
| 465 | (let ((inhibit-message t) | ||
| 466 | (macroexp-inhibit-compiler-macros t) | ||
| 467 | (warning-minimum-log-level :emergency)) | ||
| 464 | (advice-add 'macroexpand-1 :around macroexpand-advice) | 468 | (advice-add 'macroexpand-1 :around macroexpand-advice) |
| 465 | (macroexpand-all sexp elisp--local-macroenv)) | 469 | (macroexpand-all sexp elisp--local-macroenv)) |
| 466 | (advice-remove 'macroexpand-1 macroexpand-advice))) | 470 | (advice-remove 'macroexpand-1 macroexpand-advice))) |