-
-
Notifications
You must be signed in to change notification settings - Fork 649
Fix `nrepl-switch-to-repl-buffer' to work with all connections #361
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
Fix `nrepl-switch-to-repl-buffer' to work with all connections #361
Conversation
Hi @bbatsov, While my commit fixes the obvious breakage of not being able to switch to nrepl buffer, it exposes a more subtle bug that was introduced in 12558e8: Suppose I have used This is absolutely the wrong thing to do, IMHO. People who are connected to multiple repls know that they are connected to multiple repls, and don't need nrepl to switch to the correct repl for them. Please consider rolling back this entire functionality and going back to the way |
One option is to keep the functionality as a separate function. The functionality is there for convenience sake. |
Yes, +1. Keep this as a separate function that can be bound to a separate key and used as per requirement. |
I have changed the If this change is acceptable, we can add a new key binding for |
Other options are having a flag to turn on/off the behaviour in the single function, or to think harder about how the 'magic' should be applied, i.e. if there is a connection present not based off a project and there is some level of ambiguity then don't do it. |
I'm against 'magic' code in general. Since this is a convenience function, keeping it separate is the right thing to do. |
Yes I agree, just throwing up the other options. |
Fair enough. Separate function it is. I'd suggest |
I've added the documentation changes and tests for |
(nrepl-remember-clojure-buffer buffer) | ||
(goto-char (point-max)))))) | ||
|
||
(defun nrepl-switch-to-relevant-buffer (arg) |
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 think we should name this nrepl-switch-to-relevant-repl
(-buffer).
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.
okay.
I've added my comments. As soon as you've addressed them we'll be good to merge this. |
Alright, I'll make the changes and push the commit. |
Commit 12558e8 breaks `nrepl-switch-to-repl-buffer' functionality by assuming that all nrepl connections will be made using `nrepl-jack-in'. This commit reverts to old `nrepl-switch-to-repl-buffer'. A new function `nrepl-switch-to-relevant-repl-buffer' is added as a convenience function to switch to the correct nrepl buffer from a given clojure buffer.
Done. Rebased on top of master and good to merge. |
Fix `nrepl-switch-to-repl-buffer' to work with all connections
Commit 12558e8 breaks
nrepl-switch-to-repl-buffer
functionality byassuming that all nrepl connections will be made using
nrepl-jack-in
.Using
nrepl-jack-in
sets the variablenrepl-project-dir
to thecorrect value, but this information cannot be retrieved when we
connect to an existing nRepl server using
nrepl-connect
. Sincenrepl-project-dir
is unbound, the functionfile-truename
throws anull value exception.
This commit checks if
nrepl-project-dir
is set before callingfile-truename
. Further, the message "nREPL connection not found"does not make sense and thus should not be displayed.