GNU bug report logs - #76077
Add grep-hook in harmony with occur-hook

Previous Next

Package: emacs;

Reported by: Ship Mints <shipmints <at> gmail.com>

Date: Wed, 5 Feb 2025 19:08:02 UTC

Severity: normal

Merged with 76078

To reply to this bug, email your comments to 76077 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#76077; Package emacs. (Wed, 05 Feb 2025 19:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ship Mints <shipmints <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 05 Feb 2025 19:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ship Mints <shipmints <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Add grep-hook in harmony with occur-hook
Date: Wed, 5 Feb 2025 14:04:48 -0500
[Message part 1 (text/plain, inline)]
grep is missing a hook similar to occur-hook. It is very useful to know
when results are returned and also to perform operations on the resulting
buffer.

I took a look at debbugs and could not find any history of discussion.

-Stephane
[Message part 2 (text/html, inline)]

Merged 76077 76078. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 05 Feb 2025 20:25:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76077; Package emacs. (Thu, 06 Feb 2025 07:41:02 GMT) Full text and rfc822 format available.

Message #10 received at 76077 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 76077 <at> debbugs.gnu.org
Subject: Re: bug#76077: Add grep-hook in harmony with occur-hook
Date: Thu, 06 Feb 2025 09:39:11 +0200
> grep is missing a hook similar to occur-hook. It is very useful to know
> when results are returned and also to perform operations on the resulting
> buffer.

Does this work for you?

#+begin_src emacs-lisp
(add-hook 'compilation-finish-functions
          (lambda (cur-buffer msg)
            (when (and (string-match-p "finished" msg)
                       (eq (with-current-buffer cur-buffer major-mode)
                           'grep-mode)) ;; i.e. not compilation-mode
              (message "Grep finished in %s" cur-buffer))))
#+end_src




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76077; Package emacs. (Thu, 06 Feb 2025 11:35:02 GMT) Full text and rfc822 format available.

Message #13 received at 76077 <at> debbugs.gnu.org (full text, mbox):

From: Ship Mints <shipmints <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 76077 <at> debbugs.gnu.org
Subject: Re: bug#76077: Add grep-hook in harmony with occur-hook
Date: Thu, 6 Feb 2025 06:32:42 -0500
[Message part 1 (text/plain, inline)]
Great. I've adapted this to my purpose. Thank you.

I suppose this is now memorialized on the mailing list should anyone want
to search it up.

-Stephane

On Thu, Feb 6, 2025 at 2:40 AM Juri Linkov <juri <at> linkov.net> wrote:

> > grep is missing a hook similar to occur-hook. It is very useful to know
> > when results are returned and also to perform operations on the resulting
> > buffer.
>
> Does this work for you?
>
> #+begin_src emacs-lisp
> (add-hook 'compilation-finish-functions
>           (lambda (cur-buffer msg)
>             (when (and (string-match-p "finished" msg)
>                        (eq (with-current-buffer cur-buffer major-mode)
>                            'grep-mode)) ;; i.e. not compilation-mode
>               (message "Grep finished in %s" cur-buffer))))
> #+end_src
>
[Message part 2 (text/html, inline)]

This bug report was last modified 192 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.