Insert symbol `debug' into two condition-case handlers

This fixes bug#65622.  Also correct a mismatch between a
function to which advice is added, and that from which it is
removed.

* lisp/emacs-lisp/macroexp.el (internal-macroexpand-for-load):
Add a `debug' to the condition-case handler for `error', so
that a useful backtrace will be produced on a macro expansion
error.

* lisp/progmodes/elisp-mode.el (elisp--local-variables): Add
`debug' to a condition-case handler, as above.  In the
advice-remove call, give the same function, macroexpand-1, as
in the corresponding advice-add call.
This commit is contained in:
Alan Mackenzie 2023-09-20 15:51:17 +00:00
parent 5792ea14ad
commit f931cebce7
2 changed files with 4 additions and 4 deletions

View file

@ -812,7 +812,7 @@ test of free variables in the following ways:
(if full-p
(macroexpand--all-toplevel form)
(macroexpand form)))
(error
((debug error)
;; Hopefully this shouldn't happen thanks to the cycle detection,
;; but in case it does happen, let's catch the error and give the
;; code a chance to macro-expand later.

View file

@ -456,14 +456,14 @@ use of `macroexpand-all' as a way to find the \"underlying raw code\".")
(lambda (expander form &rest args)
(condition-case err
(apply expander form args)
(error (message "Ignoring macroexpansion error: %S" err)
form))))
((debug error)
(message "Ignoring macroexpansion error: %S" err) form))))
(sexp
(unwind-protect
(let ((warning-minimum-log-level :emergency))
(advice-add 'macroexpand-1 :around macroexpand-advice)
(macroexpand-all sexp elisp--local-macroenv))
(advice-remove 'macroexpand macroexpand-advice)))
(advice-remove 'macroexpand-1 macroexpand-advice)))
(vars (elisp--local-variables-1 nil sexp)))
(delq nil
(mapcar (lambda (var)