@item e @var{exp} @key{RET}
Evaluate expression @var{exp} in the context outside of Edebug
(@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
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
(defalias 'edebug-format #'format-message)
(defalias 'edebug-message #'message)
-(defun edebug-eval-expression (expr)
+(defun edebug-eval-expression (expr &optional pp)
"Evaluate an expression in the outside environment.
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)
- (result
+ (value
(edebug-outside-excursion
- (let ((result (if debug-allow-recursive-debug
- (edebug-eval expr)
- (condition-case err
- (edebug-eval expr)
- (error
- (setq errored
- (format "%s: %s"
- (get (car err) 'error-message)
- (car (cdr err)))))))))
- (unless errored
- (values--store-value result)
- (concat (edebug-safe-prin1-to-string result)
- (eval-expression-print-format result)))))))
- (if errored
- (message "Error: %s" errored)
- (princ result))))
+ (if debug-allow-recursive-debug
+ (edebug-eval expr)
+ (condition-case err
+ (edebug-eval expr)
+ (error
+ (setq errored
+ (format "%s: %s"
+ (get (car err) 'error-message)
+ (car (cdr err)))))))))
+ (result
+ (unless errored
+ (values--store-value value)
+ (concat (edebug-safe-prin1-to-string value)
+ (eval-expression-print-format value)))))
+ (cond
+ (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)
"Evaluate sexp before point in the outside environment.