diff options
author | Lennart Borgman <lennart.borgman@gmail.com> | 2021-07-17 16:53:36 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-17 16:53:36 +0200 |
commit | 9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99 (patch) | |
tree | 377c54249da1239046e30c02fdc9da9efd272a2f /lisp/progmodes/grep.el | |
parent | b4b0c219a15f31aecd43f81c9e87cdf4dca57e37 (diff) | |
download | emacs-9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99.tar.gz |
Add new function 'grep-file-at-point'
* lisp/progmodes/grep.el (grep-file-at-point): New function to
return the file name at point (bug#8252).
Diffstat (limited to 'lisp/progmodes/grep.el')
-rw-r--r-- | lisp/progmodes/grep.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 462ea51e2ce..370bdd55163 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -1345,6 +1345,13 @@ command before it's run." (grep-highlight-matches 'always)) (rgrep regexp files dir confirm))) +(defun grep-file-at-point (point) + "Return the name of the file at POINT a `grep-mode' buffer. +The returned file name is relative." + (when-let ((msg (get-text-property (point) 'compilation-message)) + (loc (compilation--message->loc msg))) + (caar (compilation--loc->file-struct loc)))) + ;;;###autoload (defalias 'rzgrep 'zrgrep) |