[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d858a63: More robust auto-detect of grep-highlight-matches (bug#4
From: |
Mattias Engdegård |
Subject: |
master d858a63: More robust auto-detect of grep-highlight-matches (bug#49978) |
Date: |
Tue, 10 Aug 2021 11:13:41 -0400 (EDT) |
branch: master
commit d858a637c2ef35079fbc6cd8b2674c6b13de1e99
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
More robust auto-detect of grep-highlight-matches (bug#49978)
* lisp/progmodes/grep.el (grep-compute-defaults):
Don't require "grep --help" to finish with exit status 0 (BSD grep
does not) and check the output in a slightly more robust way.
---
lisp/progmodes/grep.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 8f0a5ac..b2a9b3e 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -696,11 +696,12 @@ The value depends on `grep-command', `grep-template',
(when (eq grep-highlight-matches 'auto-detect)
(setq grep-highlight-matches
(with-temp-buffer
- (and (grep-probe grep-program '(nil t nil "--help"))
- (progn
- (goto-char (point-min))
- (search-forward "--color" nil t))
- ;; Windows and DOS pipes fail `isatty' detection in Grep.
+ ;; The "grep --help" exit status varies; pay no attention to it.
+ (grep-probe grep-program '(nil t nil "--help"))
+ (goto-char (point-min))
+ (and (let ((case-fold-search nil))
+ (re-search-forward (rx "--color" (not (in "a-z"))) nil t))
+ ;; Windows and DOS pipes fail `isatty' detection in Grep.
(if (memq system-type '(windows-nt ms-dos))
'always 'auto)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master d858a63: More robust auto-detect of grep-highlight-matches (bug#49978),
Mattias Engdegård <=