|
From: | Jim Porter |
Subject: | bug#62426: [PATCH] eshell: Add 'rgrep' builtin. |
Date: | Thu, 30 Mar 2023 17:14:49 -0700 |
On 3/30/2023 2:19 PM, Sean Whitton wrote:
Even without Pcomplete support, there's still a benefit to a command like this though: you could use Eshell to pipe the results of 'M-x rgrep' to some other command. Looking at the code for 'eshell-grep', I don't think it'd be terribly difficult to support this case.Can you give a concrete use case? If you're piping won't you typically want to reuse your knowledge of traditional grep(1)? If I'm piping then I'm probably thinking in non-Emacs terms.
I'm somewhat biased (or maybe I've just thought about this too much?) because I wrote urgrep[1], which is essentially an extension of the basic recursive-grep concept: it provides a layer of abstraction over *any* recursive-grep-like command (rgrep, ag, ack, etc) so that you have a single API and can use whatever the flavor of the week is (possibly even using different programs on remote hosts).
In that package, I wrote an Eshell command, also called "urgrep", that replaces the user-entered command with whatever the *real* command is; then you can use that in Eshell like it's a regular command and pipe it around and do all the usual shell things with it. The Eshell urgrep command is designed to feel like grep so that you can (mostly) use your existing knowledge to search for things.
For Eshell's "rgrep" support, I think you could do the same thing without too much work, even if it delegated to "M-x rgrep" instead of "/usr/bin/rgrep". Since I almost never want to search the files in my .git dir, "M-x rgrep" is more convenient for me.
That said, ...
Maybe there should be a defcustom for this ("use M-x rgrep" vs "use /usr/bin/rgrep")? Or maybe it should be easier to configure various Eshell commands so they open in a compilation buffer when appropriate? You can do this now with an alias, but the syntax is a bit tricky:
[snip]
A command-specific defcustom doesn't seem ideal because we could end up with very many such things. Something like your compilation buffer idea sounds good.
My thinking here was that some users might simply prefer "M-x rgrep", and others might prefer /usr/bin/rgrep. Having an easy way to make Eshell conform to users' preferences would be nice. But maybe we could do this by defaulting to use "M-x rgrep", and making it very easy to write an alias to prefer /usr/bin/rgrep (e.g. with the compilation-buffer wrapper I suggested). We could even document this explicitly in the manual.
I'll try to get at least a prototype of this into a patch in a week or so. Then people can try it out and have something a little less nebulous to comment on.
[1] https://github.com/jimporter/urgrep
[Prev in Thread] | Current Thread | [Next in Thread] |