-
Notifications
You must be signed in to change notification settings - Fork 177
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
Support clj-reload workflow #850
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks!
Some suggestions
#(try | ||
(let [reload (user-reload)] | ||
(when-not reload | ||
(throw (ex-info "clj-reload.core/reload not found" {}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we don't need to be this stringent, following tonsky/clj-reload@0a082e9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's right! We can use the project one if available, and fall back to the bundled one if not.
(defn handle-reload [handler msg] | ||
(case (:op msg) | ||
"reload" (refresh-reply msg) | ||
"reload-all" (refresh-reply (assoc msg :all true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not a clear
op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm no, I can't see it in https://github.com/tonsky/clj-reload/blob/main/src/clj_reload/core.clj
(respond msg {:status :ok})) | ||
(catch Throwable error | ||
(respond msg {:status :error | ||
:error (stacktrace.analyzer/analyze error print-fn)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:error (stacktrace.analyzer/analyze error print-fn)}) | |
;; TODO assoc :file, :line info if available | |
:error (stacktrace.analyzer/analyze error print-fn)}) |
I'd like this to eventually return file/line info if we can easily grab it from the analyzer. This way cider.el could automatically open the culprit file.
(Feel free to give it a shot, but simply adding the TODO is perfectly fine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the TODO for now, but may circle back later if I can manage it.
a42b6dd
to
37a8dbf
Compare
@vemv running
But |
Thanks for applying the feedback! I think it's a known issue with mranderson - see: cider-nrepl/test/clj/cider/nrepl/middleware/refresh_test.clj Lines 131 to 136 in 3824d72
You could perform the require dynamically, only running the deftest if |
@vemv all the tests in |
That last commit seems to have sorted the cli-reload errors. But now a see two errors that I really don't understand....
I didn't touch or I think interact with these ns's in any way, do you have any idea of what's happening? |
Yes, feel free to disregard those - we can fix them before we cut a stable release. Is there anything pending from your side? |
Should I do any changes to the README, as the PR template mentions? I'd like to test locally a bit to make sure everything is fine, but hitting a failure... when I run
it fails with this message:
Am I doing something wrong? If there's a better way to test locally let me know. |
That looks like an occurrence of #848 - please try with a slightly older Lein? |
Yeap that worked! ... but I'm at a bit of a loss of how to test it now. I mean CIDER won't have this operation, right? What should I do to test it in CIDER? |
Well if there's nothing more that I can test at this point, I don't think there's anything pending on my side. Just pushed the README update. |
Happy that you got it! After a successful There should be a few defcustoms e.g. Should be a small change overall. It also should be good timing to discuss upstream whether a |
What's the difference between the I tried to setup CIDER locally but get a native compile error while doing I could see This is the test I used: (def foo 1)
(defonce bar 5)
(comment
foo
bar) I saved, reloaded, and got eval'ed |
What are you thoughts on using the new operation from within CIDER by the way? I guessed that a new command would be added, |
Hi Filipe!
In general,
Looks like they are: https://github.com/clojure-emacs/cider/blob/dc58ed1a411e6fe6f0350435aa4c56ec6edf59bf/cider-ns.el#L257-L261
I'd prefer if the defuns/commands remained the same. Instead, the ops would be customizable via defcustoms. Cheers - V |
Ok so what's next? I don't think there's anything left for me to do in this PR, or is there? |
I'd like to know if there's an intention from clj-reload's side to offer In the meantime, WIP PR welcome for https://github.com/clojure-emacs/cider - let us know if it's working as intended, using the suggested |
I see now all the refresh nrepl operations are within the same cider-ns-refresh, that's what I missed. It also makes a lot more sense why you'd like But I don't see an exposed unload operation in clj-reload, it's not part of the API I think. Maybe we could leave that one as not yet implemented and the interface would still be the same? |
@tonsky what are your thoughts about a clear/unload operation? |
This? We can do this, sure. Send a PR or I’ll do it myself next week |
@vemv early draft of the cider changes in clojure-emacs/cider#3624, PTAL if it matches what you had in mind. |
(case (:op msg) | ||
"cider.clj-reload/reload" (refresh-reply msg) | ||
"cider.clj-reload/reload-all" (refresh-reply (assoc msg :all true)) | ||
"cider.clj-reload/reload-clear" (refresh-reply (assoc msg :clear true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vemv left support for the clear op here so it exists when called from CIDER, but it's still not functional as per the TODO in this file.
(exec id | ||
(fn [] | ||
(try | ||
;; TODO: clear op |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonsky I think I'll wait until you implement the clear op, because I felt my init implementation was a rather far from what you ended up merging and unload seems to be more involved than init.
I think everything else is done though. Today I tested the e2e of the feature in my emacs and it was working as expected. All users need to do is add (setq cider-ns-refresh-tool 'clj-reload)
.
Thanks much, @tonsky 🎉! @filipesilva , if you merge Be sure to add |
[{:keys [transport] :as msg} response] | ||
(transport/send transport (response-for msg response))) | ||
|
||
(defn- refresh-reply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you forgot to rename this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, initial copy paste then didn't look at it again :(
Yeah, it'd be nice to explain both here and in CIDER's docs (later) why are there 2 instances of relatively similar functionality. I'm guessing if |
tbh that would be one big breaking change :) it's easy to imagine a variety of commercial projects that have set up the t.n boilerplate, so using t.n would be a natural fit. Ultimately, let's see how it all plays out over the years - I reckon that only one of both projects will remain actively maintained / used. It's pretty early to bet on either. |
Yeah, I'm well aware of this. I don't see this happening soon, but I also dislike functionality duplication. (it tends to be confusing for the end users and it's more maintenance work for us) Now CIDER will have 3 ways to do code reloading, so can understand my desire for this not to be a permanent situation. Anyways, that's not particularly important for this PR. |
Added Edit: also added a bit more about why you might want cld-reload to the cider docs in the other PR. |
Great work, thanks! FYI a changelog entry was missing - no biggie, adding it now |
|
@cichli Might be good to file this as a ticket, so the suggestion to add an alias won't be forgotten. |
Fix #849
Before submitting a PR make sure the following things have been done:
cider.nrepl
ns which has all middleware documentation.lein docs
afterwards, and commit the results.Note: If you're just starting out to hack on
cider-nrepl
you might findnREPL's documentation and the
"Design" section of the README extremely useful.*
Thanks!