Skip to content

Commit 89347cc

Browse files
yuhan0bbatsov
authored andcommitted
Add separate defcustom for cljs connection params
1 parent a2c2142 commit 89347cc

File tree

1 file changed

+48
-10
lines changed

1 file changed

+48
-10
lines changed

cider.el

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,21 +1443,54 @@ server buffer, in which case a new session for that server is created."
14431443
(plist-put :session-name ses-name)
14441444
(plist-put :repl-type 'cljs)))))
14451445

1446-
(defvar-local cider-connect-default-params nil
1447-
"Default plist of params to pass to `cider-connect'.
1448-
Recognized keys are :host, :port and :project-dir.")
1446+
(defcustom cider-connect-default-params nil
1447+
"Default plist of params for connecting to an external nREPL server.
1448+
Recognized keys are :host, :port and :project-dir.
1449+
1450+
These are used as arguments to the commands `cider-connect-clj',
1451+
`cider-connect-cljs' and `cider-connect-clj&cljs', in order to bypass
1452+
the corresponding user prompts.
1453+
1454+
This defcustom is intended for use with .dir-locals.el on a per-project basis.
1455+
See `cider-connect-default-cljs-params' in order to specify a separate set of params
1456+
for cljs REPL connections.
1457+
1458+
Note: it is recommended to set the variable `cider-default-cljs-repl'
1459+
instead of specifying the :cljs-repl-type key."
1460+
:type '(plist :key-type
1461+
(choice (const :host)
1462+
(const :port)
1463+
(const :project-dir)))
1464+
:group 'cider)
1465+
1466+
(defcustom cider-connect-default-cljs-params nil
1467+
"Default plist of params for connecting to a ClojureScript REPL.
1468+
Recognized keys are :host, :port and :project-dir.
1469+
1470+
If non-nil, overrides `cider-connect-default-params' for the commands
1471+
`cider-connect-cljs' and (the latter half of) `cider-connect-clj&cljs'.
1472+
1473+
Note: it is recommended to set the variable `cider-default-cljs-repl'
1474+
instead of specifying the :cljs-repl-type key."
1475+
:type '(plist :key-type
1476+
(choice (const :host)
1477+
(const :port)
1478+
(const :project-dir)))
1479+
:group 'cider)
14491480

14501481
;;;###autoload
14511482
(defun cider-connect-clj (&optional params)
14521483
"Initialize a Clojure connection to an nREPL server.
14531484
PARAMS is a plist optionally containing :host, :port and :project-dir.
14541485
If nil, use the default parameters in `cider-connect-default-params'.
1455-
When called interactively with a prefix argument, prompt for all the
1456-
parameters."
1486+
1487+
With the prefix argument, prompt for all the parameters regardless of
1488+
their supplied or default values."
14571489
(interactive "P")
14581490
(cider-nrepl-connect
1459-
;; Make sure to copy the list, as the following steps will mutate it
1460-
(thread-first (or params (copy-sequence cider-connect-default-params))
1491+
(thread-first (or params cider-connect-default-params)
1492+
(copy-sequence) ;; Note: the following steps mutate the list
1493+
(map-delete :cljs-repl-type)
14611494
(cider--update-project-dir)
14621495
(cider--update-host-port)
14631496
(cider--check-existing-session)
@@ -1470,12 +1503,17 @@ parameters."
14701503
"Initialize a ClojureScript connection to an nREPL server.
14711504
PARAMS is a plist optionally containing :host, :port, :project-dir and
14721505
:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc).
1506+
If nil, use the default parameters in `cider-connect-default-params' or
1507+
`cider-connect-default-cljs-params'.
14731508
1474-
On prefix, prompt for all the
1475-
parameters regardless of their supplied or default values."
1509+
With the prefix argument, prompt for all the parameters regardless of
1510+
their supplied or default values."
14761511
(interactive "P")
14771512
(cider-nrepl-connect
1478-
(thread-first params
1513+
(thread-first (or params
1514+
cider-connect-default-cljs-params
1515+
cider-connect-default-params)
1516+
(copy-sequence)
14791517
(cider--update-project-dir)
14801518
(cider--update-host-port)
14811519
(cider--check-existing-session)

0 commit comments

Comments
 (0)