@@ -627,7 +627,7 @@ function with the repl buffer set as current."
627
627
cider-session-name ses-name
628
628
nrepl-project-dir (plist-get params :project-dir )
629
629
; ; REPLs start with clj and then "upgrade" to a different type
630
- cider-repl-type " clj "
630
+ cider-repl-type ( plist-get params :repl-type )
631
631
; ; ran at the end of cider--connected-handler
632
632
cider-repl-init-function (plist-get params :repl-init-function ))
633
633
(cider-repl-reset-markers)
@@ -639,6 +639,17 @@ function with the repl buffer set as current."
639
639
640
640
; ;; Current/other REPLs
641
641
642
+ (defun cider--no-repls-user-error (type )
643
+ " Throw \" No REPL\" user error customized for TYPE."
644
+ (let ((type (cond
645
+ ((equal type " multi" )
646
+ " clj or cljs" )
647
+ ((listp type)
648
+ (mapconcat #'identity type " or " ))
649
+ (type))))
650
+ (user-error " No %s REPLs in current session \" %s\" "
651
+ type (car (sesman-current-session 'CIDER )))))
652
+
642
653
(defun cider-current-repl (&optional type ensure )
643
654
" Get the most recent REPL of TYPE from the current session.
644
655
TYPE is either \" clj\" , \" cljs\" or \" multi\" . When nil, infer the type
@@ -659,26 +670,30 @@ session."
659
670
(member b repls))
660
671
(buffer-list )))))
661
672
(if (and ensure (null repl))
662
- (user-error " No %s REPL in current session (%s)"
663
- type (car (sesman-current-session 'CIDER )))
673
+ (cider--no-repls-user-error type)
664
674
repl))))
665
675
666
676
(defun cider--match-repl-type (type buffer )
667
677
" Return non-nil if TYPE matches BUFFER's REPL type."
668
678
(let ((buffer-repl-type (cider-repl-type buffer)))
669
679
(cond ((null buffer-repl-type) nil )
670
680
((or (null type) (equal type " multi" )) t )
681
+ ((listp type) (member buffer-repl-type type))
671
682
(t (string= type buffer-repl-type)))))
672
683
673
684
(defun cider-repls (&optional type ensure )
674
685
" Return cider REPLs of TYPE from the current session.
675
- If TYPE is nil or \" multi\" , return all repls. If ENSURE is non-nil, throw
676
- an error if no linked session exists."
686
+ If TYPE is nil or \" multi\" , return all repls. If TYPE is a list of types,
687
+ return only REPLs of type contained in the list. If ENSURE is non-nil,
688
+ throw an error if no linked session exists."
677
689
(let ((repls (cdr (if ensure
678
690
(sesman-ensure-session 'CIDER )
679
691
(sesman-current-session 'CIDER )))))
680
- (seq-filter (lambda (b )
681
- (cider--match-repl-type type b)) repls)))
692
+ (or (seq-filter (lambda (b )
693
+ (cider--match-repl-type type b))
694
+ repls)
695
+ (when ensure
696
+ (cider--no-repls-user-error type)))))
682
697
683
698
(defun cider-map-repls (which function )
684
699
" Call FUNCTION once for each appropriate REPL as indicated by WHICH.
@@ -691,7 +706,8 @@ the following keywords:
691
706
:clj-strict (:cljs-strict) - Map over clj (cljs) REPLs but signal a
692
707
`user-error' in `clojurescript-mode' (`clojure-mode' ). Use this for
693
708
commands only supported in Clojure (ClojureScript).
694
- Error is signaled if no REPL buffer of specified type exists."
709
+ Error is signaled if no REPL buffers of specified type exist in current
710
+ session."
695
711
(declare (indent 1 ))
696
712
(let ((cur-type (cider-repl-type-for-buffer)))
697
713
(cl-case which
@@ -702,7 +718,9 @@ Error is signaled if no REPL buffer of specified type exists."
702
718
(let* ((type (cl-case which
703
719
((:clj :clj-strict ) " clj" )
704
720
((:cljs :cljs-strict ) " cljs" )
705
- (:auto cur-type)))
721
+ (:auto (if (equal cur-type " multi" )
722
+ '(" clj" " cljs" )
723
+ cur-type))))
706
724
(repls (cider-repls type 'ensure )))
707
725
(mapcar function repls))))
708
726
0 commit comments