Skip to content
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

Merged
merged 1 commit into from
Apr 2, 2015

Conversation

EricGebhart
Copy link
Contributor

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.

@EricGebhart EricGebhart force-pushed the jump-to branch 5 times, most recently from 5fc2847 to 55b7ead Compare March 21, 2015 06:17
@@ -762,6 +762,32 @@ window."
(when pos
(goto-char pos)))))

(defun cider-jump-to-resource-or-var (symbol-file &optional other-window)
Copy link
Member

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.

@bbatsov
Copy link
Member

bbatsov commented Mar 22, 2015

This adds an entirely new function jump-to-resource-or-var.

Without changing the existing bindings this command will unlikely be used by someone. Maybe the existing commands should be make ordinary functions.

@bbatsov
Copy link
Member

bbatsov commented Mar 22, 2015

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.

@EricGebhart
Copy link
Contributor Author

The optional parameter is a leftover from trying to continue using cider-read-symbol-name.
I'll remove it and add your other suggestions.

@EricGebhart
Copy link
Contributor Author

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
Copy link
Member

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.

@bbatsov
Copy link
Member

bbatsov commented Mar 28, 2015

I'm also starting to think that the "jump" terminology was a bad idea. Right now I prefer "lookup".

@cichli @vspinu Any feedback?

@expez
Copy link
Member

expez commented Mar 28, 2015

How about find- now that these commands are more like find-variable, find-function etc in emacs? I think lookup is better suited for actual lookups, like the grimoire command

@bbatsov
Copy link
Member

bbatsov commented Mar 28, 2015

How about find- now that these commands are more like find-variable, find-function etc in emacs?

Good point! Let's use find-var, find-resource and find-dwim.

@bbatsov
Copy link
Member

bbatsov commented Mar 28, 2015

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? find-var will obviously show known vars, find-resource will probably show nothing. For a mix of them - it's hard to determine this.

@expez
Copy link
Member

expez commented Mar 28, 2015

Can't we just merge all known vars and all resources on classpath?

@vspinu
Copy link
Contributor

vspinu commented Mar 28, 2015

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.

@expez
Copy link
Member

expez commented Mar 28, 2015

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 resources/ and test/resources/ if you should have similarly named files.

@EricGebhart
Copy link
Contributor Author

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.

@bbatsov
Copy link
Member

bbatsov commented Mar 30, 2015

The completion problem remains - cider-find-var used to have a smart completion and the new command has zilch. Let's do this in two steps. Rework the current PR into something that simply renames the existing commands to cider-find-var and cider-find-resource.

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.

@EricGebhart
Copy link
Contributor Author

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.

@EricGebhart
Copy link
Contributor Author

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.

@bbatsov
Copy link
Member

bbatsov commented Mar 31, 2015

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.

Therefore my suggestion to do several small changes instead of focusing on merging find-var and find-resource directly.

The completion and history for vars is easy, resources never had completion or history.

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...

@EricGebhart
Copy link
Contributor Author

Well, it is easy to reuse what you've already been using. Adding completion for resources will take more.

@EricGebhart
Copy link
Contributor Author

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.

@bbatsov
Copy link
Member

bbatsov commented Mar 31, 2015

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.

@EricGebhart
Copy link
Contributor Author

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?

@expez
Copy link
Member

expez commented Apr 1, 2015

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 find-var and find-resources in other window, though.

@@ -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}
Copy link
Member

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.

@bbatsov
Copy link
Member

bbatsov commented Apr 2, 2015

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).

@EricGebhart
Copy link
Contributor Author

I must not have double checked... :-/

bbatsov added a commit that referenced this pull request Apr 2, 2015
[#1032] Combine jump-to-var and jump-to-resource into one function.
@bbatsov bbatsov merged commit ceb2d7d into clojure-emacs:master Apr 2, 2015
@bbatsov
Copy link
Member

bbatsov commented Apr 2, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants