@@ -1053,8 +1053,9 @@ throw an error if no linked session exists."
10531053(defun cider-map-repls (which function )
10541054 " Call FUNCTION once for each appropriate REPL as indicated by WHICH.
10551055The 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:
10581059 :auto - Act on the connections whose type matches the current buffer. In
10591060 `cljc' files, mapping happens over both types of REPLs.
10601061 :clj (:cljs) - Map over clj (cljs)) REPLs only.
@@ -1064,23 +1065,33 @@ the following keywords:
10641065Error is signaled if no REPL buffers of specified type exist in current
10651066session."
10661067 (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
10691072 (:clj-strict (when (eq cur-type 'cljs )
10701073 (user-error " Clojure-only operation requested in a ClojureScript buffer" )))
10711074 (:cljs-strict (when (eq cur-type 'clj )
10721075 (user-error " ClojureScript-only operation requested in a Clojure buffer" ))))
1073- (let* ((type (cl-case which
1076+ (let* ((type (cl-case which-key
10741077 ((:clj :clj-strict ) 'clj )
10751078 ((:cljs :cljs-strict ) 'cljs )
10761079 (:auto (if (eq cur-type 'multi )
10771080 '(clj cljs)
10781081 cur-type))))
1079- (ensure (cl-case which
1082+ (ensure (cl-case which-key
10801083 (:auto nil )
10811084 (t 'ensure )))
10821085 (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+
10841095
10851096; ; REPLs double as connections in CIDER, so it's useful to be able to refer to
10861097; ; them as connections in certain contexts.
0 commit comments