help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep counting matches only with --color argument


From: Juri Linkov
Subject: Re: grep counting matches only with --color argument
Date: Tue, 02 Mar 2021 21:33:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]