Function: pp-eval-expression

pp-eval-expression is an autoloaded, interactive and byte-compiled function defined in pp.el.gz.

Signature

(pp-eval-expression EXPRESSION &optional INSERT-VALUE)

Documentation

Evaluate EXPRESSION and pretty-print its value.

Also add the value to the front of the list in the variable values(var)/values(fun). When called interactively, read an Emacs Lisp expression. With a prefix argument (when called from Lisp, with optional argument INSERT-VALUE non-nil), insert the value into the current buffer instead of displaying it in the echo area or a temporary buffer.

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/pp.el.gz
;;;###autoload
(defun pp-eval-expression (expression &optional insert-value)
  "Evaluate EXPRESSION and pretty-print its value.
Also add the value to the front of the list in the variable `values'.
When called interactively, read an Emacs Lisp expression.
With a prefix argument (when called from Lisp, with optional argument
INSERT-VALUE non-nil), insert the value into the current buffer instead
of displaying it in the echo area or a temporary buffer."
  (interactive
   (list (read--expression "Eval: ") current-prefix-arg))
  (message "Evaluating...")
  (let ((result (eval expression lexical-binding)))
    (values--store-value result)
    (if insert-value
        (let (deactivate-mark)
          (insert (pp-to-string result)))
      (pp-display-expression result "*Pp Eval Output*" pp-use-max-width))))