5

When I evaluate an expression with C-x C-e, I see the result returned by that expression in the minibuffer, for a while.

Can I have that returned value written in the same buffer where the evalued expression is?

How?

1
  • 2
    I removed your buffer-local tag. buffer-local in emacs is about variables having values specific to a buffer.
    – rpluim
    Dec 20 '20 at 12:37
7

The emacs way is to ask emacs:

C-h k C-x C-e

C-x C-e runs the command eval-last-sexp (found in global-map), which
is an interactive compiled Lisp function in `elisp-mode.el'.

It is bound to C-x C-e.

(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)

  Probably introduced at or before Emacs version 24.4.

Evaluate sexp before point; print value in the echo area.
Interactively, with a non `-' prefix argument, print output into
current buffer.

Read that last line. Do:

C-u C-x C-e

and observe the result.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.