* grep counting matches only with --color argument
@ 2021-02-27 23:07 Tomas Hlavaty
2021-03-02 19:33 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Tomas Hlavaty @ 2021-02-27 23:07 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
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?
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.
Thanks in advance,
Tomas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: grep counting matches only with --color argument
2021-02-27 23:07 grep counting matches only with --color argument Tomas Hlavaty
@ 2021-03-02 19:33 ` Juri Linkov
2021-03-02 21:33 ` Tomas Hlavaty
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2021-03-02 19:33 UTC (permalink / raw)
To: Tomas Hlavaty; +Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-02 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-27 23:07 grep counting matches only with --color argument Tomas Hlavaty
2021-03-02 19:33 ` Juri Linkov
2021-03-02 21:33 ` Tomas Hlavaty
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).