Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Emacs Lisp major mode

Tags:

emacs

elisp

I'm developing a major mode for Emacs. Is there any way that I can set a break point in the source code when fontification happens, for example?

like image 200
Alex Avatar asked Aug 29 '09 16:08

Alex


2 Answers

Find the Lisp source of the function you'd like to step through, and type M-x edebug-defun there. Then, whenever that function is executed, you'll automatically be placed into Edebug, where you can step through it if you wish.

Fontification functions can be a bit tricky though, as they can be invoked at odd times. You can use the message function to write messages into the *Messages* buffer. Another trick is to turn off Font Lock (so your function doesn't get invoked automatically), then prep the function you're debugging with edebug-defun and invoke it manually. (Note that you can use M-: (a.k.a. eval-expression) to invoke a non-interactive function.)

like image 69
cjm Avatar answered Sep 18 '22 05:09

cjm


The manual for debugging elisp can be found here.

You can used edebug as mentioned, there's also M-x debug-on-entry and you can set (setq debug-on-quit t). Check out all the options in the link, it all depends on how you want to skin the cat.

like image 27
Trey Jackson Avatar answered Sep 19 '22 05:09

Trey Jackson