-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
[#1032] Combine jump-to-var and jump-to-resource into one function. #1036
Conversation
5fc2847
to
55b7ead
Compare
@@ -762,6 +762,32 @@ window." | |||
(when pos | |||
(goto-char pos))))) | |||
|
|||
(defun cider-jump-to-resource-or-var (symbol-file &optional other-window) |
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.
Seems like a bad idea to allow an optional argument in this interactive command, given that this is actually used only by another interactive command.
Without changing the existing bindings this command will unlikely be used by someone. Maybe the existing commands should be make ordinary functions. |
A further optimization might be to check if the point is within a string - then it would make sense to use jump to resource, otherwise we would do var jump. |
The optional parameter is a leftover from trying to continue using cider-read-symbol-name. |
ok. jump-to-var and jump-to-resource are regular functions. I changed the key bindings to point at jump-to-resource-or-var. Which means there are duplicate key bindings for each. I didn't want to break anything. Your call. |
@@ -30,6 +30,8 @@ | |||
* [#958](https://github.com/clojure-emacs/cider/pull/958) Reuse existing repl | |||
buffers with dead processes. Users are now informed about existing zombie repl | |||
buffers and are offered the choice to reuse those for new connections. | |||
* [#1032](https://github.com/clojure-emacs/cider/issues/1032) New function jump-to-resource-or-var |
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.
Use full function names here and surround them with backticks.
How about |
Good point! Let's use |
Btw, just realized the downside of having a combined command - what are we going to use as the completion candidates when not operating at the point? |
Can't we just merge all known vars and all resources on classpath? |
Yes. I think that's pretty much the only way to go. It's a bit tricky with non-ido completion. Should the resources be full file names or base names only, or maybe both. |
Anything above the project root is just noise, so I think we should display it with a path relative to the root. This lets you disambiguate between say |
This version is completely different from the last commit. The new cider-prompt-for-symbol functionality changed things around quite a bit. @bbatsov I probably misunderstood your earlier suggestion about the '.' Checking for a '.' in the name would otherwise be something I would not have done. It seems a bit risky to me. Currently the new functions are find-dwim and find-dwim-other-window. The former jump-to-var and jump-to-resource are now non-interactive functions find-var and find-resource. The string match on '.' is still there. |
The completion problem remains - Afterwards we'll figure out how to auto-complete resources and how to combine the completion for resources with the completion for vars. As it stands I don't like the proposed command and won't accept it in its current state. |
I didn't think this iteration would go, but it seemed silly to continue having discussions about code that had not been rebased or integrated. The completion and history for vars is easy, resources never had completion or history. I already had that working by the time I read this, so I'll push that and see what you say. I haven't had much time to look at this today. |
This does of course still leave adding completions for resources to be done. But it does provide the same functionality as before with the added benefit of history for resources albeit mixed with history for vars. |
Therefore my suggestion to do several small changes instead of focusing on merging find-var and find-resource directly.
Is it really easy? I've changed it several times over the years and while the current version is pretty nice (it simply reuses the REPL completion), it's not exactly ido friendly (and probably never will be). We cannot just dump all the candidates, as we can do for Emacs Lisp. But we can do this for the resources... |
Well, it is easy to reuse what you've already been using. Adding completion for resources will take more. |
What is missing in the current functionality of find-dwim verses find-var and find-resource? I don't see anything lacking. There is completion, history, the new prompting behavior with prefix and the addition of the other-window version of the function. It seems to me that anything beyond that belongs in another PR. |
Right now you'll get var completion in the new command, which is totally unacceptable to me. The new command makes a lot of sense when operating at the point, but its usability is pretty questionable otherwise as mixing two completion sources together is generally a bad idea (not to mention one is not implemented yet). @vspinu guess you know what I mean. :-) I understand your desire to push forward with this, but until there's a foolproof solution for the problems that bother me I'd rather have this on hold. @expez You suggested this initially, but I hope you agree with my concerns. I'm starting to think this was a bad idea and there's no sensible way to implement it. Dealing with all the added complexity just to free one keybinding is not worth it. |
Ok. That makes sense to me. @expez, the function will be there, so you can bind it how you want. I guess we'll see what we can do with it from here. I can probably make an other window version of find-var and find-resource with that other PR. But is that something you still want if you have this one? |
I agree that the dwim stuff only makes sense if we're acting on point and not prompting. I also get that mixing completion sources can be undesirable. I'm thinking we should just drop this dwim stuff now. I really want |
@@ -51,8 +51,8 @@ | |||
\subgroup{Navigation} | |||
|
|||
\key{M-,}{cider-jump-back} | |||
\key{M-.}{cider-jump-to-var} | |||
\key{C-c M-.}{cider-jump-to-resource} | |||
\key{M-.}{cider-jump-to-resource-or-var} |
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 forgot to update this.
Overall things look good, apart from my small remarks. As discussed we're now not going to change the default keybindings, so the new commands should have keybindings of their own (or none). |
I must not have double checked... :-/ |
[#1032] Combine jump-to-var and jump-to-resource into one function.
👍 |
This adds an entirely new function jump-to-resource-or-var.
A prompt is given with thing at point as the default. Thing-at-point uses 'filename as
that is more leniant than 'symbol.
First an attempt is made to find the resource. Upon failure jump to var is attempted.
C-u prefix will cause the result to go to other-window.