Subject: bug#8252: Please add a function to get files in *grep*

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 17 Jul 2021 16:54:56 +0200

Lennart Borgman <[email-masked]> writes:

> For example something like this (which I just added to
> ourcomments-util.el in nXhtml) works now:
>
> (defun grep-grepped-file (pt)
>   "Return grepped file at PT in a `grep-mode' buffer.
> The returned file name is relative."
>   (let* ((msg (get-text-property (point) 'compilation-message))
>          (loc (when msg (compilation--message->loc msg)))
>          (file (when loc (caar (compilation--loc->file-struct loc)))))
>     file))

I think that sounds generally useful -- writing things on top of grep
mode is quite popular, and it isn't obvious how to get at the file name
(which is what people generally want).  So I've added your function to
Emacs 28 (with some minor tweaks) under the name `grep-file-at-point'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no