@abo-abo provided the general answer: use M-:
.
However, if you are interested not only in obtaining the side effects of the evaluation, and not only in a cursory overview of the return value, but in the full return value (regardless of its size and complexity), then vanilla Emacs
M-:
is not what you want.For that, I substitute
pp-eval-expression
foreval-expression
wrt its key bindings (includingM-:
), and I recommend this practice for others too:(substitute-key-definition 'eval-expression 'pp-eval-expression global-map)
That pretty-prints the return value, and you can make it print the complete value (no ellipses:
...
).In addition, I offer a modified version of
pp-eval-expression
in librarypp+.el
. It has these advantages:- Reads with completion, using
pp-read-expression-map
. - Emacs-Lisp mode indentation and completion key bindings are available during input.
- With a prefix arg, inserts the resulting value into the current buffer at point.
- With a negative prefix arg, if the return value is a string, inserts it into the buffer without double-quotes (
"
). - Font-locks the return value (syntax highlighting) for Emacs-Lisp mode. (And during display
emacs-lisp-mode-hook
andchange-major-mode-hook
are inhibited.) - Respects new user options
pp-eval-expression-print-length
,pp-eval-expression-print-level
, and standard optioneval-expression-debug-on-error
. The former are separate from the similar, standard optionseval-expression-print-length
andeval-expression-print-level
because the use cases are typically different.
- Reads with completion, using
If you use library Icicles then you get the same advantages as library
pp+.el
-- no need to loadpp+.el
also.