unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: help-gnu-emacs@gnu.org
Subject: Re: When grep-find, show the count of matches
Date: Mon, 28 Jun 2010 17:59:05 +0000	[thread overview]
Message-ID: <m3tyonqbrq.fsf@passepartout.tim-landscheidt.de> (raw)
In-Reply-To: AANLkTimJkv619lE9tYQYnl3wqJiHxp4BX8-wZTZOMsTF@mail.gmail.com

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

> Thank you very much, Tim. Sorry for my confusing illustration.

> You have point a good way to solve my problem. Changing grep-process-setup
> seems don't work, so I change the function of grep-find.

> One slight problem is that, since the grep command takes some time, even
> though we define an after-defadive, the function is executed before *grep*
> buffer is stable.

> My workaround is to sleep for some while. No idea whether we have better
> solution.

> (defadvice grep-find (after show-grep())
>  (save-excursion
>    (setq SLEEP_INTERVAL 2)
>    (set-buffer "*grep*")
>    (sleep-for SLEEP_INTERVAL)
>    (message
>     "%d matches found"
>     (- (count-lines (point-min) (point-max)) 6))
>    )
> )
> (ad-activate 'grep-find)
> [...]

No, you should defadvice *around* grep-process-setup, copy
the whole original from the Emacs distribution, and replace
the lambda construct in:

|   (set (make-local-variable 'compilation-exit-message-function)
|        (lambda (status code msg)
|          (if (eq status 'exit)
|              (cond ((zerop code)
|                     '("finished (matches found)\n" . "matched"))
|                    ((= code 1)
|                     '("finished with no matches found\n" . "no match"))
|                    (t
|                     (cons msg code)))
|            (cons msg code))))

with another that inserts the number of matches into the
buffer.

Tim




  reply	other threads:[~2010-06-28 17:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-28  9:59 When grep-find, show the count of matches filebat Mark
2010-06-28 11:33 ` Tim Landscheidt
2010-06-28 13:23   ` filebat Mark
2010-06-28 13:51     ` Tim Landscheidt
2010-06-28 15:57       ` filebat Mark
2010-06-28 17:59         ` Tim Landscheidt [this message]
2010-06-29  5:04           ` Kevin Rodgers
     [not found]         ` <mailman.1.1277747970.703.help-gnu-emacs@gnu.org>
2010-06-28 18:40           ` Andreas Politz

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=m3tyonqbrq.fsf@passepartout.tim-landscheidt.de \
    --to=tim@tim-landscheidt.de \
    --cc=help-gnu-emacs@gnu.org \
    /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).