-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Optionally specify callback to cider load buffer #2689
Optionally specify callback to cider load buffer #2689
Conversation
Nice idea! Let me think a bit about this, as there's another approach to do the same thing - namely trigger some hook functions in the done handler, which might be more user-friendly. |
Let me also ping @Malabarba here, as back in the day he had a different approach to this https://endlessparentheses.com/test-driven-development-in-cider-and-emacs.html |
Hmm, actually I see we already have the file loaded hook, but it's being triggered in another handler (the value handler). I'm not sure if this has any practical differences, so I guess you can help me understand why using the done callback is preferable for this. |
I'm happy to use the |
As a side note, the trick @Malabarba uses is the one I'm trying to avoid here - since I had to resort to a |
Btw, I've noticed one small problem with our existing hook - starting with nREPL 0.6 you can actually get multiple
Yeah, that's a perfectly valid argument. |
@@ -501,7 +502,7 @@ or it can be a list with (START END) of the evaluated region." | |||
(lambda (_buffer err) | |||
(cider-emit-interactive-eval-err-output err) | |||
(cider-handle-compilation-errors err eval-buffer)) | |||
'() | |||
(or done-handler '()) |
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.
since '()
is the same as nil
, this whole line is the same as just done-handler
I think it's reasonable for the function to receive a callback argument, since it's already implemented in the lower functions. I think both the hook and the local callback will probably have its uses in different situations. |
@Malabarba Fine by me. Let's get this baby merged! Btw, do you think we should move the hook in the done handler as well? @magnars Please, add a changelog entry for the PR. |
382c2b0
to
1c10aff
Compare
Done, as well as freshly rebased onto master. |
Thanks! |
cider-load-buffer
(normally bound to C-c C-k) does not pass a callback tocider-request:load-file
. With this change, a user can now optionally specify this callback.when no callback is passed to
cider-request:load-file
, it will fall back oncider-load-file-handler
, which does not specify a done-handler. With this change, a user can now optionally specify a done-handler.These two changes together would allow users to perform some task after loading the current buffer, by doing something like this:
In my case that would be running tests.
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
make test
)make lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.Thanks!
If you're just starting out to hack on CIDER you might find this section of its
manual extremely useful.