Skip to content

Commit 46007a0

Browse files
committed
Add separate defcustom for cljs connection params
1 parent f56f1f7 commit 46007a0

File tree

1 file changed

+48
-10
lines changed

1 file changed

+48
-10
lines changed

cider.el

+48-10
Original file line numberDiff line numberDiff line change
@@ -1500,21 +1500,54 @@ server buffer, in which case a new session for that server is created."
15001500
(plist-put :session-name ses-name)
15011501
(plist-put :repl-type 'cljs)))))
15021502

1503-
(defvar-local cider-connect-default-params nil
1504-
"Default plist of params to pass to `cider-connect'.
1505-
Recognized keys are :host, :port and :project-dir.")
1503+
(defcustom cider-connect-default-params nil
1504+
"Default plist of params for connecting to an external nREPL server.
1505+
Recognized keys are :host, :port and :project-dir.
1506+
1507+
These are used as arguments to the commands `cider-connect-clj',
1508+
`cider-connect-cljs' and `cider-connect-clj&cljs', in order to bypass
1509+
the corresponding user prompts.
1510+
1511+
This defcustom is intended for use with .dir-locals.el on a per-project basis.
1512+
See `cider-connect-default-cljs-params' in order to specify a separate set of params
1513+
for cljs REPL connections.
1514+
1515+
Note: it is recommended to set the variable `cider-default-cljs-repl'
1516+
instead of specifying the :cljs-repl-type key."
1517+
:type '(plist :key-type
1518+
(choice (const :host)
1519+
(const :port)
1520+
(const :project-dir)))
1521+
:group 'cider)
1522+
1523+
(defcustom cider-connect-default-cljs-params nil
1524+
"Default plist of params for connecting to a ClojureScript REPL.
1525+
Recognized keys are :host, :port and :project-dir.
1526+
1527+
If non-nil, overrides `cider-connect-default-params' for the commands
1528+
`cider-connect-cljs' and (the latter half of) `cider-connect-clj&cljs'.
1529+
1530+
Note: it is recommended to set the variable `cider-default-cljs-repl'
1531+
instead of specifying the :cljs-repl-type key."
1532+
:type '(plist :key-type
1533+
(choice (const :host)
1534+
(const :port)
1535+
(const :project-dir)))
1536+
:group 'cider)
15061537

15071538
;;;###autoload
15081539
(defun cider-connect-clj (&optional params)
15091540
"Initialize a Clojure connection to an nREPL server.
15101541
PARAMS is a plist optionally containing :host, :port and :project-dir.
15111542
If nil, use the default parameters in `cider-connect-default-params'.
1512-
When called interactively with a prefix argument, prompt for all the
1513-
parameters."
1543+
1544+
With the prefix argument, prompt for all the parameters regardless of
1545+
their supplied or default values."
15141546
(interactive "P")
15151547
(cider-nrepl-connect
1516-
;; Make sure to copy the list, as the following steps will mutate it
1517-
(thread-first (or params (copy-sequence cider-connect-default-params))
1548+
(thread-first (or params cider-connect-default-params)
1549+
(copy-sequence) ;; Note: the following steps mutate the list
1550+
(map-delete :cljs-repl-type)
15181551
(cider--update-project-dir)
15191552
(cider--update-host-port)
15201553
(cider--check-existing-session)
@@ -1527,12 +1560,17 @@ parameters."
15271560
"Initialize a ClojureScript connection to an nREPL server.
15281561
PARAMS is a plist optionally containing :host, :port, :project-dir and
15291562
:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc).
1563+
If nil, use the default parameters in `cider-connect-default-params' or
1564+
`cider-connect-default-cljs-params'.
15301565
1531-
On prefix, prompt for all the
1532-
parameters regardless of their supplied or default values."
1566+
With the prefix argument, prompt for all the parameters regardless of
1567+
their supplied or default values."
15331568
(interactive "P")
15341569
(cider-nrepl-connect
1535-
(thread-first params
1570+
(thread-first (or params
1571+
cider-connect-default-cljs-params
1572+
cider-connect-default-params)
1573+
(copy-sequence)
15361574
(cider--update-project-dir)
15371575
(cider--update-host-port)
15381576
(cider--check-existing-session)

0 commit comments

Comments
 (0)