Skip to content

Commit 49de783

Browse files
committed
Consolidate jack-in defcustoms into cider-jack-in.el
cider.el's customization section still held all the jack-in-only defcustoms: per-tool command/parameter pairs and the cross-tool jack-in toggles. Move them next to the code that actually uses them. Moved (~17 defcustoms): - Per-tool command/parameter pairs for lein, clojure-cli (incl. aliases / global-aliases), shadow-cljs, gradle, babashka, nbb, and basilisp. - Cross-tool toggles: cider-jack-in-default, cider-preferred-build-tool, cider-allow-jack-in-without-project, cider-inject-dependencies-at-jack-in, cider-enable-nrepl-jvmti-agent. Each gets `:group 'cider' since the defgroup stays in cider.el, but the in-Customize grouping is unchanged for users. Removing the now-redundant `(defvar ...)` forward declarations from cider-jack-in.el's prologue is the second half of the diff. cider.el's customization section is now ~50 lines of project metadata, connect hooks, and `cider-version`; jack-in's user-tunable knobs all live with the jack-in code. cider.el drops from 773 to 577 lines.
1 parent 9faf3af commit 49de783

2 files changed

Lines changed: 226 additions & 202 deletions

File tree

lisp/cider-jack-in.el

Lines changed: 226 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@
5050

5151
;; Defined in cider.el; declared here to keep cider-jack-in.el free of a
5252
;; circular require on cider.
53-
(defvar cider-clojure-cli-command)
54-
(defvar cider-clojure-cli-aliases)
55-
(defvar cider-clojure-cli-global-aliases)
56-
(defvar cider-enable-nrepl-jvmti-agent)
57-
(defvar cider-preferred-build-tool)
58-
(defvar cider-jack-in-default)
5953
(declare-function cider--update-params "cider")
6054
(declare-function cider-connect-sibling-clj "cider")
6155
(declare-function cider-connect-sibling-cljs "cider")
@@ -66,6 +60,232 @@
6660
(declare-function cider--update-cljs-type "cider-cljs")
6761
(declare-function cider--check-cljs "cider-cljs")
6862

