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

Possibility of having git-grep in git repos and fallback to ag #109

Closed
netromdk opened this issue Mar 16, 2017 · 6 comments
Closed

Possibility of having git-grep in git repos and fallback to ag #109

netromdk opened this issue Mar 16, 2017 · 6 comments

Comments

@netromdk
Copy link
Contributor

I was thinking that people would probably prefer to use git grep in a git repo because it's usually faster, and now they can with commit a90ae44.

However, it's not always useful to have (setq dumb-jump-searcher "git-grep") if you sometimes search non-git projects. In this case, I was wondering if it would be helpful with an easy way of defining a fallback searcher? In my ideal scenario, it will pick git grep in a git repo and otherwise use dumb-jump-searcher. Thoughts?

@netromdk
Copy link
Contributor Author

Perhaps there could be a (setq dumb-jump-use-git-grep-in-git-repo t) or something, and dumb-jump-pick-grep-variant would then use git grep if the project has a ".git" denoter and git grep is installed.

@jacktasia
Copy link
Owner

I haven't fully thought this out yet but I was kind of thinking of having dumb-jump-searcher* default to nil and then when nil it will pick the best option which seems to be (in order): git-grep (if it's a git project), ag, rg, grep. If it's anything but git-grep it would still try to use git grep if it was a git project...but then also add a new config called dumb-jump-force-searcher that would also default to nil but if it was set it would just blindly use whatever was set.

So

Example 1

(setq dumb-jump-searcher nil)
(setq dumb-jump-force-searcher nil)

would use git-grep if a git repo and if not then use whatever was available in order ag, rg, grep.

Example 2

(setq dumb-jump-searcher nil) 
(setq dumb-jump-force-searcher "ag")

would always use ag and dumb-jump-searcher would effectively be ignored (even if it was set)

*It'd probably be a good idea to drop dumb-jump-searcher and call it dump-jump-prefer-searcher to make it more clear.

What I like about this is it would have a sane default "out of the box" that is the fastset and people wouldn't have to worry about what it's doing under the hood, but then if they really care they can force the searcher of your choice.

Thoughts? Any flaws with this thinking?

@netromdk
Copy link
Contributor Author

I agree with your two variables, making it possible to force a searcher if necessary (like wanting rg which will not be chosen if both git grep and ag are installed, for instance), and still being able to define a preferable searcher.

But just to be clear, this is how I understand the way it will detect the searcher to use (most relevant first):

  1. If dumb-jump-force-searcher is defined, it will use that even if it can't find it. Or?
  2. If it's a git repo, it will use git grep, if installed, no matter what dumb-jump-prefer-searcher is set to.
  3. Then it tests whether dumb-jump-prefer-searcher (if not nil) is installed and applicable.
  4. Otherwise, it detects by fastest first: ag, rg, or grep.

Was that what you meant as well?

@jacktasia
Copy link
Owner

That all sounds good/correct to me.

If dumb-jump-force-searcher is defined, it will use that even if it can't find it.

Yes, my thinking is if a person is going to set a variable with force in the name then the least confusing thing to do is what we're told. That said, we should just do what they say, but still error gracefully if not found...something like: Jump aborted! Searcher "rg" was forced, but not found. Please install "rg" or set "dumb-jump-force-searcher" to nil to automatically use the fastest searcher available.

@netromdk
Copy link
Contributor Author

netromdk commented Mar 16, 2017

I think I'll look into this tomorrow. 😊

@jacktasia
Copy link
Owner

Thanks again!

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

No branches or pull requests

2 participants