Skip to content

Commit

Permalink
Make cider-switch-to-repl-buffer switch to most recent buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu authored and bbatsov committed Jul 13, 2017
1 parent 4733e02 commit cb4ed93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Make it possible to disable auto-evaluation of changed ns forms via the defcustom `cider-auto-track-ns-form-changes`.
* [#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`.
* [#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.
* Ensure that `cider-switch-to-repl-buffer` picks the most recent repl buffer if multiple connections are available.

### Changes

Expand Down
9 changes: 7 additions & 2 deletions cider-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ that of the namespace in the Clojure source buffer."

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

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

Expand Down

0 comments on commit cb4ed93

Please sign in to comment.