1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-25 07:28:20 +00:00

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)
This commit is contained in:
Jens Schmidt 2023-09-29 22:04:43 +02:00 committed by Stefan Monnier
parent 095d64577c
commit 86e8f31505
2 changed files with 19 additions and 7 deletions

View File

@ -105,13 +105,21 @@ each clause."
(macroexp--all-forms clause skip) (macroexp--all-forms clause skip)
clause))) clause)))
(defvar macroexp-inhibit-compiler-macros nil
"Inhibit application of compiler macros if non-nil.")
(defun macroexp--compiler-macro (handler form) (defun macroexp--compiler-macro (handler form)
(condition-case-unless-debug err "Apply compiler macro HANDLER to FORM and return the result.
(apply handler form (cdr form)) Unless `macroexp-inhibit-compiler-macros' is non-nil, in which
(error case return FORM unchanged."
(message "Warning: Optimization failure for %S: Handler: %S\n%S" (if macroexp-inhibit-compiler-macros
(car form) handler err) form
form))) (condition-case-unless-debug err
(apply handler form (cdr form))
(error
(message "Warning: Optimization failure for %S: Handler: %S\n%S"
(car form) handler err)
form))))
(defun macroexp--funcall-if-compiled (_form) (defun macroexp--funcall-if-compiled (_form)
"Pseudo function used internally by macroexp to delay warnings. "Pseudo function used internally by macroexp to delay warnings.

View File

@ -460,7 +460,11 @@ use of `macroexpand-all' as a way to find the \"underlying raw code\".")
(message "Ignoring macroexpansion error: %S" err) form)))) (message "Ignoring macroexpansion error: %S" err) form))))
(sexp (sexp
(unwind-protect (unwind-protect
(let ((warning-minimum-log-level :emergency)) ;; Silence any macro expansion errors when
;; attempting completion at point (bug#58148).
(let ((inhibit-message t)
(macroexp-inhibit-compiler-macros t)
(warning-minimum-log-level :emergency))
(advice-add 'macroexpand-1 :around macroexpand-advice) (advice-add 'macroexpand-1 :around macroexpand-advice)
(macroexpand-all sexp elisp--local-macroenv)) (macroexpand-all sexp elisp--local-macroenv))
(advice-remove 'macroexpand-1 macroexpand-advice))) (advice-remove 'macroexpand-1 macroexpand-advice)))