macrostep
macrostep copied to clipboard
`macrostep-expand` fails with error on erroneous macros
(defmacro my-bad ()
`(1+ ,(/ 1 0)))
(my-bad)
Using macrostep-expand
on the last form results in an arithmetic error. I'm not sure whether that's intended behaviour, but I'd expect a preview of the code instead. Any thoughts on this?
@wasamasa What should it expand to? (1+ (arith-error))
?
Something like (1+ <error>)
, with <error>
highlighted distinctly. That way one would immediately know what the problematic part is.
It's a nice idea, but I'm not sure if it's feasible within Emacs Lisp. You need to be able to perform macroexpansion within a dynamic environment where you can trap error conditions without unwinding the stack, so that you can return some distinguished error-marker object instead. I think that requires something like Common Lisp's HANDLER-BIND
mechanism, which Emacs Lisp lacks.
Maybe it could be done by binding the debugger
variable? I'll try it next time I have a spare couple of hours.