Running into errors is not only a consequence of tinkering with your
editor, it is the only road to graduating in Emacs. Therefore, it
stands to reason that Emacs would contain the most impressive
debugging utilities know to mankind, Edebug.
Learning to Edebug is the right decision for anyone who doesn't know
how to Edebug.
It's easy as pie, you have no excuse not to learn it.
It helps you solve your own problems. Not that the community isn't
helpful, it just allows you to help yourself—which will eventually
allow you to help the community.
If you're a newcomer, it will teach you more about elisp than most
tutorials out there.
If you're anything other than a newcomer, then it's about time and
you should be ashamed of yourself.
A quick first stop
Before delving into Edebug, you should be aware of toggle-debug-on-error and
toggle-debug-on-quit (which happen to be in our toggle-map). Though not as
powerful as the alternative, they're a quick n' dirty way to get a backtrace of
your problem.
How to Edebug a function
Go to where the function is defined. You can usually do that with
C-h f (which calls describe function) or just
M-x find-function.
Press C-u C-M-x. This turns on Edebug for that function.
Now, just invoke the function (or some other command that calls
that function).
The next time the Edebugged function gets called, Emacs will display
its source code and will take you through it step-by-step. Press
n to continue to the next step or
c to stop fooling around and skip to the end.
Once a function has been instrumented, it will trigger Edebug every time it is
called. To undo this effect (to remove instrumentation) simply visit its
definition again and hit C-M-x without the prefix.q
Debugging Elisp Part 1: Earn your independence
24 Nov 2014, by Artur Malabarba.Debugging Emacs-Lisp post series
Running into errors is not only a consequence of tinkering with your editor, it is the only road to graduating in Emacs. Therefore, it stands to reason that Emacs would contain the most impressive debugging utilities know to mankind, Edebug.
Learning to Edebug is the right decision for anyone who doesn't know how to Edebug.
A quick first stop
Before delving into Edebug, you should be aware of
toggle-debug-on-error
andtoggle-debug-on-quit
(which happen to be in our toggle-map). Though not as powerful as the alternative, they're a quick n' dirty way to get a backtrace of your problem.How to Edebug a function
The next time the Edebugged function gets called, Emacs will display its source code and will take you through it step-by-step. Press n to continue to the next step or c to stop fooling around and skip to the end.
For instance, to solve the issue that lead me to write this, we could perform the following sequence of commands:
Once a function has been instrumented, it will trigger Edebug every time it is called. To undo this effect (to remove instrumentation) simply visit its definition again and hit C-M-x without the prefix.q
Tags: edebug, programming, debugging, emacs,
Debugging Elisp Part 2: Advanced topics »
« Emacs Rocks Again!
Related Posts
Turbo up your Ruby console in Emacs in programming
A few paredit keys that take over the world in programming
Restarting the compilation buffer in comint-mode in programming
Content © 2019, All rights reserved. Icons under CC3.0.