From: Jim Porter <jporterbugs@gmail.com>
To: Sean Whitton <spwhitton@spwhitton.name>
Cc: Antero Mejr <antero@mailbox.org>, 62426@debbugs.gnu.org
Subject: bug#62426: [PATCH] eshell: Add 'rgrep' builtin.
Date: Thu, 30 Mar 2023 17:14:49 -0700 [thread overview]
Message-ID: <8c94b46f-e360-087e-cb80-bf27ac76d2f9@gmail.com> (raw)
In-Reply-To: <87o7oavsxf.fsf@melete.silentflame.com>
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
next prev parent reply other threads:[~2023-03-31 0:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 21:02 bug#62426: [PATCH] eshell: Add 'rgrep' builtin Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-25 0:04 ` Jim Porter
2023-03-25 17:22 ` Sean Whitton
2023-03-25 19:07 ` Jim Porter
2023-03-30 21:19 ` Sean Whitton
2023-03-31 0:14 ` Jim Porter [this message]
2023-04-09 1:55 ` Jim Porter
2023-04-11 2:12 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-11 4:01 ` Jim Porter
2023-06-03 1:41 ` bug#62426: (no subject) Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c94b46f-e360-087e-cb80-bf27ac76d2f9@gmail.com \
--to=jporterbugs@gmail.com \
--cc=62426@debbugs.gnu.org \
--cc=antero@mailbox.org \
--cc=spwhitton@spwhitton.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).