#Emacs tip of the week

This is a two-for-one, these are two tips that I can't believe I never learned about it until now.

What is an easy way to see the value of a variable, or see the result returned from a function call?

You might know about the M-: (Alt-Colon) command, which lets you run any Lisp code, the result is printed into the *Messages* buffer. But... if you use the prefix command C-u (Control-U) and then press M-: (Alt-Colon), the result returned by the Lisp code is printed into the current buffer after the cursor.

Even better, however is using the (pp) ("Pretty-Printing") function. This also outputs to *Messages* by default, but it takes 2 arguments, the second of which can be a buffer. Try this code:

(pp (buffer-local-variables) (currrent-buffer))

The result returned by (buffer-local-variables), which is a list of all buffer-local variables and their values, is pretty-printed right after the cursor.

Reply to this note

Please Login to reply.

Discussion

nostr:npub15fe8snwf0jsk93au6haj3zrtxx9awz3wcc8lxx6qmypv6tndww6sp3x47v I also use C-x C-e at the end of the sexp that interests me, it prints the output of the call into the modeline (and the *Messages* buffer)