Skip to content

Commit aea853d

Browse files
committed
3834 Extend cider-repls to filter out REPLs that do not support needed ops
1 parent f65ea20 commit aea853d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

cider-connection.el

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,12 @@ Returns a list of the form ((session1 host1) (session2 host2) ...)."
10151015
sessions
10161016
:initial-value '()))
10171017

1018-
(defun cider-repls (&optional type ensure)
1018+
(defun cider-repls (&optional type ensure ops-to-support)
10191019
"Return cider REPLs of TYPE from the current session.
10201020
If TYPE is nil or multi, return all REPLs. If TYPE is a list of types,
10211021
return only REPLs of type contained in the list. If ENSURE is non-nil,
1022-
throw an error if no linked session exists."
1022+
throw an error if no linked session exists. If OPS-TO-SUPPORT is non-nil,
1023+
filters out all the REPLs that do not support the designated ops."
10231024
(let ((type (cond
10241025
((listp type)
10251026
(mapcar #'cider-maybe-intern type))
@@ -1045,7 +1046,10 @@ throw an error if no linked session exists."
10451046
(or (seq-filter (lambda (b)
10461047
(unless
10471048
(cider-cljs-pending-p b)
1048-
(cider--match-repl-type type b)))
1049+
(and (cider--match-repl-type type b)
1050+
(seq-every-p (lambda (op)
1051+
(nrepl-op-supported-p op b))
1052+
ops-to-support))))
10491053
repls)
10501054
(when ensure
10511055
(cider--no-repls-user-error type)))))
@@ -1082,16 +1086,8 @@ session."
10821086
(ensure (cl-case which-key
10831087
(:auto nil)
10841088
(t 'ensure)))
1085-
(repls (cider-repls type ensure)))
1086-
(mapcar (lambda (repl)
1087-
(mapc (lambda (op)
1088-
(unless (nrepl-op-supported-p op repl)
1089-
(user-error "`%s' requires the nREPL op \"%s\" (provided by cider-nrepl)"
1090-
this-command op)))
1091-
ops-to-support)
1092-
(funcall function repl))
1093-
repls))))
1094-
1089+
(repls (cider-repls type ensure ops-to-support)))
1090+
(mapcar function repls))))
10951091

10961092
;; REPLs double as connections in CIDER, so it's useful to be able to refer to
10971093
;; them as connections in certain contexts.

0 commit comments

Comments
 (0)