I registered a focus-in-hook that generates an error. Now any time I try to execute a command in the minibuffer I get an error and am then unable to execute the load-file that would be required to resolve the error. How can I remove this hook or otherwise recover from this situation?

  • 1
    Have you tried M-: (remove-hook 'focus-in-hook 'my-func)? I created a function that raises an error named my-func and was still able to remove the hook in this way (while running emacs -Q). If this doesn't work for you, please provide a minimum working example, or provide a description of the observed behavior vs the expected behavior. – nispio Apr 18 '16 at 23:02
  • You can also use emacs -Q to visit the file where you do such stuff that breaks things. IOW, edit the file without using your init file. – Drew Apr 19 '16 at 0:30

A simple test seems to suggest that you would still be able to evaluate a lisp expression with eval-expression (bound to M-:) in this situation. If so, then try

M-: (remove-hook 'focus-in-hook 'my-func)

Where my-func is the name of the offending function. You can then make the necessary corrections and re-set the hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.