Normally the easiest way to debug is using printf
. What can I do to debug emacs-lisp? How can I print something to emacs editor from elisp? Or is there any way to debug elisp code?
For example, how can I check if the following code is run in .emacs
file?
(load "auctex.el" nil t t)
You can enter the debugger when you call the function by calling debug-on-entry . Now, type d again, eight times, slowly. Each time you type d , Emacs will evaluate another expression in the function definition. By typing d , you were able to step through the function.
If the debugger was entered due to a C-g but you really want to quit, and not debug, use the q command.
The debugger (edebug) is pretty straight forward to use. Go to the definition of the function, and type M-x edebug-defun. The next time it is called, you'll be able to step through the code as with every other debugger. Type ? for the list of keybindings, or check out the documentation for edebug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With