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

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

Re: When grep-find, show the count of matches


From: Tim Landscheidt
Subject: Re: When grep-find, show the count of matches
Date: Mon, 28 Jun 2010 13:51:04 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

filebat Mark <filebat.mark@gmail.com> wrote:

>> > I am wondering how to show the count of matches when grep-find. Like the
>> > following.
>> > ,-----------
>> > | -*- mode: grep; default-directory:
>> > "d:/ntemacs23/myemacs/private_data/out_of_svn/" -*-
>> > | Grep started at Mon Jun 28 17:46:18
>> > |
>> > |  find . -name ".svn" -prune -o -type f -print0 | xargs -0 -e grep -inH
>> -e
>> > emacs
>> > | ./#tmp.txt#:7:#+TAGS: ARCHIVE(a) WEBPAGE(w) LIFE(l) EMACS(e)
>> IMPORTANT(i)
>> > HARD(h) COMPUTER(c) RECOMMENDATE(r) Tool(t)
>> > | ./#tmp.txt#:47438:* TODO log4j-mode in emacs
>> > | ./#tmp.txt#:47529:Hi emacsers
>> > | ./tmp.html:554:<p class="creator">HTML generated by org-mode 6.35i in
>> > emacs 23</p>
>> > | ./tmp.html~:153:<p class="creator">HTML generated by org-mode 6.35i in
>> > emacs 23</p>
>> > | ./tmp.txt:7:#+TAGS: ARCHIVE(a) WEBPAGE(w) LIFE(l) EMACS(e) IMPORTANT(i)
>> > HARD(h) COMPUTER(c) RECOMMENDATE(r) Tool(t)
>> > | ./tmp.txt:47438:* TODO log4j-mode in emacs
>> > |
>> > | Grep finished (7 matches found) at Mon Jun 28 17:46:20
>> > `-----------

>> > IMHO, one feasible way may be counting the output of *grep* buffer.
>> > Before moving any further, I am very willing to hear your ideas, comment
>> or
>> > codesnipet for this?

>> - "find ... | xargs -0r grep ... | wc -l"?
>> - "find ... | xargs -0r cat | grep -c"?
>> - Read "(7 matches found)"?

> Your commands can help to count the matches, however my point is to get both
> the matches and the count of how many matches. ^-^

Your point /was/ "how to show the count of matches". For
your current point, you could:

a) put something like:

   | (save-excursion
   |   (set-buffer "*grep*")
   |   (message
   |    "%d matches found"
   |    (- (count-lines (point-min) (point-max))
   |       6)))

   on a hot key,

b) defadvice grep-process-setup/set grep-setup-hook so that
   the above will be executed when grep finishes.

Tim




reply via email to

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