I am trying to debug a problem with the alert.el package using edebug. However, I am unable to step through the alert function.

I expect the debugger to enter the function and allow me to step through. Instead, it terminates.

Here is what I'm doing:

  1. Open an Emacs instance opened with emacs -Q
  2. Evaluate (package-initialize)
  3. Call C-u C-M-x on (alert "Hello, world!")

At this point, I see an indicator in my fringe.

On the fringe

  1. Press i to step into the function call

On pressing i, I quickly see "Go..." printed to the minibuffer and the fringe indicator disappears.

I am no longer debugging.

Checking C-h f alert shows me that it is an autoloaded function. Might this be affecting my ability to step into it?

I have tried toggling (debug-on-error) and stepping through with d. However, I can't see the source code while stepping. Whenever I try to open another buffer with the source code in it, pressing d in the *Backtrace* closes the source code buffer. Is there a way to use (debug-on-error) and see the source code while stepping through execution?

Any advice you have for debugging is welcome.

  • You can explicitly load alert.el with load-library or require.
    – Tobias
    Aug 2, 2019 at 19:23
  • That was something I tried, running (require 'alert) after Step 2. When I did that, I experienced the same behavior with edebug. I did notice however that the help description changes to say "alert is an autoloaded Lisp closure...". Might that affect edebug's behavior? I noticed this line in the documentation: "Most Emacs Lisp programs, however, should not interact directly with lexical environments in this way; only specialized programs like debuggers." gnu.org/software/emacs/manual/html_node/elisp/… Aug 2, 2019 at 19:46
  • 2
    Step 3 i s wrong: you need to do C-u C-M-x on the definition of the alert function, not on its use.
    – NickD
    Aug 2, 2019 at 20:29
  • 1
    That's not true: there is a customization group called alert and there is a function called alert: go to line 1022 of alert.el to see it. It's the latter that you want to apply C-u C-M-x to.
    – NickD
    Aug 2, 2019 at 20:56
  • 1
    Strange xref-find-definition brings you to the defgroup but should prolly take you to (cl-defun alert ... at line 1023. If you debug the cl-defun it works as expected.
    – Hubisan
    Aug 2, 2019 at 20:58

2 Answers 2


You need to apply C-u C-M-x on the definition of a function in order to enable edebug to instrument it for debugging. Your step 3. applies it to the use of the function, which does not do anything useful.

Download the alert.el file and load it with e.g. (load-file "/path/to/alert.el"), then open the file in emacs and navigate to the definition of the alert function on line 1022 or thereabouts. That's where you want to do C-u C-M-x.


For anyone using a framework like doom emacs C-u C-M-x is edebug-defun and it doesn't have any keybinding by default (using edebug in doom emacs isn't documented at all as a matter of fact so you are on your own when trying to debug emacs lisp).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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