-
-
Notifications
You must be signed in to change notification settings - Fork 649
switch-to-relevant buffer #350
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
Conversation
@@ -2649,6 +2649,23 @@ clojure buffer and the REPL buffer." | |||
(pop-to-buffer nrepl-last-clojure-buffer) | |||
(message "Don't know the original clojure buffer"))) | |||
|
|||
(defun nrepl-switch-to-relevant-buffer () | |||
"Switch to relevant nrepl buffer based on the current 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.
This docstring is missing an ending dot.
I think that this behaviour should be integrated into the existing switch to REPL buffer command - it's pretty sensible to assume people would won't to go to proper REPL buffer using that command. |
Thanks - I've made all the changes bar using cl-remove-if-not and merging into the existing switch command. I couldn't find cl-remove-if-not... I played around but couldn't improve upon remove-if-not. As commented in http://stackoverflow.com/questions/2234860/lisp-filter-out-results-from-list-not-matching-predicate, I tried using remove-if, but complement isn't present in elisp. WRT to merging into the existing switch-command I'm happy to do this. Might be worth a second pull-request as it's changing existing behaviour? But whatever I'll work on it. |
The problem with having this functionality in a separate command is that probably nobody will notice and as I already said - I cannot imagine why I'll want to jump to a REPL that's not connected to my current project so I'd rather us change the existing (and widely used command). @hugoduncan @purcell @technomancy @samaaron Thoughts? |
I've merged the two fns. I'm running with emacs 24.2 which is why I can't seem to get cl-remove-if-not and friends: http://williamjohnbert.com/2013/05/emacs-cl-lib-madness/ I'll upgrade. |
Might it be an issue with users on older Emacs versions though? |
What happens when there are multiple REPLs for a single project? I assume it would just pick the "first", which should be the most recently used, iirc. Building it into jump to repl should be fine, but should be overridable with a prefix, since it is not impossible that you have REPLs for a project and a subproject open, and want to work with the top level project REPL when changing subproject files. Not sure if checkout dependencies complicate anything further here - I don't think so. |
Have used cl-remove-if-not as discussed (after emacs upgrade) I moved nrepl-remember-clojure-buffer up as it was being used before it was defined. @hugoduncan it does pick the first match if you were to have multiple nrepl sessions open in the same project dir. TBH - not sure how the prefix would function? Like a global flag to turn off the extra behaviour? |
@jonpither A prefix argument means that when the function is invoked like this |
Thanks @bbatsov. I understand the prefix behaviour now :-) The same ido-read-directory-name approach could be taken as for nrepl-jack-in. There is though already an arg taken by nrepl-switch-to-repl-buffer to put the user into the namespace of the file they are on... thoughts? |
@jonpither Pretty simple - we have |
@bbatsov I've added the second prefix arg that prompts for a directory in the last commit. The only issue is that if you want the new behaviour of specifying the directory of the repl session you want to jump to through C-u C-u C-c C-z, then the first arg is still also activated, meaning the NS will be changed to whatever the current buffer is (or user if the current buffer does not have a ns open). This is probably fine, but it may annoy if you want to change to a specific repl but not switch ns. If there's an easy way of having the second behaviour but not the first, it may be worth doing. |
of the current source file. | ||
|
||
With a second prefix ARG the chosen repl buffer is based on a | ||
supplied project directory." | ||
(interactive "P") |
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.
You can make this interactive "p"
to receive directly a numeric prefix argument. For C-u C-c C-z
it would be 4 and for C-u C-c C-z
it would be 16.
I've commented on the relevant bit of code - basically |
Have added as per your comment, the two behaviours are triggered separately. Have added to the docs. |
OK. Now just update the Changelog and squash all the commits into one and we're good to merge this. |
Should be good to go |
Hi I added this function 'nrepl-switch-to-relevant-buffer'. It switches the user to the right nrepl buffer based on the current buffer. So if you have 2 nrepls open for project x and project y, if you open a project x file and run the function (key mapped of course) then you land on the right nrepl buffer. I couldn't see anything that caters for this in nrepl.el hence the pull request.
TBH I'm new to elisp so you might want to make sure it looks sane. Unfortunately since I moved this fn into nrepl.el, I can't seem to use it without eval'ling the nrepl.el in emacs. Not sure why this is? I get:
Symbol's function definition is void: nrepl-switch-to-relevant-buffer. I've tried byte-recompiling my emacs dir to no avail.
Not sure what the issue is.