aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2004-09-02 16:35:42 +0000
committerJuri Linkov2004-09-02 16:35:42 +0000
commit277df08871a1da3b83e648af97e336861c1b8742 (patch)
tree6c6d2fd3fc127f0e6d7d2561ce261b9f174ba744
parent9dc3a46a444a46e00ed3287a3174d73ed9511dac (diff)
downloademacs-277df08871a1da3b83e648af97e336861c1b8742.tar.gz
emacs-277df08871a1da3b83e648af97e336861c1b8742.zip
(grep-highlight-matches): New defcustom.
(grep-regexp-alist): Add rule to highlight grep matches. (grep-process-setup): Set env-vars GREP_OPTIONS and GREP_COLOR.
-rw-r--r--lisp/progmodes/grep.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index f4acd564a3c..9d48fd37569 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -64,6 +64,21 @@ will be parsed and highlighted as soon as you try to move to them."
64 :version "21.4" 64 :version "21.4"
65 :group 'grep) 65 :group 'grep)
66 66
67(defcustom grep-highlight-matches t
68 "*Non-nil to use special markers to highlight grep matches.
69
70Some grep programs are able to surround matches with special
71markers in grep output. Such markers can be used to highlight
72matches in grep mode.
73
74This option sets the environment variable GREP_COLOR to specify
75markers for highlighting and GREP_OPTIONS to add the --color
76option in front of any explicit grep options before starting
77the grep."
78 :type 'boolean
79 :version "21.4"
80 :group 'grep)
81
67(defcustom grep-scroll-output nil 82(defcustom grep-scroll-output nil
68 "*Non-nil to scroll the *grep* buffer window as output appears. 83 "*Non-nil to scroll the *grep* buffer window as output appears.
69 84
@@ -230,6 +245,23 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
230 '(("^\\(.+?\\)[:( \t]+\ 245 '(("^\\(.+?\\)[:( \t]+\
231\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\ 246\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
232\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6)) 247\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6))
248 ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
249 1 2
250 ((lambda ()
251 (setq compilation-error-screen-columns nil)
252 (- (match-beginning 5) (match-end 3) 8))
253 .
254 (lambda () (- (match-end 5) (match-end 3) 8)))
255 nil nil
256 (4 (list 'face nil 'invisible t 'intangible t))
257 (5 (list 'face compilation-column-face))
258 (6 (list 'face nil 'invisible t 'intangible t))
259 ;; highlight other matches on the same line
260 ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
261 nil nil
262 (1 (list 'face nil 'invisible t 'intangible t))
263 (2 (list 'face compilation-column-face) t)
264 (3 (list 'face nil 'invisible t 'intangible t))))
233 ("^Binary file \\(.+\\) matches$" 1 nil nil 1)) 265 ("^Binary file \\(.+\\) matches$" 1 nil nil 1))
234 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") 266 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
235 267
@@ -300,6 +332,10 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
300(defun grep-process-setup () 332(defun grep-process-setup ()
301 "Setup compilation variables and buffer for `grep'. 333 "Setup compilation variables and buffer for `grep'.
302Set up `compilation-exit-message-function' and run `grep-setup-hook'." 334Set up `compilation-exit-message-function' and run `grep-setup-hook'."
335 (when grep-highlight-matches
336 ;; Modify `process-environment' locally bound in `compilation-start'
337 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
338 (setenv "GREP_COLOR" "01;41"))
303 (set (make-local-variable 'compilation-exit-message-function) 339 (set (make-local-variable 'compilation-exit-message-function)
304 (lambda (status code msg) 340 (lambda (status code msg)
305 (if (eq status 'exit) 341 (if (eq status 'exit)