Skip to content

Commit a5e2cde

Browse files
committed
Use with-current-buffer in cider--pprint-eval-form
The result buffer might end up selected after it is displayed (depending on configuration). Ensure the source buffer is current when calling cider-interactive-eval, since it examines the contents of the current buffer to evaluate the form. Fixes #2589.
1 parent a6eab10 commit a5e2cde

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cider-eval.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,12 +843,14 @@ With an optional PRETTY-PRINT prefix it pretty-prints the result."
843843

844844
(defun cider--pprint-eval-form (form)
845845
"Pretty print FORM in popup buffer."
846-
(let* ((result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary))
846+
(let* ((buffer (current-buffer))
847+
(result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary))
847848
(handler (cider-popup-eval-handler result-buffer)))
848-
(cider-interactive-eval (when (stringp form) form)
849-
handler
850-
(when (consp form) form)
851-
(cider--nrepl-print-request-map fill-column))))
849+
(with-current-buffer buffer
850+
(cider-interactive-eval (when (stringp form) form)
851+
handler
852+
(when (consp form) form)
853+
(cider--nrepl-print-request-map fill-column)))))
852854

853855
(defun cider-pprint-eval-last-sexp (&optional output-to-current-buffer)
854856
"Evaluate the sexp preceding point and pprint its value.

0 commit comments

Comments
 (0)