@@ -1053,8 +1053,9 @@ throw an error if no linked session exists."
1053
1053
(defun cider-map-repls (which function )
1054
1054
" Call FUNCTION once for each appropriate REPL as indicated by WHICH.
1055
1055
The function is called with one argument, the REPL buffer. The appropriate
1056
- connections are found by inspecting the current buffer. WHICH is one of
1057
- the following keywords:
1056
+ connections are found by inspecting the current buffer. WHICH is either one of
1057
+ the following keywords or a list starting with one of them followed by names of
1058
+ operations that the REPL is expected to support:
1058
1059
:auto - Act on the connections whose type matches the current buffer. In
1059
1060
`cljc' files, mapping happens over both types of REPLs.
1060
1061
:clj (:cljs) - Map over clj (cljs)) REPLs only.
@@ -1064,23 +1065,33 @@ the following keywords:
1064
1065
Error is signaled if no REPL buffers of specified type exist in current
1065
1066
session."
1066
1067
(declare (indent 1 ))
1067
- (let ((cur-type (cider-repl-type-for-buffer)))
1068
- (cl-case which
1068
+ (let ((cur-type (cider-repl-type-for-buffer))
1069
+ (which-key (or (car-safe which) which))
1070
+ (ops-to-support (cdr-safe which)))
1071
+ (cl-case which-key
1069
1072
(:clj-strict (when (eq cur-type 'cljs )
1070
1073
(user-error " Clojure-only operation requested in a ClojureScript buffer" )))
1071
1074
(:cljs-strict (when (eq cur-type 'clj )
1072
1075
(user-error " ClojureScript-only operation requested in a Clojure buffer" ))))
1073
- (let* ((type (cl-case which
1076
+ (let* ((type (cl-case which-key
1074
1077
((:clj :clj-strict ) 'clj )
1075
1078
((:cljs :cljs-strict ) 'cljs )
1076
1079
(:auto (if (eq cur-type 'multi )
1077
1080
'(clj cljs)
1078
1081
cur-type))))
1079
- (ensure (cl-case which
1082
+ (ensure (cl-case which-key
1080
1083
(:auto nil )
1081
1084
(t 'ensure )))
1082
1085
(repls (cider-repls type ensure)))
1083
- (mapcar function repls))))
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
+
1084
1095
1085
1096
; ; REPLs double as connections in CIDER, so it's useful to be able to refer to
1086
1097
; ; them as connections in certain contexts.
0 commit comments