Skip to content

Commit cb4ed93

Browse files
vspinubbatsov
authored andcommitted
Make cider-switch-to-repl-buffer switch to most recent buffer
1 parent 4733e02 commit cb4ed93

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Make it possible to disable auto-evaluation of changed ns forms via the defcustom `cider-auto-track-ns-form-changes`.
2828
* [#1991](https://github.com/clojure-emacs/cider/issues/1832): Make it possible to disable the prompt to open a ClojureScript in a browser on connect via `cider-offer-to-open-cljs-app-in-browser`.
2929
* [#1995](https://github.com/clojure-emacs/cider/pull/1995): Add new customization variable `cider-doc-auto-select-buffer` to control cider-doc popup buffer auto selection.
30+
* Ensure that `cider-switch-to-repl-buffer` picks the most recent repl buffer if multiple connections are available.
3031

3132
### Changes
3233

cider-mode.el

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ that of the namespace in the Clojure source buffer."
122122

123123
(defun cider-switch-to-repl-buffer (&optional set-namespace)
124124
"Select the REPL buffer, when possible in an existing window.
125-
The buffer chosen is based on the file open in the current buffer.
125+
The buffer chosen is based on the file open in the current buffer. If
126+
multiple REPL buffers are associated with current connection the most
127+
recent is used.
126128
127129
If the REPL buffer cannot be unambiguously determined, the REPL
128130
buffer is chosen based on the current connection buffer and a
@@ -135,7 +137,10 @@ the buffer should appear.
135137
With a prefix arg SET-NAMESPACE sets the namespace in the REPL buffer to that
136138
of the namespace in the Clojure source buffer."
137139
(interactive "P")
138-
(cider--switch-to-repl-buffer (cider-current-repl-buffer) set-namespace))
140+
(let* ((connections (cider-connections))
141+
(buffer (cl-some (lambda (b) (and (member b connections) b))
142+
(buffer-list))))
143+
(cider--switch-to-repl-buffer buffer set-namespace)))
139144

140145
(declare-function cider-load-buffer "cider-interaction")
141146

0 commit comments

Comments
 (0)