Function: eval-last-sexp

eval-last-sexp is an interactive and byte-compiled function defined in elisp-mode.el.gz.

Signature

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

Documentation

Evaluate sexp before point; print value in the echo area.

Interactively, EVAL-LAST-SEXP-ARG-INTERNAL is the prefix argument. With a non - prefix argument, print output into current buffer.

This commands handles defvar, defcustom and defface the same way that eval-defun does. See the doc string of that function for details.

Normally, this function truncates long output according to the value of the variables eval-expression-print-length and eval-expression-print-level. With a prefix argument of zero, however, there is no such truncation. Integer values are printed in several formats (decimal, octal, and hexadecimal). When the prefix argument is -1 or the value doesn't exceed eval-expression-print-maximum-character, an integer value is also printed as a character of that codepoint.

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

View in manual

Probably introduced at or before Emacs version 24.4.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
(defun eval-last-sexp (eval-last-sexp-arg-internal)
  "Evaluate sexp before point; print value in the echo area.
Interactively, EVAL-LAST-SEXP-ARG-INTERNAL is the prefix argument.
With a non `-' prefix argument, print output into current buffer.

This commands handles `defvar', `defcustom' and `defface' the
same way that `eval-defun' does.  See the doc string of that
function for details.

Normally, this function truncates long output according to the
value of the variables `eval-expression-print-length' and
`eval-expression-print-level'.  With a prefix argument of zero,
however, there is no such truncation.
Integer values are printed in several formats (decimal, octal,
and hexadecimal).  When the prefix argument is -1 or the value
doesn't exceed `eval-expression-print-maximum-character', an
integer value is also printed as a character of that codepoint.

If `eval-expression-debug-on-error' is non-nil, which is the default,
this command arranges for all errors to enter the debugger."
  (interactive "P")
  (funcall
   ;; Not sure why commit 4428c27c1ae7d stored into `values' only when
   ;; `eval-expression-debug-on-error' was nil, but let's preserve that.
   (if eval-expression-debug-on-error #'identity #'values--store-value)
   (handler-bind ((error (if eval-expression-debug-on-error
                             #'eval-expression--debug #'ignore)))
     (elisp--eval-last-sexp eval-last-sexp-arg-internal))))