From 859ff65fa89b411176608ac50ccb0394b4fef1c3 Mon Sep 17 00:00:00 2001 From: akater Date: Sat, 11 Apr 2020 15:43:56 +0000 Subject: [PATCH] Ensure backwards compatibility for all users We check whether eval-and-grab-output caller presumes older interface to it and return a legacy list of two elements instead of alist in those cases. It is certainly appropriate to drop this check when Emacs 27 becomes history. It is very likely appropriate to drop when use of Org 9.4 becomes discouraged by Org developers. --- swank.lisp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) 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.