]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't consider "Grep finished" lines as matches for file names
authorPaul Nelson <ultrono@gmail.com>
Mon, 21 Apr 2025 14:25:06 +0000 (16:25 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 26 Apr 2025 17:36:58 +0000 (19:36 +0200)
* 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

index eee88faf21e972e332d281de29883ef7f75c4308..c395be14c1b9dc9bc40446e04c240dd430c653af 100644 (file)
@@ -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