While I am developing some elisp package I find myself edebug-defun'ing the same critical functions foo-some-mess and bar-more everytime I modify them, or everytime I load the code after compiling.

Is there a way to tell emacs once and for all that these two functions must be stepped through with edebug?


You may be able to do this by surrounding definitions of function you want to instrument with (edebug-all-defs).


;; this one is instrumented
(defun foo ()

;; this one is, too
(defun bar ()
  (message "hi!"))


;; this one is not
(defun baz ()

Now foo and bar are instrumented, and baz is not.

I found this by pressing C-h k C-M-x and reading the doc. string, which pointed me to edebug-all-defs. Its documentation string says this:

edebug-all-defs is a variable defined in edebug.el. Its value is nil


If non-nil, evaluating defining forms instruments for Edebug. This applies to eval-defun, eval-region, eval-buffer, and eval-current-buffer. eval-region is also called by eval-last-sexp, and eval-print-last-sexp.

You can use the command edebug-all-defs to toggle the value of this variable. You may wish to make it local to each buffer with (make-local-variable 'edebug-all-defs) in your emacs-lisp-mode-hook.

  • Thanks a lot. This seems to be just what I need. I'll try it before accepting your answer. – phs Feb 5 '16 at 20:01

The usual way is: if it hurts, don't do that.

More specifically, don't "compile + load" the code, but edit the code directly in the Emacs where you perform the tests, and after changing the code just do C-u C-M-x or C-M-x (according to whether the changed code should be stepped or not).

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.