Debugging Elisp

Jon Eskin has a revealing post that shows how easy it is to use the Elisp debugger. The debugger, Edebug, is documented in the Emacs Lisp manual so of course it’s always available in your Emacs session.

What I liked about the post was that it shows how easy it is to use Edebug to solve a problem even if you don’t really know the code base. Usually when you think about a debugger, there’s a supposition that it will be complex, hard to use, and have lots of mysterious commands. Eskin’s post shows otherwise.

The entire debugging session involved two commands. First, the suspect function is intrumented with Ctrl+u Meta+Ctrl+x so that Eskin could step through the function and see what it was doing. It turned out that a variable was being unexpectedly changed. To track down the culprit, Eskin put a watchpoint on the variable and was able to see exactly what was changing it. After that, the problem and its fix was obvious.

There’s more to Edebug, of course, but it’s amazing how far you can get with just the two commands that Eskin used. Notice that Eskin wasn’t writing Elisp code, he merely wanted to track down a problem in existing code. That shows that Edebug can be useful to many different types of users. If you aren’t already familiar with Edebug, take a look at Eskin’s post and then read over the Edebug chapter in the Elisp manual.

This entry was posted in General and tagged . Bookmark the permalink.