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: Sat, 8 Apr 2023 18:55:06 -0700 Message-ID: References: <87jzz5eucl.fsf@mailbox.org> <87355syce8.fsf@athena.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="33267"; 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 Sun Apr 09 03:56:17 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 1plKHx-0008Vw-Mg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Apr 2023 03:56:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plKHi-0005dE-Lc; Sat, 08 Apr 2023 21:56:02 -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 1plKHi-0005d5-0Y for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2023 21:56:02 -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 1plKHh-0002Pp-NU for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2023 21:56:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1plKHh-0000DJ-Jn for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2023 21:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Apr 2023 01:56:01 +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.1681005315764 (code B ref 62426); Sun, 09 Apr 2023 01:56:01 +0000 Original-Received: (at 62426) by debbugs.gnu.org; 9 Apr 2023 01:55:15 +0000 Original-Received: from localhost ([127.0.0.1]:59959 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plKGw-0000CG-OF for submit@debbugs.gnu.org; Sat, 08 Apr 2023 21:55:15 -0400 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:43888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plKGv-0000Bq-I5 for 62426@debbugs.gnu.org; Sat, 08 Apr 2023 21:55:14 -0400 Original-Received: by mail-pl1-f169.google.com with SMTP id 20so3796502plk.10 for <62426@debbugs.gnu.org>; Sat, 08 Apr 2023 18:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681005308; x=1683597308; 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=3lYhRB92Hnebaai6Vpo2MN9JhssWOZUoKMIIFpBh/e0=; b=hJr1I4znu+9QmOx/sEfRbTKyOP1usNM2U4+8wohKQicK5eWPYJx0JPSBpjMbRq5Pg9 8FyBXc2XO90W4wBBI+x1GdFH75KIIBXmDOgLH2v3cqzAG+6y4GXd2ANli98GIKb7TUtz 4qmBF3eaNV7gIt5VMWIk9b98CdpHEZl6mQZMl6S50LkzgjBsqJTB0Z+92HIftP+eCHPG JsvcaYAalMXH5pw7FeJ2bDaij1em7ESinkuYKUdcOQnexoiibKyqnpS8a5VO9hrJi5r1 NgmjzF04jwGypt0kFQCNVH5VzXMIqzOxKJ93UuG3y/Teg71q8SLVlV9Tr/woVYRVNMWF JO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681005308; x=1683597308; 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=3lYhRB92Hnebaai6Vpo2MN9JhssWOZUoKMIIFpBh/e0=; b=mAuhTojERaRuG9rxd+f2pq62ivIhFnJ07s26vbD6arWkNskWnIRiUgNMs2b+bdoWLO XbCjQJUyyYBplZhr9qMmrIRSNHtniN7ouUuPwvmi/2lbzrge0YnEvTnaKwk0fgNhtgh7 kR7r91Jv211ABc4xNTXoaGuo1QnUh076LFvFbkr9HfjDjdtsk//cRqJ7KfvgCr+P3X8V 14IM9j+6oOxgWaV/FOe5Fz2iMIZ7pvg+UIZT8ZrH6KhHXERULuKazov6YisEkHPRT8c3 98+20MlKZvHx96Qz6D+D6UJRRrUW4ErSkyHJA/Vi68xYHfpeHoIDJPCOL97/JxpUlBf/ WlTw== X-Gm-Message-State: AAQBX9ef3nv5q6eIx0bj/8T225ApGe3S4JcxpQMxIJ9IPXB/KgMZSK1V LfWXpu9m9EHvGMuAkpYMbuQ= X-Google-Smtp-Source: AKy350Yx1uU4ssqtomlm7yPZoItQiypyIb4NCFdDRKucNyovqoC4NheNMzlbWLfskNY+jbvgoMdnow== X-Received: by 2002:a17:902:ced2:b0:19e:7a2c:78a7 with SMTP id d18-20020a170902ced200b0019e7a2c78a7mr9808950plg.57.1681005307562; Sat, 08 Apr 2023 18:55:07 -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 k22-20020a170902761600b0019cb6222691sm4819699pll.133.2023.04.08.18.55.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Apr 2023 18:55:07 -0700 (PDT) Content-Language: en-US In-Reply-To: <87355syce8.fsf@athena.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:259507 Archived-At: On 3/25/2023 10:22 AM, Sean Whitton wrote: > On Fri 24 Mar 2023 at 05:04PM -07, Jim Porter wrote: > >> That said, it might be a bit strange for Eshell's rgrep to work this way, when >> Eshell's agrep/egrep/fgrep work like the external versions. This seems like a >> tricky case... > > Tricky indeed. Here is an attempt: > > Normally with M-x rgrep one benefits from how Emacs prompts you > separately for the parameters to the function, right? In particular, > you get completion for the second and third parameters. Given that, > you're unlikely to want to type 'rgrep foo bar baz' into Eshell, and not > benefit from that completion, when you could just type M-x rgrep in the > same buffer, and benefit from it. > > Given this, I suggest rgrep in Eshell should be /usr/bin/rgrep. I've dug through the Eshell grep code over the last few days, and after some thinking, I agree that the initial patch is the right way to go. While I think it would be nice to get the benefits of M-x rgrep into Eshell, it's just too much of a deviation from the existing Eshell grep builtins. For example, M-x grep defaults to using "--color=auto", but eshell/grep doesn't: eshell/grep is (close to) what you'd get if you called /usr/bin/grep directly. It's all a bit strange though since eshell/grep forces you to have the flags "-nH" (file and line number) so that the compilation buffer works right. But Eshell sets those flags even when you're *not* using a compilation buffer (e.g. when piping the output of grep to some other process). I'm not sure it's the behavior I'd want, but it is the way it is, and I think it's too late to change it now. I just see one issue with the patch: the NEWS entry and docstring are a bit misleading. I know these are just copying from the existing Eshell functions, but this isn't really accurate: "Use Emacs grep facility instead of calling external rgrep." It *always* calls the external rgrep; it's just that sometimes the output goes into a compilation buffer. Instead, how about something like this? "Call the external rgrep program, opening its output in a compilation buffer when possible." (Plus similar changes to the other existing functions.) I think that makes it clearer what's actually happening. Anyway, sorry for the back and forth on this. This is a part of Eshell that I haven't looked at in much detail before, and I wanted to get a better sense of what our options were here.