Ramin Honary on Nostr: #Emacs tip of the week This is a two-for-one, these are two tips that I can't believe ...
#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.
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.