diff options
| author | Lars Ingebrigtsen | 2022-06-18 13:26:14 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-06-18 13:26:23 +0200 |
| commit | 606275e91ec57cccabeb4ac2feb93753f734cb00 (patch) | |
| tree | 93a5795f1a79871e5d24b6d46ca0a5a54ca515df | |
| parent | ba1508ed17f57642421f510fd9e1ac35e17bf208 (diff) | |
| download | emacs-606275e91ec57cccabeb4ac2feb93753f734cb00.tar.gz emacs-606275e91ec57cccabeb4ac2feb93753f734cb00.zip | |
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.
| -rw-r--r-- | doc/lispref/edebug.texi | 3 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 28 |
3 files changed, 24 insertions, 13 deletions
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 377cd21da86..622578bcf1c 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi | |||
| @@ -719,7 +719,8 @@ Evaluate expression @var{exp} in the context of Edebug itself | |||
| 719 | Evaluate the expression before point, in the context outside of Edebug | 719 | Evaluate the expression before point, in the context outside of Edebug |
| 720 | (@code{edebug-eval-last-sexp}). With the prefix argument of zero | 720 | (@code{edebug-eval-last-sexp}). With the prefix argument of zero |
| 721 | (@kbd{C-u 0 C-x C-e}), don't shorten long items (like strings and | 721 | (@kbd{C-u 0 C-x C-e}), don't shorten long items (like strings and |
| 722 | lists). | 722 | lists). Any other prefix will result in the value being |
| 723 | pretty-printed in a separate buffer. | ||
| 723 | @end table | 724 | @end table |
| 724 | 725 | ||
| 725 | @cindex lexical binding (Edebug) | 726 | @cindex lexical binding (Edebug) |
| @@ -1030,6 +1030,12 @@ which is a change in behaviour from previous Emacs versions. | |||
| 1030 | When invoked with a prefix argument, as in 'C-u e', this command will | 1030 | When invoked with a prefix argument, as in 'C-u e', this command will |
| 1031 | pop up a new buffer and show the full pretty-printed value there. | 1031 | pop up a new buffer and show the full pretty-printed value there. |
| 1032 | 1032 | ||
| 1033 | +++ | ||
| 1034 | *** 'C-x C-e' now interprets a non-zero prefix arg to pretty-print the results. | ||
| 1035 | When invoked with a non-zero prefix argument, as in 'C-u C-x C-e', | ||
| 1036 | this command will pop up a new buffer and show the full pretty-printed | ||
| 1037 | value there. | ||
| 1038 | |||
| 1033 | ** Compile | 1039 | ** Compile |
| 1034 | 1040 | ||
| 1035 | +++ | 1041 | +++ |
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 58cfd47abdf..ad66cfc2b81 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -3746,21 +3746,25 @@ this is the prefix key.)" | |||
| 3746 | (t | 3746 | (t |
| 3747 | (princ result))))) | 3747 | (princ result))))) |
| 3748 | 3748 | ||
| 3749 | (defun edebug-eval-last-sexp (&optional no-truncate) | 3749 | (defun edebug-eval-last-sexp (&optional display-type) |
| 3750 | "Evaluate sexp before point in the outside environment. | 3750 | "Evaluate sexp before point in the outside environment. |
| 3751 | Print value in minibuffer. | 3751 | If DISPLAY-TYPE is `pretty-print' (interactively, a non-zero |
| 3752 | 3752 | prefix argument), pretty-print the value in a separate buffer. | |
| 3753 | If NO-TRUNCATE is non-nil (or interactively with a prefix | 3753 | Otherwise, print the value in minibuffer. If DISPLAY-TYPE is any |
| 3754 | argument of zero), show the full length of the expression, not | 3754 | other non-nil value (or interactively with a prefix argument of |
| 3755 | limited by `edebug-print-length' or `edebug-print-level'." | 3755 | zero), show the full length of the expression, not limited by |
| 3756 | `edebug-print-length' or `edebug-print-level'." | ||
| 3756 | (interactive | 3757 | (interactive |
| 3757 | (list (and current-prefix-arg | 3758 | (list (and current-prefix-arg |
| 3758 | (zerop (prefix-numeric-value current-prefix-arg))))) | 3759 | (if (zerop (prefix-numeric-value current-prefix-arg)) |
| 3759 | (if no-truncate | 3760 | 'no-truncate |
| 3760 | (let ((edebug-print-length nil) | 3761 | 'pretty-print)))) |
| 3761 | (edebug-print-level nil)) | 3762 | (if (or (null display-type) |
| 3762 | (edebug-eval-expression (edebug-last-sexp))) | 3763 | (eq display-type 'pretty-print)) |
| 3763 | (edebug-eval-expression (edebug-last-sexp)))) | 3764 | (edebug-eval-expression (edebug-last-sexp) display-type) |
| 3765 | (let ((edebug-print-length nil) | ||
| 3766 | (edebug-print-level nil)) | ||
| 3767 | (edebug-eval-expression (edebug-last-sexp))))) | ||
| 3764 | 3768 | ||
| 3765 | (defun edebug-eval-print-last-sexp (&optional no-truncate) | 3769 | (defun edebug-eval-print-last-sexp (&optional no-truncate) |
| 3766 | "Evaluate sexp before point in outside environment; insert value. | 3770 | "Evaluate sexp before point in outside environment; insert value. |