diff options
-rw-r--r-- | cider-mode.el | 28 | ||||
-rw-r--r-- | cider-repl.el | 10 |
2 files changed, 13 insertions, 25 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") diff --git a/cider-repl.el b/cider-repl.el index 57e72354..eb919799 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -1027,10 +1027,12 @@ text property `cider-old-input'." "Switch between the Clojure and ClojureScript REPLs for the current project." (interactive) ;; FIXME: implement cycling as session can hold more than two REPLs - (if-let* ((this-repl (cider-current-repl)) - (other-repls (seq-remove (lambda (r) (eq r this-repl)) (cider-repls)))) - (switch-to-buffer (car other-repls)) - (message "There's no other REPL for the current project"))) + (let* ((this-repl (cider-current-repl nil 'ensure)) + (other-repl (car (seq-remove (lambda (r) (eq r this-repl)) (cider-repls nil t))))) + (if other-repl + (switch-to-buffer other-repl) + (user-error "No other REPL in current session (%s)" + (car (sesman-current-session 'CIDER)))))) (defvar cider-repl-clear-buffer-hook) |