From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#62426: [PATCH] eshell: Add 'rgrep' builtin. Date: Thu, 30 Mar 2023 17:14:49 -0700 Message-ID: <8c94b46f-e360-087e-cb80-bf27ac76d2f9@gmail.com> References: <87jzz5eucl.fsf@mailbox.org> <87355syce8.fsf@athena.silentflame.com> <314663e3-ff4e-814c-6ff7-6ab3376ef458@gmail.com> <87o7oavsxf.fsf@melete.silentflame.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6612"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Antero Mejr , 62426@debbugs.gnu.org To: Sean Whitton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 31 02:15:22 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pi2QM-0001YO-KQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Mar 2023 02:15:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pi2Q5-0005HZ-4a; Thu, 30 Mar 2023 20:15:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pi2Q3-0005HL-Dh for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2023 20:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pi2Q3-0006t3-4g for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2023 20:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pi2Q2-0001J0-BU for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2023 20:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Mar 2023 00:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62426 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62426-submit@debbugs.gnu.org id=B62426.16802216994999 (code B ref 62426); Fri, 31 Mar 2023 00:15:02 +0000 Original-Received: (at 62426) by debbugs.gnu.org; 31 Mar 2023 00:14:59 +0000 Original-Received: from localhost ([127.0.0.1]:59875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi2Pz-0001IY-1x for submit@debbugs.gnu.org; Thu, 30 Mar 2023 20:14:59 -0400 Original-Received: from mail-pj1-f51.google.com ([209.85.216.51]:41703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi2Pw-0001IK-TC for 62426@debbugs.gnu.org; Thu, 30 Mar 2023 20:14:57 -0400 Original-Received: by mail-pj1-f51.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so21634796pjb.0 for <62426@debbugs.gnu.org>; Thu, 30 Mar 2023 17:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680221691; x=1682813691; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=NeLnD2AB5U4G/lqFSeQPahthI0CMgSMveG/H+fhyhdw=; b=VjHjJhiQOBF/2wJ974JQbDRWkjyxOCwhytICeSN3Fj5NFFys6QzmfDyjhgKKlC0PnZ RZ6vWvoK47etBdRzMdQcFDOFyJcb9pP3dtFv7sYdxAAzyuv6/RGwzbHQbygeF9wtqIzF knxA6kzpDWhGa4X4lhFy0kHp3uw3LHRlA/mhiZnmEscbENuA7XO5tStwfzq7AiyiOp3E 0aekVih4OQ3lfUZTxIZI/dDJk+vGmhfgPVxOfyLp3wrAtCeemOte84i0jTqYTAEQOiJw jeKWUuUi1MS+rstMEdoa1rowvFzz2wlZ8W75zEuUNxdqrzMx9KJF5hUBoSswiFHdWuDO lefg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680221691; x=1682813691; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NeLnD2AB5U4G/lqFSeQPahthI0CMgSMveG/H+fhyhdw=; b=0SBvIzlkK5v7u04ZbC5wFZMQ+YWooTjGLW+h1C1qrHqZRGz9jidm8ASxL/s4SvF60s y/e2kcFmfAc/C5LWRAtE5JsuPXBPenKm6VEjWRRFEJbopTOR2p5OCtDkHcSL+HYLNuaX 01FDW51bAE5zVrAUuf/1iL4tG6eYSFpVdfFgtv8ngmIRa/p9wqv2H6hDiO0UOLDe3V47 qidpBGfFkFP8NJvuUFoAzt29n7zYMia1fXQPFe+GmvpPnwAvWq1t3Cq2IH2efWgATWPQ 8/u//zTI0zoqLM1pV21AzNiKa8c6+zZ5RguhDR33uz5541AZ8ymf3Qf/YSv/TZxNdYzf J2TQ== X-Gm-Message-State: AO0yUKWy6p7Wyy5+r/8MAWtMgMARsZ7Ju7SjWV1gprF8JgxoDRDWnffC UrxkwvzJ4wmMO5EKiCh55DY= X-Google-Smtp-Source: AK7set9OhFZhZDBQn+sBGjOSoEZir0TIF3e90C6mt2h1vg+/Q9N3CWcBmC0wPDLte2jEl+IzPqjbkw== X-Received: by 2002:a05:6a20:b288:b0:d9:2818:441 with SMTP id ei8-20020a056a20b28800b000d928180441mr21859094pzb.5.1680221690492; Thu, 30 Mar 2023 17:14:50 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id c16-20020aa78c10000000b005e5b11335b3sm435919pfd.57.2023.03.30.17.14.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Mar 2023 17:14:50 -0700 (PDT) Content-Language: en-US In-Reply-To: <87o7oavsxf.fsf@melete.silentflame.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258953 Archived-At: 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