22

How do I undo the effects of edebug-defun? In other words, how do I rescind the directive that causes edebug to enter debugging mode when a particular function is invoked?

Also, I'd really like to know where the answer to this question is in the documenation. I've looked for it far longer than one would think would be necessary...

3 Answers 3

21

From (info "(elisp) Instrumenting") :

   To remove instrumentation from a definition, simply re-evaluate its
definition in a way that does not instrument.  There are two ways of
evaluating forms that never instrument them: from a file with `load',
and from the minibuffer with `eval-expression' (`M-:').

IOW, the easy way is to use C-M-x without prefix argument (or with a prefix argument, if you have edebug-all-defs set).

4
  • 1
    Thanks! After seeing the answer, I am now absolutely certain that the only way I would have found the answer would have been a linear search through all of the Emacs and Elisp documentation.
    – kjo
    Apr 4, 2016 at 14:58
  • FWIW I wish there was an easy way to remove instrumentation from all definitions (even if scattered across multiple files) at once, but I don't know of one.
    – YoungFrog
    Apr 4, 2016 at 14:59
  • @kjo I found it by opening up the edebug section in the elisp manual, and browsing through the sections. Knowing that "effects of edebug-defun" is called "instrumenting" certainly helped.
    – YoungFrog
    Apr 4, 2016 at 15:00
  • 3
    @kjo Also, if you report a bug (M-x report-emacs-bug) by saying what you actually tried when looking for your answer, the documentation can then be improved.
    – YoungFrog
    Apr 4, 2016 at 15:02
10

In other words, how do I rescind the directive that causes edebug to enter debugging mode when a particular function is invoked?

You can get this effect without removing instrumentation by setting edebug-initial-mode to go. This way, you will only get stopped in edebug if there is a breakpoint set. As of Emacs 25.1, you can do this quickly with edebug-set-initial-mode: C-x C-a C-m g

(info "(elisp) Edebug Execution Modes")

‘g’
     Go: run until the next breakpoint (‘edebug-go-mode’).  *Note
     Breakpoints::.

[...]

When you enter a new Edebug level, the initial execution mode comes
from the value of the variable ‘edebug-initial-mode’ (*note Edebug
Options::).  By default, this specifies step mode.

[...]

Command: edebug-set-initial-mode

This command, bound to C-x C-a C-m, sets edebug-initial-mode. It
prompts you for a key to indicate the mode. You should enter one of
the eight keys listed above, which sets the corresponding mode.
0
0

For anyone using doom emacs to cancel edebug-defun put your cursor inside defun and run <leader> m e d or eval-defun (this is equivalent to C-M-x mentioned in the accepted answer). Evaluating function definition again "overwrites" edebug's effects.

0

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.