emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117891: Don't assume 'grep' supports GREP_OPTIONS.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r117891: Don't assume 'grep' supports GREP_OPTIONS.
Date: Wed, 17 Sep 2014 00:07:17 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117891
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2014-09-16 17:07:12 -0700
message:
  Don't assume 'grep' supports GREP_OPTIONS.
  
  The GREP_OPTIONS environment variable is planned to be marked
  obsolescent in GNU grep, due to problems in its use, so stop
  relying on it.
  * progmodes/grep.el (grep-highlight-matches): Document this.
  (grep-process-setup): Do not set GREP_OPTIONS.
  (grep-compute-defaults): Use an explicit --color option if supported.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/grep.el         grep.el-20091113204419-o5vbwnq5f7feedwu-2948
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-09-16 00:28:28 +0000
+++ b/lisp/ChangeLog    2014-09-17 00:07:12 +0000
@@ -1,3 +1,13 @@
+2014-09-17  Paul Eggert  <address@hidden>
+
+       Don't assume 'grep' supports GREP_OPTIONS.
+       The GREP_OPTIONS environment variable is planned to be marked
+       obsolescent in GNU grep, due to problems in its use, so stop
+       relying on it.
+       * progmodes/grep.el (grep-highlight-matches): Document this.
+       (grep-process-setup): Do not set GREP_OPTIONS.
+       (grep-compute-defaults): Use an explicit --color option if supported.
+
 2014-09-16  Stefan Monnier  <address@hidden>
 
        * msb.el (msb--make-keymap-menu, msb-menu-bar-update-buffers):

=== modified file 'lisp/progmodes/grep.el'
--- a/lisp/progmodes/grep.el    2014-05-09 09:10:56 +0000
+++ b/lisp/progmodes/grep.el    2014-09-17 00:07:12 +0000
@@ -76,11 +76,10 @@
 you will not get highlighting.
 
 This option sets the environment variable GREP_COLORS to specify
-markers for highlighting and GREP_OPTIONS to add the --color
-option in front of any explicit grep options before starting
-the grep.
+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=auto' to highlight
+When this option is `auto', grep uses `--color' 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.
@@ -96,7 +95,7 @@
   :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" auto)
+                (const :tag "Use --color" auto)
                 (other :tag "Not Set" auto-detect))
   :set 'grep-apply-setting
   :version "22.1"
@@ -466,10 +465,6 @@
     ;; `setenv' modifies `process-environment' let-bound in `compilation-start'
     ;; Any TERM except "dumb" allows GNU grep to use `--color=auto'
     (setenv "TERM" "emacs-grep")
-    (setenv "GREP_OPTIONS"
-           (concat (getenv "GREP_OPTIONS")
-                   " --color=" (if (eq grep-highlight-matches 'always)
-                                   "always" "auto")))
     ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions
     (setenv "GREP_COLOR" "01;31")
     ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions
@@ -569,7 +564,13 @@
     (unless (and grep-command grep-find-command
                 grep-template grep-find-template)
       (let ((grep-options
-            (concat (if grep-use-null-device "-n" "-nH")
+            (concat (and grep-highlight-matches
+                         (grep-probe grep-program
+                                     `(nil nil nil "--color" "x" ,null-device)
+                                     nil 1)
+                         (if (eq grep-highlight-matches 'always)
+                             "--color=always " "--color "))
+                    (if grep-use-null-device "-n" "-nH")
                     (if (grep-probe grep-program
                                     `(nil nil nil "-e" "foo" ,null-device)
                                     nil 1)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]