Petr Hracek da86ac
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
Petr Hracek da86ac
index 9962945..763f906 100644
Petr Hracek da86ac
--- a/lisp/progmodes/grep.el
Petr Hracek da86ac
+++ b/lisp/progmodes/grep.el
Petr Hracek da86ac
@@ -77,11 +77,10 @@ in grep buffers, so if you have globally disabled font-lock-mode,
Petr Hracek da86ac
 you will not get highlighting.
Petr Hracek da86ac
 
Petr Hracek da86ac
 This option sets the environment variable GREP_COLORS to specify
Petr Hracek da86ac
-markers for highlighting and GREP_OPTIONS to add the --color
Petr Hracek da86ac
-option in front of any explicit grep options before starting
Petr Hracek da86ac
-the grep.
Petr Hracek da86ac
+markers for highlighting and adds the --color option in front of
Petr Hracek da86ac
+any explicit grep options before starting the grep.
Petr Hracek da86ac
 
Petr Hracek da86ac
-When this option is `auto', grep uses `--color=auto' to highlight
Petr Hracek da86ac
+When this option is `auto', grep uses `--color' to highlight
Petr Hracek da86ac
 matches only when it outputs to a terminal (when `grep' is the last
Petr Hracek da86ac
 command in the pipe), thus avoiding the use of any potentially-harmful
Petr Hracek da86ac
 escape sequences when standard output goes to a file or pipe.
Petr Hracek da86ac
@@ -97,7 +96,7 @@ To change the default value, use Customize or call the function
Petr Hracek da86ac
   :type '(choice (const :tag "Do not highlight matches with grep markers" nil)
Petr Hracek da86ac
 		 (const :tag "Highlight matches with grep markers" t)
Petr Hracek da86ac
 		 (const :tag "Use --color=always" always)
Petr Hracek da86ac
-		 (const :tag "Use --color=auto" auto)
Petr Hracek da86ac
+		 (const :tag "Use --color" auto)
Petr Hracek da86ac
 		 (other :tag "Not Set" auto-detect))
Petr Hracek da86ac
   :set 'grep-apply-setting
Petr Hracek da86ac
   :version "22.1"
Petr Hracek da86ac
@@ -467,10 +466,6 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
Petr Hracek da86ac
     ;; `setenv' modifies `process-environment' let-bound in `compilation-start'
Petr Hracek da86ac
     ;; Any TERM except "dumb" allows GNU grep to use `--color=auto'
Petr Hracek da86ac
     (setenv "TERM" "emacs-grep")
Petr Hracek da86ac
-    (setenv "GREP_OPTIONS"
Petr Hracek da86ac
-	    (concat (getenv "GREP_OPTIONS")
Petr Hracek da86ac
-		    " --color=" (if (eq grep-highlight-matches 'always)
Petr Hracek da86ac
-				    "always" "auto")))
Petr Hracek da86ac
     ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions
Petr Hracek da86ac
     (setenv "GREP_COLOR" "01;31")
Petr Hracek da86ac
     ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions
Petr Hracek da86ac
@@ -570,7 +565,13 @@ This function is called from `compilation-filter-hook'."
Petr Hracek da86ac
     (unless (and grep-command grep-find-command
Petr Hracek da86ac
 		 grep-template grep-find-template)
Petr Hracek da86ac
       (let ((grep-options
Petr Hracek da86ac
-	     (concat (if grep-use-null-device "-n" "-nH")
Petr Hracek da86ac
+	     (concat (and grep-highlight-matches
Petr Hracek da86ac
+                      (grep-probe grep-program
Petr Hracek da86ac
+                                  `(nil nil nil "--color" "x" ,null-device)
Petr Hracek da86ac
+                                  nil 1)
Petr Hracek da86ac
+                      (if (eq grep-highlight-matches 'always)
Petr Hracek da86ac
+                           "--color=always " "--color "))
Petr Hracek da86ac
+                 (if grep-use-null-device "-n" "-nH")
Petr Hracek da86ac
 		     (if (grep-probe grep-program
Petr Hracek da86ac
 				     `(nil nil nil "-e" "foo" ,null-device)
Petr Hracek da86ac
 				     nil 1)