aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Borgman2021-07-17 16:53:36 +0200
committerLars Ingebrigtsen2021-07-17 16:53:36 +0200
commit9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99 (patch)
tree377c54249da1239046e30c02fdc9da9efd272a2f
parentb4b0c219a15f31aecd43f81c9e87cdf4dca57e37 (diff)
downloademacs-9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99.tar.gz
emacs-9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99.zip
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).
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/progmodes/grep.el7
2 files changed, 12 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 4bfb5b4d165..88d8fbe4b89 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1153,6 +1153,11 @@ any directory names on the 'find' command lines end in a slash.
1153This change is for better compatibility with old versions of non-GNU 1153This change is for better compatibility with old versions of non-GNU
1154'find', such as the one used on macOS. 1154'find', such as the one used on macOS.
1155 1155
1156---
1157*** New utility function 'grep-file-at-point'.
1158This returns the name of the file at point (if any) in 'grep-mode'
1159buffers.
1160
1156** Help 1161** Help
1157 1162
1158+++ 1163+++
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."
1345 (grep-highlight-matches 'always)) 1345 (grep-highlight-matches 'always))
1346 (rgrep regexp files dir confirm))) 1346 (rgrep regexp files dir confirm)))
1347 1347
1348(defun grep-file-at-point (point)
1349 "Return the name of the file at POINT a `grep-mode' buffer.
1350The returned file name is relative."
1351 (when-let ((msg (get-text-property (point) 'compilation-message))
1352 (loc (compilation--message->loc msg)))
1353 (caar (compilation--loc->file-struct loc))))
1354
1348;;;###autoload 1355;;;###autoload
1349(defalias 'rzgrep 'zrgrep) 1356(defalias 'rzgrep 'zrgrep)
1350 1357