diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2018-04-13 10:51:00 +0300 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2018-04-13 10:51:00 +0300 |
commit | 18a5f10021a70134310f367547c4c750e1acedba (patch) | |
tree | ea92589f6b9493cfae5f0206e5c4a8607cb8e6a9 | |
parent | 41087a59ec92707649b0a26105a85c0b69f0ff91 (diff) |
Add a function for registering additional ClojureScript REPL types
Handy for people who're not satisfied with the available defaults.
-rw-r--r-- | cider.el | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -671,7 +671,7 @@ The supplied string will be wrapped in a do form if needed." form (format "(do %s)" form)))) -(defconst cider-cljs-repl-types +(defvar cider-cljs-repl-types '(("Rhino" "(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))" nil) ("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. The form should be either a string or a function producing a string.") +(defun cider-register-cljs-repl-type (name init-form &optional requirements-fn) + "Register a new ClojureScript REPL type. + +Types are defined by the following: + +- NAME - string identifier that will be used to refer to the REPL typel +- INIT-FORM - string or function (symbol) producing string +- REQUIREMENTS-FN - function to check whether the REPL can be started. +This param is optional. + +All this function does is modifying `cider-cljs-repl-types'. +It's intended to be used in your Emacs config." + (unless (stringp name) + (user-error "The REPL name must be a string")) + (unless (or (stringp init-form) (symbolp init-form)) + (user-error "The init form must be a string or a symbol referring to a function")) + (unless (or (null requirements-fn) (symbolp requirements-fn)) + (user-error "The requirements-fn must be a symbol referring to a function")) + (add-to-list 'cider-cljs-repl-types (list name init-form requirements-fn))) + (defcustom cider-default-cljs-repl nil "The default ClojureScript REPL to start. |