summaryrefslogtreecommitdiff
path: root/cider-mode.el
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2018-06-28 11:27:47 +0200
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-06-30 19:24:48 +0200
commit40c1fa0962b4c2285b432cb25263b5edf8c164e2 (patch)
tree91a32de24df9923feb35d297cca60839990c2723 /cider-mode.el
parentaecf9b05f1598bc25a0f1d65c982dde1afad2d9a (diff)
Refactor `cider-switch-to-repl-buffer` and `cider-repl-switch-to-other`
- cider-switch-to-repl-buffer uses cider-current-repl instead of implementing its own lookup - cider-repl-switch-to-other throws a "no other REPL" error if no other REPL exists instead of switching to an arbitrary buffer
Diffstat (limited to 'cider-mode.el')
-rw-r--r--cider-mode.el28
1 files changed, 7 insertions, 21 deletions
diff --git a/cider-mode.el b/cider-mode.el
index ff8782a8..59cd7e40 100644
--- a/cider-mode.el
+++ b/cider-mode.el
@@ -99,28 +99,14 @@ that of the namespace in the Clojure source buffer."
(goto-char (point-max))))
(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. If
-multiple cider sessions are associated with current connection the most
-recent is used. With a prefix arg SET-NAMESPACE sets the namespace in the
-REPL buffer to that of the namespace in the Clojure source buffer
-
-Hint: You can use `display-buffer-reuse-frames' and
-`special-display-buffer-names' to customize the frame in which
-the buffer should appear."
+ "Switch to current REPL buffer, when possible in an existing window.
+The type of the REPL is inferred from the mode of current buffer. 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")
- (if-let* ((repls (cider-repls)))
- (let* ((type (cider-repl-type-for-buffer))
- (a-repl)
- (the-repl (seq-find (lambda (buf)
- (when (member buf repls)
- (unless a-repl
- (setq a-repl buf))
- (equal type (cider-repl-type-for-buffer buf))))
- (buffer-list))))
- (let ((repl (or the-repl a-repl)))
- (cider--switch-to-repl-buffer repl set-namespace)))
- (user-error "No linked REPL")))
+ (cider--switch-to-repl-buffer
+ (cider-current-repl nil 'ensure)
+ set-namespace))
(declare-function cider-load-buffer "cider-eval")