Skip to content

Commit 128bf92

Browse files
committed
Reformat some thread-firsts
This style is closer to Clojure's, and indents consistently across more Emacs versions.
1 parent 5cbca64 commit 128bf92

File tree

1 file changed

+71
-83
lines changed

1 file changed

+71
-83
lines changed

cider.el

Lines changed: 71 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,11 +1344,10 @@ been determined."
13441344
"Fill-in the passed in PARAMS plist needed to start an nREPL server.
13451345
Updates :project-dir and :jack-in-cmd.
13461346
Also checks whether a matching session already exists."
1347-
(thread-first
1348-
params
1349-
(cider--update-project-dir)
1350-
(cider--check-existing-session)
1351-
(cider--update-jack-in-cmd)))
1347+
(thread-first params
1348+
(cider--update-project-dir)
1349+
(cider--check-existing-session)
1350+
(cider--update-jack-in-cmd)))
13521351

13531352
;;;###autoload
13541353
(defun cider-jack-in-clj (params)
@@ -1387,11 +1386,10 @@ these parameters."
13871386
(cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares))
13881387
(orig-buffer (current-buffer)))
13891388
;; cider--update-jack-in-cmd relies indirectly on the above dynamic vars
1390-
(let ((params (thread-first
1391-
params
1392-
(cider--update-project-dir)
1393-
(cider--check-existing-session)
1394-
(cider--update-jack-in-cmd))))
1389+
(let ((params (thread-first params
1390+
(cider--update-project-dir)
1391+
(cider--check-existing-session)
1392+
(cider--update-jack-in-cmd))))
13951393
(nrepl-start-server-process
13961394
(plist-get params :project-dir)
13971395
(plist-get params :jack-in-cmd)
@@ -1417,14 +1415,13 @@ only when the ClojureScript dependencies are met."
14171415
(cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares))
14181416
(orig-buffer (current-buffer)))
14191417
;; cider--update-jack-in-cmd relies indirectly on the above dynamic vars
1420-
(let ((params (thread-first
1421-
params
1422-
(cider--update-project-dir)
1423-
(cider--check-existing-session)
1424-
(cider--update-jack-in-cmd)
1425-
(cider--update-cljs-type)
1426-
;; already asked, don't ask on sibling connect
1427-
(plist-put :do-prompt nil))))
1418+
(let ((params (thread-first params
1419+
(cider--update-project-dir)
1420+
(cider--check-existing-session)
1421+
(cider--update-jack-in-cmd)
1422+
(cider--update-cljs-type)
1423+
;; already asked, don't ask on sibling connect
1424+
(plist-put :do-prompt nil))))
14281425
(nrepl-start-server-process
14291426
(plist-get params :project-dir)
14301427
(plist-get params :jack-in-cmd)
@@ -1449,13 +1446,12 @@ server is created."
14491446
(other-params (cider--gather-connect-params nil other-repl))
14501447
(ses-name (unless (nrepl-server-p other-repl)
14511448
(sesman-session-name-for-object 'CIDER other-repl))))
1452-
(thread-first
1453-
params
1454-
(cider--update-do-prompt)
1455-
(append other-params)
1456-
(plist-put :repl-init-function nil)
1457-
(plist-put :repl-type 'clj)
1458-
(plist-put :session-name ses-name)))))
1449+
(thread-first params
1450+
(cider--update-do-prompt)
1451+
(append other-params)
1452+
(plist-put :repl-init-function nil)
1453+
(plist-put :repl-type 'clj)
1454+
(plist-put :session-name ses-name)))))
14591455

14601456
;;;###autoload
14611457
(defun cider-connect-sibling-cljs (params &optional other-repl)
@@ -1474,14 +1470,13 @@ server buffer, in which case a new session for that server is created."
14741470
(ses-name (unless (nrepl-server-p other-repl)
14751471
(sesman-session-name-for-object 'CIDER other-repl))))
14761472
(cider-nrepl-connect
1477-
(thread-first
1478-
params
1479-
(cider--update-do-prompt)
1480-
(append other-params)
1481-
(cider--update-cljs-type)
1482-
(cider--update-cljs-init-function)
1483-
(plist-put :session-name ses-name)
1484-
(plist-put :repl-type 'cljs)))))
1473+
(thread-first params
1474+
(cider--update-do-prompt)
1475+
(append other-params)
1476+
(cider--update-cljs-type)
1477+
(cider--update-cljs-init-function)
1478+
(plist-put :session-name ses-name)
1479+
(plist-put :repl-type 'cljs)))))
14851480

14861481
;;;###autoload
14871482
(defun cider-connect-clj (&optional params)
@@ -1490,14 +1485,13 @@ PARAMS is a plist optionally containing :host, :port and :project-dir. On
14901485
prefix argument, prompt for all the parameters."
14911486
(interactive "P")
14921487
(cider-nrepl-connect
1493-
(thread-first
1494-
params
1495-
(cider--update-project-dir)
1496-
(cider--update-host-port)
1497-
(cider--check-existing-session)
1498-
(plist-put :repl-init-function nil)
1499-
(plist-put :session-name nil)
1500-
(plist-put :repl-type 'clj))))
1488+
(thread-first params
1489+
(cider--update-project-dir)
1490+
(cider--update-host-port)
1491+
(cider--check-existing-session)
1492+
(plist-put :repl-init-function nil)
1493+
(plist-put :session-name nil)
1494+
(plist-put :repl-type 'clj))))
15011495

15021496
;;;###autoload
15031497
(defun cider-connect-cljs (&optional params)
@@ -1509,15 +1503,14 @@ On prefix, prompt for all the
15091503
parameters regardless of their supplied or default values."
15101504
(interactive "P")
15111505
(cider-nrepl-connect
1512-
(thread-first
1513-
params
1514-
(cider--update-project-dir)
1515-
(cider--update-host-port)
1516-
(cider--check-existing-session)
1517-
(cider--update-cljs-type)
1518-
(cider--update-cljs-init-function)
1519-
(plist-put :session-name nil)
1520-
(plist-put :repl-type 'cljs))))
1506+
(thread-first params
1507+
(cider--update-project-dir)
1508+
(cider--update-host-port)
1509+
(cider--check-existing-session)
1510+
(cider--update-cljs-type)
1511+
(cider--update-cljs-init-function)
1512+
(plist-put :session-name nil)
1513+
(plist-put :repl-type 'cljs))))
15211514

15221515
;;;###autoload
15231516
(defun cider-connect-clj&cljs (params &optional soft-cljs-start)
@@ -1526,16 +1519,14 @@ PARAMS is a plist optionally containing :host, :port, :project-dir and
15261519
:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). When SOFT-CLJS-START is
15271520
non-nil, don't start if ClojureScript requirements are not met."
15281521
(interactive "P")
1529-
(let* ((params (thread-first
1530-
params
1531-
(cider--update-project-dir)
1532-
(cider--update-host-port)
1533-
(cider--check-existing-session)
1534-
(cider--update-cljs-type)))
1535-
(clj-params (thread-first
1536-
params
1537-
copy-sequence
1538-
(map-delete :cljs-repl-type)))
1522+
(let* ((params (thread-first params
1523+
(cider--update-project-dir)
1524+
(cider--update-host-port)
1525+
(cider--check-existing-session)
1526+
(cider--update-cljs-type)))
1527+
(clj-params (thread-first params
1528+
copy-sequence
1529+
(map-delete :cljs-repl-type)))
15391530
(clj-repl (cider-connect-clj clj-params)))
15401531
(when (if soft-cljs-start
15411532
(cider--check-cljs (plist-get params :cljs-repl-type) 'no-error)
@@ -1605,10 +1596,9 @@ Params is a plist with the following keys (non-exhaustive)
16051596
(setq-local buffer-file-name nil))
16061597
(let ((default-directory proj-dir))
16071598
(hack-dir-local-variables-non-file-buffer)
1608-
(thread-first
1609-
params
1610-
(plist-put :project-dir proj-dir)
1611-
(plist-put :--context-buffer (current-buffer)))))))))
1599+
(thread-first params
1600+
(plist-put :project-dir proj-dir)
1601+
(plist-put :--context-buffer (current-buffer)))))))))
16121602

16131603
(defun cider--update-cljs-type (params)
16141604
"Update :cljs-repl-type in PARAMS."
@@ -1704,10 +1694,9 @@ PARAMS is a plist with the following keys (non-exhaustive list)
17041694
(cider-select-endpoint)))))
17051695
(if (equal "local-unix-domain-socket" (car endpoint))
17061696
(plist-put params :socket-file (cdr endpoint))
1707-
(thread-first
1708-
params
1709-
(plist-put :host (car endpoint))
1710-
(plist-put :port (cdr endpoint)))))))
1697+
(thread-first params
1698+
(plist-put :host (car endpoint))
1699+
(plist-put :port (cdr endpoint)))))))
17111700

17121701
(defun cider--update-cljs-init-function (params)
17131702
"Update repl type and any init PARAMS for cljs connections.
@@ -1728,21 +1717,20 @@ over to cljs.
17281717
(if (null repl-init-form)
17291718
(plist-put params :cider-repl-cljs-upgrade-pending nil)
17301719

1731-
(thread-first
1732-
params
1733-
(plist-put :cider-repl-cljs-upgrade-pending t)
1734-
(plist-put :repl-init-function
1735-
(lambda ()
1736-
(cider--check-cljs cljs-type)
1737-
(cider-nrepl-send-request
1738-
(list "op" "eval"
1739-
"ns" (cider-current-ns)
1740-
"code" repl-init-form)
1741-
(cider-repl-handler (current-buffer)))
1742-
(when (and (buffer-live-p nrepl-server-buffer)
1743-
cider-offer-to-open-cljs-app-in-browser)
1744-
(cider--offer-to-open-app-in-browser nrepl-server-buffer))))
1745-
(plist-put :repl-init-form repl-init-form))))))
1720+
(thread-first params
1721+
(plist-put :cider-repl-cljs-upgrade-pending t)
1722+
(plist-put :repl-init-function
1723+
(lambda ()
1724+
(cider--check-cljs cljs-type)
1725+
(cider-nrepl-send-request
1726+
(list "op" "eval"
1727+
"ns" (cider-current-ns)
1728+
"code" repl-init-form)
1729+
(cider-repl-handler (current-buffer)))
1730+
(when (and (buffer-live-p nrepl-server-buffer)
1731+
cider-offer-to-open-cljs-app-in-browser)
1732+
(cider--offer-to-open-app-in-browser nrepl-server-buffer))))
1733+
(plist-put :repl-init-form repl-init-form))))))
17461734

17471735
(defun cider--check-existing-session (params)
17481736
"Ask for confirmation if a session with similar PARAMS already exists.

0 commit comments

Comments
 (0)