Skip to content

Commit 9ad6b03

Browse files
committed
Add separate defcustom for cljs connection params
1 parent 0b97151 commit 9ad6b03

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
@@ -1502,21 +1502,54 @@ server buffer, in which case a new session for that server is created."
15021502
(plist-put :session-name ses-name)
15031503
(plist-put :repl-type 'cljs)))))
15041504

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

15091540
;;;###autoload
15101541
(defun cider-connect-clj (&optional params)
15111542
"Initialize a Clojure connection to an nREPL server.
15121543
PARAMS is a plist optionally containing :host, :port and :project-dir.
15131544
If nil, use the default parameters in `cider-connect-default-params'.
1514-
When called interactively with a prefix argument, prompt for all the
1515-
parameters."
1545+
1546+
With the prefix argument, prompt for all the parameters regardless of
1547+
their supplied or default values."
15161548
(interactive "P")
15171549
(cider-nrepl-connect
1518-
;; Make sure to copy the list, as the following steps will mutate it
1519-
(thread-first (or params (copy-sequence cider-connect-default-params))
1550+
(thread-first (or params cider-connect-default-params)
1551+
(copy-sequence) ;; Note: the following steps mutate the list
1552+
(map-delete :cljs-repl-type)
15201553
(cider--update-project-dir)
15211554
(cider--update-host-port)
15221555
(cider--check-existing-session)
@@ -1529,12 +1562,17 @@ parameters."
15291562
"Initialize a ClojureScript connection to an nREPL server.
15301563
PARAMS is a plist optionally containing :host, :port, :project-dir and
15311564
:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc).
1565+
If nil, use the default parameters in `cider-connect-default-params' or
1566+
`cider-connect-default-cljs-params'.
15321567
1533-
On prefix, prompt for all the
1534-
parameters regardless of their supplied or default values."
1568+
With the prefix argument, prompt for all the parameters regardless of
1569+
their supplied or default values."
15351570
(interactive "P")
15361571
(cider-nrepl-connect
1537-
(thread-first params
1572+
(thread-first (or params
1573+
cider-connect-default-cljs-params
1574+
cider-connect-default-params)
1575+
(copy-sequence)
15381576
(cider--update-project-dir)
15391577
(cider--update-host-port)
15401578
(cider--check-existing-session)

0 commit comments

Comments
 (0)