wincent/ferret

Add back fallback support for `grep`

wincent opened this issue · 6 comments

This was removed in 1.4 because it didn't work at all.

But it would be nice to add it back.

I think the right way to do this might be by adding the ability to customize the executable and args used (beyond the current hard-coded list). My main concern is that grep may vary a fair bit from platform to platform (BSD grep vs GNU grep etc), so getting a default config that works everywhere might be fiddly and brittle.

See also #40, which is another case where we might want the user to be able to configure the options passed to the search command.

I'm wondering if we could just modify the grep command. In my case, I need to customize ag switches. (e.g.: add --hidden).

Would it be the case that the script should read from grepprg, or you think a new variable is better?

Ferret doesn't read from 'grepprg', it sets it.

As for adding a switch, you can of course add --hidden explicitly when you use :Ack (there is even auto-complete for it), but if you want it to apply all the time, you'd still need a configuration option for that, like I said in the issue description above:

I think the right way to do this might be by adding the ability to customize the executable and args used.

It indeed sets grepprg, but it doesn't use it afterwards, so even if I reset that value manually after the plugin gets loaded, it won't use the new value. Is it supposed behave like that? 🤔

What I meant in my previous post is that in order to add this customization ability, how could that be better implemented: by using a new global variable, or by just reading from grepprg?

Is it supposed behave like that?

Yes. The idea is that it sets the program to the best "reasonable" guess based on what executables you have present on your system, so that if you run a command like :grep you get the same results you'll get if you run :Ack.

What I meant in my previous post is that in order to add this customization ability, how could that be better implemented: by using a new global variable, or by just reading from grepprg?

By adding a new (global) setting variable, where the user could override the default arguments that Ferret would otherwise set for each executable.

Closing this one due to inactivity, because I don't think many people who care about this kind of plug-in are actually relying on grep, and because grep is different enough from the other executables that adding this fallback in would require some unpleasant complexity to be added back in.