diff options
| author | Lennart Borgman | 2021-07-17 16:53:36 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-07-17 16:53:36 +0200 |
| commit | 9ee418b7b95e20fa4d8ae585f33e9b5d9316bc99 (patch) | |
| tree | 377c54249da1239046e30c02fdc9da9efd272a2f | |
| parent | b4b0c219a15f31aecd43f81c9e87cdf4dca57e37 (diff) | |
| download | emacs-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/NEWS | 5 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 7 |
2 files changed, 12 insertions, 0 deletions
| @@ -1153,6 +1153,11 @@ any directory names on the 'find' command lines end in a slash. | |||
| 1153 | This change is for better compatibility with old versions of non-GNU | 1153 | This 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'. | ||
| 1158 | This returns the name of the file at point (if any) in 'grep-mode' | ||
| 1159 | buffers. | ||
| 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. | ||
| 1350 | The 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 | ||