[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: When grep-find, show the count of matches
From: |
Andreas Politz |
Subject: |
Re: When grep-find, show the count of matches |
Date: |
Wed, 08 Dec 2010 15:16:09 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Tim Landscheidt <tim@tim-landscheidt.de> writes:
> 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
Why use a `hack', if there is a defined way of doing these things
(`grep-setup-hook') ?
-ap
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: When grep-find, show the count of matches,
Andreas Politz <=