Skip to content

Commit 5631d60

Browse files
Reify cider-cljs-pending separate from repl-type (#3291)
This pull request addresses #3287 by separating the concept of a repl type from the concept of pending cljs upgrade status. The pending variable is now set when the repl is initialized, and it is set to nil when we are sure that we have a cljs repl in cider-repl--state-handler.
1 parent 9acd4d0 commit 5631d60

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Changes
1212

1313
- Bump the injected nREPL version to 1.0.
14+
- [#3291](https://github.com/clojure-emacs/cider/pull/3291): **Remove** the `'cljs-pending` `repl-type`. It is replaced by `cider-repl-cljs-upgrade-pending`.
1415

1516
### Bugs fixed
1617

cider-connection.el

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ See `cider-connection-capabilities'."
315315
(_ '()))
316316
(when
317317
(or
318-
(member cider-repl-type '(cljs pending-cljs))
318+
(eq cider-repl-type 'cljs)
319319
;; This check is currently basically for nbb.
320320
;; See `cider-sync-tooling-eval', but it is defined on a higher layer
321321
(nrepl-dict-get
322-
(nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) (cider-current-ns) 'tooling)
322+
(nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) nil 'tooling)
323323
"value"))
324324
'(cljs))))))
325325

@@ -762,10 +762,17 @@ Session name can be customized with `cider-session-name-template'."
762762
(defvar-local cider-repl-type nil
763763
"The type of this REPL buffer, usually either clj or cljs.")
764764

765+
(defvar-local cider-repl-cljs-upgrade-pending nil
766+
"Is the cljs repl currently pending?")
767+
765768
(defun cider-repl-type (repl-buffer)
766769
"Get REPL-BUFFER's type."
767770
(buffer-local-value 'cider-repl-type repl-buffer))
768771

772+
(defun cider-cljs-pending-p (repl-buffer)
773+
"Returns non nil when REPL-BUFFER is currently a pending cljs repl."
774+
(buffer-local-value 'cider-repl-cljs-upgrade-pending repl-buffer))
775+
769776
(defun cider-repl-type-for-buffer (&optional buffer)
770777
"Return the matching connection type (clj or cljs) for BUFFER.
771778
BUFFER defaults to the `current-buffer'. In cljc buffers return
@@ -812,13 +819,13 @@ PARAMS is a plist as received by `cider-repl-create'."
812819
(let* ((proj-dir (plist-get params :project-dir))
813820
(host (plist-get params :host))
814821
(port (plist-get params :port))
815-
(cljsp (member (plist-get params :repl-type) '(cljs pending-cljs)))
822+
(cljsp (member (plist-get params :repl-type) '(cljs)))
816823
(scored-repls
817824
(delq nil
818825
(mapcar (lambda (b)
819826
(let ((bparams (cider--gather-connect-params nil b)))
820827
(when (eq cljsp (member (plist-get bparams :repl-type)
821-
'(cljs pending-cljs)))
828+
'(cljs)))
822829
(cons (buffer-name b)
823830
(+
824831
(if (equal proj-dir (plist-get bparams :project-dir)) 8 0)
@@ -866,8 +873,9 @@ function with the repl buffer set as current."
866873
mode-name nil
867874
cider-session-name ses-name
868875
nrepl-project-dir (plist-get params :project-dir)
869-
;; REPLs start with clj and then "upgrade" to a different type
876+
;; Cljs repls are pending until they are upgraded. See cider-repl--state-handler
870877
cider-repl-type (plist-get params :repl-type)
878+
cider-repl-cljs-upgrade-pending (plist-get params :cider-repl-cljs-upgrade-pending)
871879
;; ran at the end of cider--connected-handler
872880
cider-repl-init-function (plist-get params :repl-init-function)
873881
cider-launch-params params)
@@ -985,7 +993,9 @@ throw an error if no linked session exists."
985993
(sesman-ensure-session 'CIDER)
986994
(sesman-current-session 'CIDER)))))))
987995
(or (seq-filter (lambda (b)
988-
(cider--match-repl-type type b))
996+
(unless
997+
(cider-cljs-pending-p b)
998+
(cider--match-repl-type type b)))
989999
repls)
9901000
(when ensure
9911001
(cider--no-repls-user-error type)))))

cider-repl.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ This cache is stored in the connection buffer.")
224224
(nrepl-dbind-response response (repl-type changed-namespaces)
225225
(when (and repl-type cider-repl-auto-detect-type)
226226
(cider-set-repl-type repl-type))
227+
(when (eq (cider-maybe-intern repl-type) 'cljs)
228+
(setq cider-repl-cljs-upgrade-pending nil))
227229
(unless (nrepl-dict-empty-p changed-namespaces)
228230
(setq cider-repl-ns-cache (nrepl-dict-merge cider-repl-ns-cache changed-namespaces))
229231
(dolist (b (buffer-list))

cider.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ server buffer, in which case a new session for that server is created."
12581258
(cider--update-cljs-type)
12591259
(cider--update-cljs-init-function)
12601260
(plist-put :session-name ses-name)
1261-
(plist-put :repl-type 'pending-cljs)))))
1261+
(plist-put :repl-type 'cljs)
1262+
(plist-put :cider-repl-cljs-upgrade-pending t)))))
12621263

12631264
;;;###autoload
12641265
(defun cider-connect-clj (&optional params)
@@ -1292,7 +1293,8 @@ parameters regardless of their supplied or default values."
12921293
(cider--update-cljs-type)
12931294
(cider--update-cljs-init-function)
12941295
(plist-put :session-name nil)
1295-
(plist-put :repl-type 'pending-cljs))))
1296+
(plist-put :repl-type 'cljs)
1297+
(plist-put :cider-repl-cljs-upgrade-pending t))))
12961298

12971299
;;;###autoload
12981300
(defun cider-connect-clj&cljs (params &optional soft-cljs-start)

0 commit comments

Comments
 (0)