Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reify cider-cljs-pending separate from repl-type #3291

Merged

Conversation

benjamin-asdf
Copy link
Contributor

@benjamin-asdf benjamin-asdf commented Dec 14, 2022

This pull request addresses #3287 by separating the concept of a repl type from the concept of pending 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.

In cider-repls, we no longer return pending repls, which is the same semantic as before (calling (cider-repls 'cljs) or (cider-repls 'clj) or (cider-repls nil) does not return pending repls. The only potential use case that is broken with this change is if a user has written an emacs lisp function that calls (cider-repls 'pending-cljs). We could add a legacy special case for this, where calling cider-repls with 'pending-cljs returns the repls that are cider-cljs-pending-p.

Overall, this change will prevent future headaches by clearly separating the concepts of repl type and pending status.

@bbatsov
Copy link
Member

bbatsov commented Dec 15, 2022

The only potential use case that is broken with this change is if a user has written an emacs lisp function that calls (cider-repls 'pending-cljs). We could add a legacy special case for this, where calling cider-repls with 'pending-cljs returns the repls that are cider-cljs-pending-p.

Pretty sure that's not an use-case we should worry about, as I can't see why someone would be doing this. Your proposed solution is reasonable. I agree that the pending upgrade status is not really a REPL type, but rather an internal implementation detail.

cider-repl.el Outdated
@@ -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 (string= repl-type 'cljs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use string= to compare something with a symbol - eq is what you're looking for here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this with eq first. repl-type is a string at that point. Could instead call cider-maybe-intern on the type and say eq ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(updated version seems better)

cider-repl.el Outdated Show resolved Hide resolved
@@ -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-cljs-repl-pending nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a good time to change the terminology to the more descriptive cider-repl-cljs-upgrade-pending. This will make the code more readable across the board.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bbatsov
Copy link
Member

bbatsov commented Dec 15, 2022

The proposed change needs a changelog entry as well, as we're removing a REPL type (even if it was kind of fake).

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, if that's a string than the comparison should be (string= repl-type "cljs"). I just saw 'cljs was a symbol and I assumed that repl-type was a symbol as well.

@bbatsov bbatsov merged commit 5631d60 into clojure-emacs:master Dec 15, 2022
@bbatsov
Copy link
Member

bbatsov commented Dec 15, 2022

I'll merge this as is and I'll make a couple of small tweaks myself, so I won't waste your time with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants