Next: , Previous: , Up: Evaluate Emacs Lisp Expressions   [Index]


F.1.3 Eval S-Expression

(eval-last-sexp)

C-x C-e

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

It is one of few commands that are globally available to most modes, and it only works if you have the point at the end of an s-expression.

Normally, this function truncates long output according to the value of the variables:

  • eval-expression-print-length
  • eval-expression-print-level

With a prefix argument of ’0’, do not truncate.

If ‘eval-expression-debug-on-error’ is non-nil, which is the default, this command arranges for all errors to enter the debugger.

There are a couple of limitations that make this command a poor tool to use if you are writing and testing elisp code, because it cannot update variables declared with ‘defvar’ or ‘defcustom’, and it goes with saying that having to move point to the end of the expression every time you want to eval the sexp is annoying as well.