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 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 >