hydra
hydra copied to clipboard
Bad interaction with company-mode when editing hydra
-
emacs -Q
-
M-x package-initialize
-
M-x toggle-debug-on-error
-
M-x company-mode
- After "a" start typing in the code below
(defhydra simple (nil nil :hint nil :foreign-keys run)
"
_a_: A"
("a" asd))
You get trapped in a loop with backtrace. company is trying to expand the macro which throws an error each time. Is there any way to avoid an error on macro expansion?
Debugger entered--Lisp error: (error "An run Hydra must have at least one blue head in order to exit")
signal(error ("An run Hydra must have at least one blue head in order to exit"))
error("An %S Hydra must have at least one blue head in order to exit" run)
#[898 "C\302!\262;\204* :\203\"
Works fine for me. In any case, seems like a company-mode
issue rather than hydra
.
It's not just company-mode
, although that is what's causing the headache here. The call that triggers it is elisp--local-variables
which tries to expand any surrounding macros. If you just try to macroexpand a bad hydra, an error is thrown. Here for example.
The issue is that there are some cases (eg company-mode
) in which the macro gets expanded before the user has finished it and defhydra
throws errors at expansion time. I tend to leave debug-on-error
on, but I can see that everything is fine with it off. What if the macro just expanded to the error without executing it in this case? Would that be bad?
Now that I understand the problem, I can just leave debug-on-error
off, but this is the first time it's caused a problem when there wasn't an actual bug.
What if the macro just expanded to the error without executing it in this case? Would that be bad?
You can change it to a warning
as far as I'm concerned. The error was intended as a hint to the user to fix the code.