When I write lisp code that contains errors, I debug it with toggle-debug-on-error. Unfortunately, once a certain function triggers the debugger once, Emacs stops launching the debugger on errors in subsequent calls to that function, giving only a summary in the echo area instead.

Is there any way I can have the debugger always invoked on error?


If variable debug-on-error is non-nil then an error always enters the debugger. However, if the debugger is already open (but its window is hidden behind another frame or whatever) then you might not notice this.

Check the mode line for [...] and see whether you have a buffer named *Backtrace*, if the backtrace does not seem to get popped up.

If the backtrace is already open then quit it, using q. Sometimes you can continue with the debugger (using c) after an error occurs but typically you cannot do much at that point.

The point of entering the debugger on an error is to see what caused it. After you see that, quit the debugger. The next error will then reopen it.

Once you find the cause of an error that was raised, you can, for example, use debug-on-entry to debug the function that caused it. That will give you a better understanding of what's wrong.

(Read the Elisp manual about using the debugger.)

  • Thanks for the clarification. It does indeed appear that killing the window leaves the *Backtrace* buffer to lurk in the background. – PythonNut Oct 24 '15 at 18:18
  • Yes, and I agree that this is a "gotcha" or an "annoyance". Please consider filing a bug report about it (M-x report-emacs-bug). (I've just gotten used to it, by now...) – Drew Oct 24 '15 at 18:45
  • @PythonNut Another gotcha is that you might have left the Debugger in an incomplete state. You can detect that by see one or more nested sets of square brackets around the major mode name in the mode-line. Example [Org] instead of Org. To quit that, do C-M-c. Once that square brackets are gone, the *Backtrace* window will launch fine the next time error is triggered. – Kaushal Modi Nov 6 '15 at 19:33

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.