From: Juri Linkov <juri@linkov.net>
To: Tomas Hlavaty <tom@logand.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: grep counting matches only with --color argument
Date: Tue, 02 Mar 2021 21:33:57 +0200 [thread overview]
Message-ID: <87wnup4elu.fsf@mail.linkov.net> (raw)
In-Reply-To: <87lfb9t8i5.fsf@logand.com> (Tomas Hlavaty's message of "Sun, 28 Feb 2021 00:07:30 +0100")
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.
next prev parent reply other threads:[~2021-03-02 19:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-27 23:07 grep counting matches only with --color argument Tomas Hlavaty
2021-03-02 19:33 ` Juri Linkov [this message]
2021-03-02 21:33 ` Tomas Hlavaty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnup4elu.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=help-gnu-emacs@gnu.org \
--cc=tom@logand.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).