Extend 'e' in edebug to pretty-print the values
* 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:
parent
c1370d83cb
commit
0d103e6f79
3 changed files with 42 additions and 21 deletions
|
@ -701,7 +701,11 @@ on this process.
|
||||||
@item e @var{exp} @key{RET}
|
@item e @var{exp} @key{RET}
|
||||||
Evaluate expression @var{exp} in the context outside of Edebug
|
Evaluate expression @var{exp} in the context outside of Edebug
|
||||||
(@code{edebug-eval-expression}). That is, Edebug tries to minimize
|
(@code{edebug-eval-expression}). That is, Edebug tries to minimize
|
||||||
its interference with the evaluation. By default, this command
|
its interference with the evaluation. The result is shown in the echo
|
||||||
|
area, or, if this command is given a prefix, pop up a new buffer and
|
||||||
|
pretty-print the result there.
|
||||||
|
|
||||||
|
By default, this command
|
||||||
suppresses the debugger during evaluation, so that an error in the
|
suppresses the debugger during evaluation, so that an error in the
|
||||||
evaluated expression won't add a new error on top of the existing one.
|
evaluated expression won't add a new error on top of the existing one.
|
||||||
Set the @code{debug-allow-recursive-debug} user option to a
|
Set the @code{debug-allow-recursive-debug} user option to a
|
||||||
|
|
3
etc/NEWS
3
etc/NEWS
|
@ -1019,6 +1019,9 @@ buffer or while edebugging) and 'C-x C-e' (while edebugging) commands
|
||||||
lead to a (further) backtrace. By default, this variable is nil,
|
lead to a (further) backtrace. By default, this variable is nil,
|
||||||
which is a change in behaviour from previous Emacs versions.
|
which is a change in behaviour from previous Emacs versions.
|
||||||
|
|
||||||
|
+++
|
||||||
|
*** 'e' in edebug can now take a prefix to pretty-print the results.
|
||||||
|
|
||||||
** Compile
|
** Compile
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
|
@ -3707,30 +3707,44 @@ Return the result of the last expression."
|
||||||
(defalias 'edebug-format #'format-message)
|
(defalias 'edebug-format #'format-message)
|
||||||
(defalias 'edebug-message #'message)
|
(defalias 'edebug-message #'message)
|
||||||
|
|
||||||
(defun edebug-eval-expression (expr)
|
(defun edebug-eval-expression (expr &optional pp)
|
||||||
"Evaluate an expression in the outside environment.
|
"Evaluate an expression in the outside environment.
|
||||||
If interactive, prompt for the expression.
|
If interactive, prompt for the expression.
|
||||||
Print result in minibuffer."
|
|
||||||
(interactive (list (read--expression "Eval: ")))
|
Print result in minibuffer by default, but if PP is non-nil open
|
||||||
|
a new window and pretty-print the result there. (Interactively,
|
||||||
|
this is the prefix key.)"
|
||||||
|
(interactive (list (read--expression "Edebug eval: ")
|
||||||
|
current-prefix-arg))
|
||||||
(let* ((errored nil)
|
(let* ((errored nil)
|
||||||
(result
|
(value
|
||||||
(edebug-outside-excursion
|
(edebug-outside-excursion
|
||||||
(let ((result (if debug-allow-recursive-debug
|
(if debug-allow-recursive-debug
|
||||||
(edebug-eval expr)
|
(edebug-eval expr)
|
||||||
(condition-case err
|
(condition-case err
|
||||||
(edebug-eval expr)
|
(edebug-eval expr)
|
||||||
(error
|
(error
|
||||||
(setq errored
|
(setq errored
|
||||||
(format "%s: %s"
|
(format "%s: %s"
|
||||||
(get (car err) 'error-message)
|
(get (car err) 'error-message)
|
||||||
(car (cdr err)))))))))
|
(car (cdr err)))))))))
|
||||||
(unless errored
|
(result
|
||||||
(values--store-value result)
|
(unless errored
|
||||||
(concat (edebug-safe-prin1-to-string result)
|
(values--store-value value)
|
||||||
(eval-expression-print-format result)))))))
|
(concat (edebug-safe-prin1-to-string value)
|
||||||
(if errored
|
(eval-expression-print-format value)))))
|
||||||
(message "Error: %s" errored)
|
(cond
|
||||||
(princ result))))
|
(errored
|
||||||
|
(message "Error: %s" errored))
|
||||||
|
(pp
|
||||||
|
(save-selected-window
|
||||||
|
(pop-to-buffer "*Edebug Results*")
|
||||||
|
(erase-buffer)
|
||||||
|
(pp value (current-buffer))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(lisp-data-mode)))
|
||||||
|
(t
|
||||||
|
(princ result)))))
|
||||||
|
|
||||||
(defun edebug-eval-last-sexp (&optional no-truncate)
|
(defun edebug-eval-last-sexp (&optional no-truncate)
|
||||||
"Evaluate sexp before point in the outside environment.
|
"Evaluate sexp before point in the outside environment.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue