diff --git a/swank.lisp b/swank.lisp index 425c699d2..965f3d391 100644 --- a/swank.lisp +++ b/swank.lisp @@ -1762,7 +1762,8 @@ Errors are trapped and invoke our debugger." (format-values-for-echo-area values))))) (defslimefun eval-and-grab-output - (string &optional (targets-to-capture '(*standard-output* values))) + (string &optional (targets-to-capture '(*standard-output* values) + targets-provided-p)) "Evaluate contents of STRING, return alist of results including various output streams. Possible keys in the returned alist should be listed in the value of `slime-output-targets' variable in `slime.el'." (with-buffer-syntax () (with-retry-restart (:msg "Retry SLIME evaluation request.") @@ -1785,16 +1786,27 @@ Errors are trapped and invoke our debugger." (*standard-output* (maybe-make-string-output-stream *standard-output*)) (values (multiple-value-list (eval (from-string string))))) - ;; It is not clear what would be the most natural order here. - ;; We picked the reversed binding order. - (list (cons 'values - (maybe-value-string (format nil "~{~S~^~%~}" values))) - (cons '*standard-output* - (maybe-output-stream-string *standard-output*)) - (cons '*error-output* - (maybe-output-stream-string *error-output*)) - (cons '*trace-output* - (maybe-output-stream-string *trace-output*)))))))) + (if targets-provided-p + ;; It is not clear what would be the most natural order here. + ;; We picked the reversed binding order. + (list + (cons 'values + (maybe-value-string (format nil "~{~S~^~%~}" values))) + (cons '*standard-output* + (maybe-output-stream-string *standard-output*)) + (cons '*error-output* + (maybe-output-stream-string *error-output*)) + (cons '*trace-output* + (maybe-output-stream-string *trace-output*))) + ;; targets are not provided by callers + ;; who presume older (pre-2.26) interface + ;; to eval-and-grab-output + ;; This check (and targets-provided-p argument itself) + ;; - can certainly be dropped when Emacs 27 becomes unsupported + ;; - can very likely be dropped when Org 9.4 becomes unsupported + (list (maybe-output-stream-string *standard-output*) + (maybe-value-string + (format nil "~{~S~^~%~}" values))))))))) (defun eval-region (string) "Evaluate STRING.