63+
64+
;;; Build tool commands
65+
66+
(defcustom cider-lein-command
67+
"lein"
68+
"The command used to execute Leiningen."
69+
:type 'string
70+
:group 'cider)
71+
72+
(defcustom cider-lein-parameters
73+
"repl :headless :host localhost"
74+
"Params passed to Leiningen to start an nREPL server via `cider-jack-in'."
75+
:type 'string
76+
:group 'cider
77+
:safe #'stringp)
78+
79+
(defcustom cider-clojure-cli-command nil
80+
"The command used to execute clojure with tools.deps.
81+
When nil (the default), CIDER auto-detects the command at jack-in time:
82+
\"clojure\" if available on PATH, otherwise \"powershell\" on Windows.
83+
This avoids freezing the auto-detection result at package load time.
84+
85+
Don't use clj here, as it doesn't work when spawned from Emacs due to it
86+
using rlwrap."
87+
:type '(choice (const :tag "Auto-detect" nil)
88+
(string :tag "Custom command"))
89+
:group 'cider
90+
:safe (lambda (s) (or (null s) (stringp s)))
91+
:package-version '(cider . "0.17.0"))
92+
93+
(defcustom cider-clojure-cli-parameters
94+
nil
95+
"Params passed to clojure cli to start an nREPL server via `cider-jack-in'."
96+
:type 'string
97+
:group 'cider
98+
:safe #'stringp
99+
:package-version '(cider . "1.8.0"))
100+
101+
(defcustom cider-clojure-cli-aliases
102+
nil
103+
"A list of aliases to include when using the clojure cli.
104+
Alias names should be of the form \":foo:bar\".
105+
Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases
106+
then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
107+
:type 'string
108+
:group 'cider
109+
:safe #'stringp
110+
:package-version '(cider . "1.1"))
111+
112+
(defcustom cider-clojure-cli-global-aliases
113+
nil
114+
"Global aliases to include when jacking in with the clojure CLI.
115+
This value should be a string of the form \":foo:bar\", and
116+
will be prepended to the value of `cider-clojure-cli-aliases'.
117+
Alias names should be of the form \":foo:bar\".
118+
Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases
119+
then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
120+
:type 'string
121+
:group 'cider
122+
:safe #'stringp
123+
:package-version '(cider . "1.14"))
124+
125+
(defcustom cider-shadow-cljs-command
126+
"npx shadow-cljs"
127+
"The command used to execute shadow-cljs.
128+
129+
By default we favor the project-specific shadow-cljs over the system-wide."
130+
:type 'string
131+
:group 'cider
132+
:safe #'stringp
133+
:package-version '(cider . "0.17.0"))
134+
135+
(defcustom cider-shadow-cljs-parameters
136+
"server"
137+
"Params passed to shadow-cljs to start an nREPL server via `cider-jack-in'."
138+
:type 'string
139+
:group 'cider
140+
:safe #'stringp
141+
:package-version '(cider . "0.17.0"))
142+
143+
(defcustom cider-gradle-command
144+
"./gradlew"
145+
"The command used to execute Gradle."
146+
:type 'string
147+
:group 'cider
148+
:safe #'stringp
149+
:package-version '(cider . "0.10.0"))
150+
151+
(defcustom cider-gradle-parameters
152+
"clojureRepl"
153+
"Params passed to gradle to start an nREPL server via `cider-jack-in'."
154+
:type 'string
155+
:group 'cider
156+
:safe #'stringp
157+
:package-version '(cider . "0.10.0"))
158+
159+
(defcustom cider-babashka-command
160+
"bb"
161+
"The command used to execute Babashka."
162+
:type 'string
163+
:group 'cider
164+
:safe #'stringp
165+
:package-version '(cider . "1.2.0"))
166+
167+
(defcustom cider-babashka-parameters
168+
"nrepl-server localhost:0"
169+
"Params passed to babashka to start an nREPL server via `cider-jack-in'."
170+
:type 'string
171+
:group 'cider
172+
:safe #'stringp
173+
:package-version '(cider . "1.2.0"))
174+
175+
(defcustom cider-nbb-command
176+
"nbb"
177+
"The command used to execute nbb."
178+
:type 'string
179+
:group 'cider
180+
:safe #'stringp
181+
:package-version '(cider . "1.6.0"))
182+
183+
(defcustom cider-nbb-parameters
184+
"nrepl-server"
185+
"Params passed to nbb to start an nREPL server via `cider-jack-in'."
186+
:type 'string
187+
:group 'cider
188+
:safe #'stringp
189+
:package-version '(cider . "1.6.0"))
190+
191+
(defcustom cider-basilisp-command
192+
"basilisp"
193+
"The command used to execute Basilisp.
194+
195+
If Basilisp is installed in a virtual environment, update this to the
196+
full path of the Basilisp executable within that virtual environment."
197+
:type 'string
198+
:group 'cider
199+
:safe #'stringp
200+
:package-version '(cider . "1.14.0"))
201+
202+
(defcustom cider-basilisp-parameters
203+
"nrepl-server"
204+
"Params passed to Basilisp to start an nREPL server via `cider-jack-in'."
205+
:type 'string
206+
:group 'cider
207+
:safe #'stringp
208+
:package-version '(cider . "1.14.0"))
209+
210+
211+
;;; Jack-in defaults and toggles
212+
213+
(defcustom cider-jack-in-default nil
214+
"The default tool to use when doing `cider-jack-in' outside a project.
215+
This value is consulted when no identifying file types (e.g. project.clj
216+
for Leiningen or deps.edn for the Clojure CLI) are found.
217+
218+
When nil (the default), CIDER auto-detects at jack-in time, picking
219+
`clojure-cli' when \"clojure\" is on PATH, else `lein'. Set this
220+
explicitly to skip the auto-detection."
221+
:type '(choice (const :tag "Auto-detect" nil)
222+
(const lein)
223+
(const clojure-cli)
224+
(const shadow-cljs)
225+
(const gradle)
226+
(const babashka)
227+
(const nbb)
228+
(const basilisp))
229+
:group 'cider
230+
:safe #'symbolp
231+
:package-version '(cider . "0.9.0"))
232+
233+
(defcustom cider-preferred-build-tool
234+
nil
235+
"Allow choosing a build system when there are many.
236+
When there are project markers from multiple build systems (e.g. lein and
237+
clojure-cli) the user is prompted to select one of them. When non-nil, this
238+
variable will suppress this behavior and will select whatever build system
239+
is indicated by the variable if present. Note, this is only when CIDER
240+
cannot decide which of many build systems to use and will never override a
241+
command when there is no ambiguity."
242+
:type '(choice (const lein)
243+
(const clojure-cli)
244+
(const shadow-cljs)
245+
(const gradle)
246+
(const babashka)
247+
(const nbb)
248+
(const basilisp)
249+
(const :tag "Always ask" nil))
250+
:group 'cider
251+
:safe #'symbolp
252+
:package-version '(cider . "0.13.0"))
253+
254+
(defcustom cider-allow-jack-in-without-project 'warn
255+
"Controls what happens when doing `cider-jack-in' outside a project.
256+
When set to `warn' (default) you'd prompted to confirm the command.
257+
When set to t `cider-jack-in' will quietly continue.
258+
When set to nil `cider-jack-in' will fail."
259+
:type '(choice (const :tag "always" t)
260+
(const warn)
261+
(const :tag "never" nil))
262+
:group 'cider
263+
:safe #'symbolp
264+
:package-version '(cider . "0.15.0"))
265+
266+
(defcustom cider-inject-dependencies-at-jack-in t
267+
"When nil, do not inject repl dependencies at `cider-jack-in' time.
268+
The repl dependendcies are most likely to be nREPL middlewares."
269+
:type 'boolean
270+
:group 'cider
271+
:safe #'booleanp
272+
:version '(cider . "0.11.0"))
273+
274+
(defcustom cider-enable-nrepl-jvmti-agent nil
275+
"When t, add `-Djdk.attach.allowAttachSelf' to the command line arguments.
276+
This is required for nREPL's bundled JVMTI agent to load, which in turn
277+
is required for eval interruption (e.g. \\[cider-interrupt]) to work
278+
reliably on Java 21 and later -- earlier JDKs do not need it. Disabled
279+
by default because attaching the agent has a small startup cost and
280+
some hardened environments forbid self-attach."
281+
:type 'boolean
282+
:group 'cider
283+
:safe #'booleanp
284+
:version '(cider . "1.15.0"))
285+
286+
287+
;;; Jack-in dependencies
288+
69289
(defvar cider-jack-in-dependencies nil
70290
"List of dependencies where elements are lists of artifact name and version.")
71291
(put 'cider-jack-in-dependencies 'risky-local-variable t)

0 commit comments

Comments
 (0)