aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2004-09-07 18:10:49 +0000
committerJuri Linkov2004-09-07 18:10:49 +0000
commita58c94a2271c0ce77f72eca6561902afa10597cf (patch)
tree3fe8f04a49aa4760ed671135fa659ceff6fdc4a5
parent1806714ad86e47cc6692207a3bcd3223b8df5972 (diff)
downloademacs-a58c94a2271c0ce77f72eca6561902afa10597cf.tar.gz
emacs-a58c94a2271c0ce77f72eca6561902afa10597cf.zip
(grep-highlight-matches): Doc fix.
(grep-process-setup): Call `grep-compute-defaults' if `grep-highlight-matches' is not computed. Set env-vars only if `grep-highlight-matches' is `t'.
-rw-r--r--lisp/progmodes/grep.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 8302b8e7987..ddfca946a78 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -65,7 +65,7 @@ will be parsed and highlighted as soon as you try to move to them."
65 :group 'grep) 65 :group 'grep)
66 66
67(defcustom grep-highlight-matches 'auto-detect 67(defcustom grep-highlight-matches 'auto-detect
68 "*If t, use special markers to highlight grep matches. 68 "If t, use special markers to highlight grep matches.
69 69
70Some grep programs are able to surround matches with special 70Some grep programs are able to surround matches with special
71markers in grep output. Such markers can be used to highlight 71markers in grep output. Such markers can be used to highlight
@@ -74,7 +74,10 @@ matches in grep mode.
74This option sets the environment variable GREP_COLOR to specify 74This option sets the environment variable GREP_COLOR to specify
75markers for highlighting and GREP_OPTIONS to add the --color 75markers for highlighting and GREP_OPTIONS to add the --color
76option in front of any explicit grep options before starting 76option in front of any explicit grep options before starting
77the grep." 77the grep.
78
79The default value of this variable is set up by `grep-compute-defaults';
80call that function before using this variable in your program."
78 :type '(choice (const :tag "Do not highlight matches with grep markers" nil) 81 :type '(choice (const :tag "Do not highlight matches with grep markers" nil)
79 (const :tag "Highlight matches with grep markers" t) 82 (const :tag "Highlight matches with grep markers" t)
80 (other :tag "Not Set" auto-detect)) 83 (other :tag "Not Set" auto-detect))
@@ -334,7 +337,9 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
334(defun grep-process-setup () 337(defun grep-process-setup ()
335 "Setup compilation variables and buffer for `grep'. 338 "Setup compilation variables and buffer for `grep'.
336Set up `compilation-exit-message-function' and run `grep-setup-hook'." 339Set up `compilation-exit-message-function' and run `grep-setup-hook'."
337 (when grep-highlight-matches 340 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t))
341 (grep-compute-defaults))
342 (when (eq grep-highlight-matches t)
338 ;; Modify `process-environment' locally bound in `compilation-start' 343 ;; Modify `process-environment' locally bound in `compilation-start'
339 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always")) 344 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
340 (setenv "GREP_COLOR" "01;41")) 345 (setenv "GREP_COLOR" "01;41"))
@@ -420,14 +425,14 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
420 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t)) 425 (unless (or (not grep-highlight-matches) (eq grep-highlight-matches t))
421 (setq grep-highlight-matches 426 (setq grep-highlight-matches
422 (with-temp-buffer 427 (with-temp-buffer
423 (and (equal (condition-case nil 428 (and (equal (condition-case nil
424 (call-process grep-program nil t nil "--help") 429 (call-process grep-program nil t nil "--help")
425 (error nil)) 430 (error nil))
426 0) 431 0)
427 (progn 432 (progn
428 (goto-char (point-min)) 433 (goto-char (point-min))
429 (search-forward "--color" nil t)) 434 (search-forward "--color" nil t))
430 t))))) 435 t)))))
431 436
432(defun grep-default-command () 437(defun grep-default-command ()
433 (let ((tag-default 438 (let ((tag-default