Skip to content

Commit 417eafa

Browse files
committed
Move four more cljs-only items from cider.el to cider-cljs.el
Follow-up to the cider-cljs.el extraction. Pulls four small cljs-only forms out of cider.el so cider-cljs.el is the single home for cljs concerns: - cider-offer-to-open-cljs-app-in-browser - the toggle for the browser-opener that already lives here. - cider-connect-default-cljs-params - the cljs counterpart of cider-connect-default-params. - cider--update-cljs-type - tiny param updater that only touches cider-select-cljs-repl / cider-default-cljs-repl, both already here. - cider--with-cljs-jack-in-deps - macro that let-binds the cljs jack-in vars (defined in cider-jack-in.el) for the duration of jack-in-cljs flows. cider-cljs.el now requires cider-jack-in for the macro's references, and forward-declares cider--update-do-prompt (which stays in cider.el). cider.el drops 50 lines, cider-cljs.el gains 55.
1 parent 5da43e7 commit 417eafa

2 files changed

Lines changed: 55 additions & 50 deletions

File tree

lisp/cider-cljs.el

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@
4242
(require 'clojure-mode)
4343

4444
(require 'cider-client)
45+
(require 'cider-jack-in)
4546
(require 'nrepl-dict)
4647

48+
;; Defined in cider.el; used by `cider--update-cljs-type'.
49+
(declare-function cider--update-do-prompt "cider")
50+
4751
(defcustom cider-check-cljs-repl-requirements t
4852
"When non-nil will run the requirement checks for the different cljs repls.
4953
Generally you should not disable this unless you run into some faulty check."
@@ -375,6 +379,13 @@ nil."
375379
(cider-verify-clojurescript-is-present)
376380
(cider-verify-cljs-repl-requirements cljs-type)))
377381

382+
(defcustom cider-offer-to-open-cljs-app-in-browser t
383+
"When nil, do not offer to open ClojureScript apps in a browser on connect."
384+
:type 'boolean
385+
:group 'cider
386+
:safe #'booleanp
387+
:version '(cider . "0.15.0"))
388+
378389
(defun cider--offer-to-open-app-in-browser (server-buf)
379390
"Look for a server address in SERVER-BUF and offer to open it."
380391
(when (buffer-live-p server-buf)
@@ -386,6 +397,50 @@ nil."
386397
(when (y-or-n-p (format "Visit ‘%s’ in a browser? " url))
387398
(browse-url url)))))))
388399

400+
(defcustom cider-connect-default-cljs-params nil
401+
"Default plist of params for connecting to a ClojureScript REPL.
402+
Recognized keys are :host, :port and :project-dir.
403+
404+
If non-nil, overrides `cider-connect-default-params' for the commands
405+
`cider-connect-cljs' and (the latter half of) `cider-connect-clj&cljs'.
406+
407+
Note: it is recommended to set the variable `cider-default-cljs-repl'
408+
instead of specifying the :cljs-repl-type key."
409+
:type '(plist :key-type
410+
(choice (const :host)
411+
(const :port)
412+
(const :project-dir)))
413+
:group 'cider)
414+
415+
(defun cider--update-cljs-type (params)
416+
"Update :cljs-repl-type in PARAMS."
417+
(with-current-buffer (or (plist-get params :--context-buffer)
418+
(current-buffer))
419+
(let ((params (cider--update-do-prompt params))
420+
(inferred-type (or (plist-get params :cljs-repl-type)
421+
cider-default-cljs-repl)))
422+
(plist-put params :cljs-repl-type
423+
(if (plist-get params :do-prompt)
424+
(cider-select-cljs-repl inferred-type)
425+
(or inferred-type
426+
(cider-select-cljs-repl)))))))
427+
428+
(defmacro cider--with-cljs-jack-in-deps (&rest body)
429+
"Run BODY with the cljs jack-in deps appended to the regular ones.
430+
`cider--update-jack-in-cmd' picks up these dynamic vars indirectly when
431+
constructing the jack-in command, so they must be in effect for the
432+
duration of the param-update pipeline."
433+
(declare (indent 0) (debug t))
434+
`(let ((cider-jack-in-dependencies
435+
(append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
436+
(cider-jack-in-lein-plugins
437+
(append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins))
438+
(cider-jack-in-nrepl-middlewares
439+
(append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares)))
440+
,@body))
441+
442+
(put 'cider--with-cljs-jack-in-deps 'lisp-indent-function 0)
443+
389444
(provide 'cider-cljs)
390445

391446
;;; cider-cljs.el ends here

lisp/cider.el

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,6 @@ some hardened environments forbid self-attach."
328328
:safe #'booleanp
329329
:version '(cider . "1.15.0"))
330330

331-
(defcustom cider-offer-to-open-cljs-app-in-browser t
332-
"When nil, do not offer to open ClojureScript apps in a browser on connect."
333-
:type 'boolean
334-
:safe #'booleanp
335-
:version '(cider . "0.15.0"))
336-
337331
(defvar cider-ps-running-lein-nrepls-command "ps u | grep leiningen"
338332
"Process snapshot command used in `cider-locate-running-nrepl-ports'.")
339333

@@ -543,22 +537,6 @@ Also checks whether a matching session already exists."
543537
(cider--check-existing-session)
544538
(cider--update-jack-in-cmd)))
545539

546-
(defmacro cider--with-cljs-jack-in-deps (&rest body)
547-
"Run BODY with the cljs jack-in deps appended to the regular ones.
548-
`cider--update-jack-in-cmd' picks up these dynamic vars indirectly when
549-
constructing the jack-in command, so they must be in effect for the
550-
duration of the param-update pipeline."
551-
(declare (indent 0) (debug t))
552-
`(let ((cider-jack-in-dependencies
553-
(append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
554-
(cider-jack-in-lein-plugins
555-
(append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins))
556-
(cider-jack-in-nrepl-middlewares
557-
(append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares)))
558-
,@body))
559-
560-
(put 'cider--with-cljs-jack-in-deps 'lisp-indent-function 0)
561-
562540
;;;###autoload
563541
(defun cider-jack-in-clj (params)
564542
"Start an nREPL server for the current project and connect to it.
@@ -681,21 +659,6 @@ This defcustom is intended for use with .dir-locals.el on a per-project basis.
681659
See `cider-connect-default-cljs-params' in order to specify a separate set
682660
of params for cljs REPL connections.
683661
684-
Note: it is recommended to set the variable `cider-default-cljs-repl'
685-
instead of specifying the :cljs-repl-type key."
686-
:type '(plist :key-type
687-
(choice (const :host)
688-
(const :port)
689-
(const :project-dir)))
690-
:group 'cider)
691-
692-
(defcustom cider-connect-default-cljs-params nil
693-
"Default plist of params for connecting to a ClojureScript REPL.
694-
Recognized keys are :host, :port and :project-dir.
695-
696-
If non-nil, overrides `cider-connect-default-params' for the commands
697-
`cider-connect-cljs' and (the latter half of) `cider-connect-clj&cljs'.
698-
699662
Note: it is recommended to set the variable `cider-default-cljs-repl'
700663
instead of specifying the :cljs-repl-type key."
701664
:type '(plist :key-type
@@ -839,19 +802,6 @@ Params is a plist with the following keys (non-exhaustive)
839802
(plist-put :project-dir proj-dir)
840803
(plist-put :--context-buffer (current-buffer)))))))))
841804

842-
(defun cider--update-cljs-type (params)
843-
"Update :cljs-repl-type in PARAMS."
844-
(with-current-buffer (or (plist-get params :--context-buffer)
845-
(current-buffer))
846-
(let ((params (cider--update-do-prompt params))
847-
(inferred-type (or (plist-get params :cljs-repl-type)
848-
cider-default-cljs-repl)))
849-
(plist-put params :cljs-repl-type
850-
(if (plist-get params :do-prompt)
851-
(cider-select-cljs-repl inferred-type)
852-
(or inferred-type
853-
(cider-select-cljs-repl)))))))
854-
855805
(defcustom cider-edit-jack-in-command nil
856806
"When truthy allow the user to edit the command."
857807
:type 'boolean

0 commit comments

Comments
 (0)