3

Many languages have a mechanism to signal an attached debugger to pause or break. For example in JavaScript this is done using the debugger keyword. In others like C# or Visual Basic the signal is generated by a built-in function. This functionality is useful in situations where it is difficult or impossible to set breakpoints using the debugger.

Does elisp have an equivalent?

Drew
  • 75,699
  • 9
  • 109
  • 225
ebpa
  • 7,319
  • 26
  • 53
  • Just add `(debug)` to your code [[Ref](https://www.gnu.org/software/emacs/manual/html_node/elisp/Explicit-Debug.html#Explicit-Debug)]. – Kaushal Modi Jun 09 '16 at 03:47
  • Also have a look at `debug-on-message` variable. Does `edebug` not help you in your use case? – Kaushal Modi Jun 09 '16 at 03:49
  • *facepalm* Thanks :-) `debug-on-message` looks neat! I seem to have encountered functions instrumented by edebug-defun not pausing in the debugger in certain contexts. I'll create a separate question if the mystery persists. – ebpa Jun 09 '16 at 04:01
  • I'm unsure of the proper etiquette here, but as the Q creator I believe I'm entitled to apply arbitrary answer selection criteria. @KaushalModi If you add an equivalent answer to your comment I'll mark it as answered. If you would like to defer to Stefan's answer (which was made after your comment) I'll mark his. In either case the "Explicit Debug" link should be included. – ebpa Jun 09 '16 at 04:09
  • No worries. Mark Stefan's answer as the answer :). You can ask him to add that link to his answer so that other users get a lead to learn more about this. – Kaushal Modi Jun 09 '16 at 04:13

1 Answers1

6

Add (debug) and you'll be thrown into a buffer showing you the backtrace and where you can examine the current state.

See: Emacs Manual "Explicit Entry to the Debugger"

ebpa
  • 7,319
  • 26
  • 53
Stefan
  • 26,154
  • 3
  • 46
  • 84