From a5b920a604737d3a0b6812acf97c30e4200d33ab Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Mon, 21 Apr 2025 16:25:06 +0200 Subject: [PATCH] Don't consider "Grep finished" lines as matches for file names * lisp/progmodes/grep.el (grep-compilation-transform-finished-rules): New variable containing rules to prevent "Grep finished" lines from being misinterpreted as matches for file names. (grep-mode): Add these rules to 'compilation-transform-file-match-alist' (bug#77732). (cherry picked from commit dd3429526aacef0aa98171a598a535a72b9cde39) --- lisp/progmodes/grep.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index eee88faf21e..c395be14c1b 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -542,6 +542,13 @@ redundant).") "Additional things to highlight in grep output. This gets tacked on the end of the generated expressions.") +(defvar grep-compilation-transform-finished-rules + '(("^Grep[/a-zA-Z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?match\\(?:es\\)? found\\)\\|\\(no matches found\\)\\).*" . nil) + ("^Grep[/a-zA-Z]* \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*" . nil)) + "Rules added to `compilation-transform-file-match-alist' in `grep-mode' +These prevent the \"Grep finished\" lines from being misinterpreted as +matches (bug#77732).") + ;;;###autoload (defvar grep-program "grep" "The default grep program for `grep-command' and `grep-find-command'. @@ -971,6 +978,9 @@ The value depends on `grep-command', `grep-template', grep-hit-face) (setq-local compilation-error-regexp-alist grep-regexp-alist) + (setq-local compilation-transform-file-match-alist + (append grep-compilation-transform-finished-rules + compilation-transform-file-match-alist)) (setq-local compilation-mode-line-errors grep-mode-line-matches) ;; compilation-directory-matcher can't be nil, so we set it to a regexp that -- 2.39.5