emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/cider 5631d60295: Reify cider-cljs-pending separate from r


From: ELPA Syncer
Subject: [nongnu] elpa/cider 5631d60295: Reify cider-cljs-pending separate from repl-type (#3291)
Date: Thu, 15 Dec 2022 08:58:50 -0500 (EST)

branch: elpa/cider
commit 5631d60295a623cbb161c76b70dac1305b1c0987
Author: Benjamin <38900087+benjamin-asdf@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    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.
---
 CHANGELOG.md        |  1 +
 cider-connection.el | 22 ++++++++++++++++------
 cider-repl.el       |  2 ++
 cider.el            |  6 ++++--
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index aeff6ca039..9c761d94b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 ### Changes
 
 - Bump the injected nREPL version to 1.0.
+- [#3291](https://github.com/clojure-emacs/cider/pull/3291): **Remove** the 
`'cljs-pending` `repl-type`. It is replaced by 
`cider-repl-cljs-upgrade-pending`.
 
 ### Bugs fixed
 
diff --git a/cider-connection.el b/cider-connection.el
index c4f7a4d914..147199cbc3 100644
--- a/cider-connection.el
+++ b/cider-connection.el
@@ -315,11 +315,11 @@ See `cider-connection-capabilities'."
              (_ '()))
            (when
                (or
-                (member cider-repl-type '(cljs pending-cljs))
+                (eq cider-repl-type 'cljs)
                 ;; This check is currently basically for nbb.
                 ;; See `cider-sync-tooling-eval', but it is defined on a 
higher layer
                 (nrepl-dict-get
-                 (nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) 
(cider-current-ns) 'tooling)
+                 (nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) 
nil 'tooling)
                  "value"))
              '(cljs))))))
 
@@ -762,10 +762,17 @@ Session name can be customized with 
`cider-session-name-template'."
 (defvar-local cider-repl-type nil
   "The type of this REPL buffer, usually either clj or cljs.")
 
+(defvar-local cider-repl-cljs-upgrade-pending nil
+  "Is the cljs repl currently pending?")
+
 (defun cider-repl-type (repl-buffer)
   "Get REPL-BUFFER's type."
   (buffer-local-value 'cider-repl-type repl-buffer))
 
+(defun cider-cljs-pending-p (repl-buffer)
+  "Returns non nil when REPL-BUFFER is currently a pending cljs repl."
+  (buffer-local-value 'cider-repl-cljs-upgrade-pending repl-buffer))
+
 (defun cider-repl-type-for-buffer (&optional buffer)
   "Return the matching connection type (clj or cljs) for BUFFER.
 BUFFER defaults to the `current-buffer'.  In cljc buffers return
@@ -812,13 +819,13 @@ PARAMS is a plist as received by `cider-repl-create'."
     (let* ((proj-dir (plist-get params :project-dir))
            (host (plist-get params :host))
            (port (plist-get params :port))
-           (cljsp (member (plist-get params :repl-type) '(cljs pending-cljs)))
+           (cljsp (member (plist-get params :repl-type) '(cljs)))
            (scored-repls
             (delq nil
                   (mapcar (lambda (b)
                             (let ((bparams (cider--gather-connect-params nil 
b)))
                               (when (eq cljsp (member (plist-get bparams 
:repl-type)
-                                                      '(cljs pending-cljs)))
+                                                      '(cljs)))
                                 (cons (buffer-name b)
                                       (+
                                        (if (equal proj-dir (plist-get bparams 
:project-dir)) 8 0)
@@ -866,8 +873,9 @@ function with the repl buffer set as current."
             mode-name nil
             cider-session-name ses-name
             nrepl-project-dir (plist-get params :project-dir)
-            ;; REPLs start with clj and then "upgrade" to a different type
+            ;; Cljs repls are pending until they are upgraded. See 
cider-repl--state-handler
             cider-repl-type (plist-get params :repl-type)
+            cider-repl-cljs-upgrade-pending (plist-get params 
:cider-repl-cljs-upgrade-pending)
             ;; ran at the end of cider--connected-handler
             cider-repl-init-function (plist-get params :repl-init-function)
             cider-launch-params params)
@@ -985,7 +993,9 @@ throw an error if no linked session exists."
                              (sesman-ensure-session 'CIDER)
                            (sesman-current-session 'CIDER)))))))
     (or (seq-filter (lambda (b)
-                      (cider--match-repl-type type b))
+                      (unless
+                          (cider-cljs-pending-p b)
+                        (cider--match-repl-type type b)))
                     repls)
         (when ensure
           (cider--no-repls-user-error type)))))
diff --git a/cider-repl.el b/cider-repl.el
index 80f47ec046..1ab3898cc3 100644
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -224,6 +224,8 @@ This cache is stored in the connection buffer.")
       (nrepl-dbind-response response (repl-type changed-namespaces)
         (when (and repl-type cider-repl-auto-detect-type)
           (cider-set-repl-type repl-type))
+        (when (eq (cider-maybe-intern repl-type) 'cljs)
+          (setq cider-repl-cljs-upgrade-pending nil))
         (unless (nrepl-dict-empty-p changed-namespaces)
           (setq cider-repl-ns-cache (nrepl-dict-merge cider-repl-ns-cache 
changed-namespaces))
           (dolist (b (buffer-list))
diff --git a/cider.el b/cider.el
index 5031096f70..dc44e1cfca 100644
--- a/cider.el
+++ b/cider.el
@@ -1258,7 +1258,8 @@ server buffer, in which case a new session for that 
server is created."
        (cider--update-cljs-type)
        (cider--update-cljs-init-function)
        (plist-put :session-name ses-name)
-       (plist-put :repl-type 'pending-cljs)))))
+       (plist-put :repl-type 'cljs)
+       (plist-put :cider-repl-cljs-upgrade-pending t)))))
 
 ;;;###autoload
 (defun cider-connect-clj (&optional params)
@@ -1292,7 +1293,8 @@ parameters regardless of their supplied or default 
values."
      (cider--update-cljs-type)
      (cider--update-cljs-init-function)
      (plist-put :session-name nil)
-     (plist-put :repl-type 'pending-cljs))))
+     (plist-put :repl-type 'cljs)
+     (plist-put :cider-repl-cljs-upgrade-pending t))))
 
 ;;;###autoload
 (defun cider-connect-clj&cljs (params &optional soft-cljs-start)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]