Allow pretty-printing results from `C-x C-e' in edebug

* doc/lispref/edebug.texi (Edebug Eval): Document it.

* lisp/emacs-lisp/edebug.el (edebug-eval-expression): Allow
displaying the full value in a different buffer.
This commit is contained in:
Lars Ingebrigtsen 2022-06-18 13:26:14 +02:00
parent ba1508ed17
commit 606275e91e
3 changed files with 24 additions and 13 deletions

View file

@ -719,7 +719,8 @@ Evaluate expression @var{exp} in the context of Edebug itself
Evaluate the expression before point, in the context outside of Edebug
(@code{edebug-eval-last-sexp}). With the prefix argument of zero
(@kbd{C-u 0 C-x C-e}), don't shorten long items (like strings and
lists).
lists). Any other prefix will result in the value being
pretty-printed in a separate buffer.
@end table
@cindex lexical binding (Edebug)

View file

@ -1030,6 +1030,12 @@ which is a change in behaviour from previous Emacs versions.
When invoked with a prefix argument, as in 'C-u e', this command will
pop up a new buffer and show the full pretty-printed value there.
+++
*** 'C-x C-e' now interprets a non-zero prefix arg to pretty-print the results.
When invoked with a non-zero prefix argument, as in 'C-u C-x C-e',
this command will pop up a new buffer and show the full pretty-printed
value there.
** Compile
+++

View file

@ -3746,21 +3746,25 @@ this is the prefix key.)"
(t
(princ result)))))
(defun edebug-eval-last-sexp (&optional no-truncate)
(defun edebug-eval-last-sexp (&optional display-type)
"Evaluate sexp before point in the outside environment.
Print value in minibuffer.
If NO-TRUNCATE is non-nil (or interactively with a prefix
argument of zero), show the full length of the expression, not
limited by `edebug-print-length' or `edebug-print-level'."
If DISPLAY-TYPE is `pretty-print' (interactively, a non-zero
prefix argument), pretty-print the value in a separate buffer.
Otherwise, print the value in minibuffer. If DISPLAY-TYPE is any
other non-nil value (or interactively with a prefix argument of
zero), show the full length of the expression, not limited by
`edebug-print-length' or `edebug-print-level'."
(interactive
(list (and current-prefix-arg
(zerop (prefix-numeric-value current-prefix-arg)))))
(if no-truncate
(let ((edebug-print-length nil)
(edebug-print-level nil))
(edebug-eval-expression (edebug-last-sexp)))
(edebug-eval-expression (edebug-last-sexp))))
(if (zerop (prefix-numeric-value current-prefix-arg))
'no-truncate
'pretty-print))))
(if (or (null display-type)
(eq display-type 'pretty-print))
(edebug-eval-expression (edebug-last-sexp) display-type)
(let ((edebug-print-length nil)
(edebug-print-level nil))
(edebug-eval-expression (edebug-last-sexp)))))
(defun edebug-eval-print-last-sexp (&optional no-truncate)
"Evaluate sexp before point in outside environment; insert value.