argument of @code{-1} overrides the effect of
@code{eval-expression-print-length}.
+ @kbd{C-x C-e} (@code{eval-last-sexp}) treats @code{defvar}
+expressions specially. Normally, evaluating a @code{defvar}
+expression does nothing if the variable it defines already has a
+value. But this command unconditionally resets the variable to the
+initial value specified by the @code{defvar}; this is convenient for
+debugging Emacs Lisp programs. @code{defcustom} and @code{defface}
+expressions are treated similarly. Note the other commands documented
+in this section, except @code{eval-defun}, do not have this special
+feature.
+
@kindex C-M-x @r{(Emacs Lisp mode)}
@findex eval-defun
The @code{eval-defun} command is bound to @kbd{C-M-x} in Emacs Lisp
mode. It evaluates the top-level Lisp expression containing or
following point, and prints the value in the echo area. In this
context, a top-level expression is referred to as a ``defun'', but it
-need not be an actual @code{defun} (function definition). In
-particular, this command treats @code{defvar} expressions specially.
-Normally, evaluating a @code{defvar} expression does nothing if the
-variable it defines already has a value. But this command
-unconditionally resets the variable to the initial value specified by
-the @code{defvar}; this is convenient for debugging Emacs Lisp
-programs. @code{defcustom} and @code{defface} expressions are treated
-similarly. Note that the other commands documented in this section do
-not have this special feature.
+need not be an actual @code{defun} (function definition).
+
+ This command handles @code{defvar}/@code{defcustom}/@code{defface}
+forms the same way that @code{eval-last-sexp} does.
With a prefix argument, @kbd{C-M-x} instruments the function
definition for Edebug, the Emacs Lisp Debugger. @xref{Instrumenting,
would have to type 'M-: M-p' to edit and redo the expression. Now
Emacs will echo the message and allow the user to continue editing.
++++
+** 'eval-last-sexp' now handles 'defvar'/'defcustom'/'defface' specially.
+This command would previously not redefine values defined by these
+forms, but this command has now been changed to work more like
+'eval-defun', and reset the values as specified.
+
+++
** New command 'undo-redo'.
It undoes previous undo commands, but doesn't record itself as an
Ignores leading comment characters."
(interactive "P")
(if arg
- (insert (pp-to-string (eval (pp-last-sexp) lexical-binding)))
- (pp-eval-expression (pp-last-sexp))))
+ (insert (pp-to-string (eval (elisp--eval-defun-1
+ (macroexpand (pp-last-sexp)))
+ lexical-binding)))
+ (pp-eval-expression (elisp--eval-defun-1
+ (macroexpand (pp-last-sexp))))))
;;;###autoload
(defun pp-macroexpand-last-sexp (arg)
;; Setup the lexical environment if lexical-binding is enabled.
(elisp--eval-last-sexp-print-value
(eval (macroexpand-all
- (eval-sexp-add-defvars (elisp--preceding-sexp)))
+ (eval-sexp-add-defvars
+ (elisp--eval-defun-1 (macroexpand (elisp--preceding-sexp)))))
lexical-binding)
(if insert-value (current-buffer) t) no-truncate char-print-limit)))
Interactively, 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,