Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

  (email not shown publicly)

Journal of jplindstrom (594)

Tuesday January 29, 2008
06:54 PM

Emacs: Debugging elisp

[ #35515 ]

In elisp, Data::Dumper is spelled prin1-to-string. Nicely pretty-printed output of deep data structures. Invaluable when you're, like me, lost in the details of Emacs' (and your own for that matter) data structures.

(message "thing: <%s>" (prin1-to-string thing))

Note 1: (message) takes a string like (format) does, which means that if your string value contains e.g. %s... well that's bad. So you should always do (message "%s" my-string).

This is documented but easily overlooked because (message) is one of the first basic tricks you acquire when you start coding elisp, usually by looking at existing code. And then you think you know how it works. At least, that's how I did it.

I used to write (message (format "blah" stuff)) for a while before I finally read the docs for it.

Note 2: The < > in the example is an old habit of mine: always always always put visible delimiters around variable output in log messages so that you immediately see when the value contains padding whitespace.

Yeah, trouble shooting weird errors is easier if you see what you're looking at.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.