all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

* Re: grep counting matches only with --color argument
  2021-03-02 19:33 ` Juri Linkov
@ 2021-03-02 21:33   ` Tomas Hlavaty
  0 siblings, 0 replies; 3+ messages in thread
From: Tomas Hlavaty @ 2021-03-02 21:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: help-gnu-emacs

On Tue 02 Mar 2021 at 21:33, Juri Linkov <juri@linkov.net> wrote:
> grep.el in Emacs 28 was fixed 2-3 months ago to support ripgrep
> matches.

That's good news, I'll just wait for Emacs 28 then.

Thanks a lot!



^ 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.