Skip to content

Commit 18a5f10

Browse files
committed
Add a function for registering additional ClojureScript REPL types
Handy for people who're not satisfied with the available defaults.
1 parent 41087a5 commit 18a5f10

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

cider.el

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ The supplied string will be wrapped in a do form if needed."
671671
form
672672
(format "(do %s)" form))))
673673

674-
(defconst cider-cljs-repl-types
674+
(defvar cider-cljs-repl-types
675675
'(("Rhino" "(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))"
676676
nil)
677677
("Nashorn" "(cemerick.piggieback/cljs-repl (cljs.repl.nashorn/repl-env))"
@@ -693,6 +693,26 @@ REPL to start the ClojureScript REPL and functions to very their requirements.
693693
694694
The form should be either a string or a function producing a string.")
695695

696+
(defun cider-register-cljs-repl-type (name init-form &optional requirements-fn)
697+
"Register a new ClojureScript REPL type.
698+
699+
Types are defined by the following:
700+
701+
- NAME - string identifier that will be used to refer to the REPL typel
702+
- INIT-FORM - string or function (symbol) producing string
703+
- REQUIREMENTS-FN - function to check whether the REPL can be started.
704+
This param is optional.
705+
706+
All this function does is modifying `cider-cljs-repl-types'.
707+
It's intended to be used in your Emacs config."
708+
(unless (stringp name)
709+
(user-error "The REPL name must be a string"))
710+
(unless (or (stringp init-form) (symbolp init-form))
711+
(user-error "The init form must be a string or a symbol referring to a function"))
712+
(unless (or (null requirements-fn) (symbolp requirements-fn))
713+
(user-error "The requirements-fn must be a symbol referring to a function"))
714+
(add-to-list 'cider-cljs-repl-types (list name init-form requirements-fn)))
715+
696716
(defcustom cider-default-cljs-repl nil
697717
"The default ClojureScript REPL to start.
698718

0 commit comments

Comments
 (0)