From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.help Subject: Re: grep counting matches only with --color argument Date: Tue, 02 Mar 2021 21:33:57 +0200 Organization: LINKOV.NET Message-ID: <87wnup4elu.fsf@mail.linkov.net> References: <87lfb9t8i5.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28920"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: help-gnu-emacs@gnu.org To: Tomas Hlavaty Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 02 20:44:03 2021 Return-path: Envelope-to: geh-help-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 1lHAw7-0007Oh-Dj for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 02 Mar 2021 20:44:03 +0100 Original-Received: from localhost ([::1]:59310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHAw6-00029g-77 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 02 Mar 2021 14:44:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHAvF-00027z-QI for help-gnu-emacs@gnu.org; Tue, 02 Mar 2021 14:43:09 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:45737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHAvD-0006ZP-LW for help-gnu-emacs@gnu.org; Tue, 02 Mar 2021 14:43:09 -0500 X-Originating-IP: 91.129.96.116 Original-Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116]) (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 1C6F960004; Tue, 2 Mar 2021 19:42:58 +0000 (UTC) In-Reply-To: <87lfb9t8i5.fsf@logand.com> (Tomas Hlavaty's message of "Sun, 28 Feb 2021 00:07:30 +0100") Received-SPF: pass client-ip=217.70.183.195; envelope-from=juri@linkov.net; helo=relay3-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128344 Archived-At: Hi Tomas, > why does this command shows the number of matches in the mode-line > > (grep "grep -r --color -nH -e TODO ~/git/emacs-pdf") > > but this one (without --color argument) always shows 0? > > (grep "grep -r -nH -e TODO ~/git/emacs-pdf") > > Is there a deeper reason that --color is required to see the number of > matches? Could it simply count the number of matched lines if no > --color was specified? Or is it not easy to detect? Not easy to detect, indeed. Emacs regexp functions can't be used to find Grep input regexps in the Grep output. > I would like to see the number of matches with alternative programs like > ripgrep: > > (grep "rg -nH --no-heading --color=always -e TODO ~/git/emacs-pdf") > (grep "rg -nH --no-heading --color=ansi -e TODO ~/git/emacs-pdf") > > But the --color argument here does not seem to have an effect. grep.el in Emacs 28 was fixed 2-3 months ago to support ripgrep matches.