summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2020-12-29 21:41:24 +0200
committerJuri Linkov <juri@linkov.net>2020-12-29 21:41:24 +0200
commit0a82e66db42a5cb81cf54b904c20410cf9218f8f (patch)
treee5b150ae8bcec5520c5fec489e85e7f66ac550b8
parentc13937ccb6c9ebf7a1dd9eaa7eb6bb3768409093 (diff)
downloademacs-0a82e66db42a5cb81cf54b904c20410cf9218f8f.tar.gz
Use explicit "--color=auto" in grep mode to support both GNU grep and ripgrep
* lisp/progmodes/grep.el (grep-highlight-matches): (grep-compute-defaults, grep-expand-template): Use "--color=auto" instead of "--color" (bug#44983).
-rw-r--r--lisp/progmodes/grep.el8
1 files changed, 4 insertions, 4 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 5dc99cc7e93..ef73dac4c0a 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -79,7 +79,7 @@ This option sets the environment variable GREP_COLORS to specify
markers for highlighting and adds the --color option in front of
any explicit grep options before starting the grep.
-When this option is `auto', grep uses `--color' to highlight
+When this option is `auto', grep uses `--color=auto' to highlight
matches only when it outputs to a terminal (when `grep' is the last
command in the pipe), thus avoiding the use of any potentially-harmful
escape sequences when standard output goes to a file or pipe.
@@ -95,7 +95,7 @@ To change the default value, use \\[customize] or call the function
:type '(choice (const :tag "Do not highlight matches with grep markers" nil)
(const :tag "Highlight matches with grep markers" t)
(const :tag "Use --color=always" always)
- (const :tag "Use --color" auto)
+ (const :tag "Use --color=auto" auto)
(other :tag "Not Set" auto-detect))
:set #'grep-apply-setting
:version "22.1")
@@ -743,7 +743,7 @@ The value depends on `grep-command', `grep-template',
`(nil nil nil "--color" "x" ,(null-device))
nil 1)
(if (eq grep-highlight-matches 'always)
- "--color=always" "--color"))
+ "--color=always" "--color=auto"))
"")
grep-options)))
(unless grep-template
@@ -1000,7 +1000,7 @@ these include `opts', `dir', `files', `null-device', `excl' and
((eq grep-highlight-matches 'always)
(push "--color=always" opts))
((eq grep-highlight-matches 'auto)
- (push "--color" opts)))
+ (push "--color=auto" opts)))
opts))
(excl . ,excl)
(dir . ,dir)