summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2004-09-02 16:35:42 +0000
committerJuri Linkov <juri@jurta.org>2004-09-02 16:35:42 +0000
commit18f8546887793d79af16ebb4a7e0243b91774beb (patch)
tree17748c98bf191c41d9e330a47d9891f7d1c414a4 /lisp
parentaa06eb19f8d31a88eb3ac8ed63887a97b9967c4a (diff)
downloademacs-18f8546887793d79af16ebb4a7e0243b91774beb.tar.gz
(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.
Diffstat (limited to 'lisp')
-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."
:version "21.4"
:group 'grep)
+(defcustom grep-highlight-matches t
+ "*Non-nil to use special markers to highlight grep matches.
+
+Some grep programs are able to surround matches with special
+markers in grep output. Such markers can be used to highlight
+matches in grep mode.
+
+This option sets the environment variable GREP_COLOR to specify
+markers for highlighting and GREP_OPTIONS to add the --color
+option in front of any explicit grep options before starting
+the grep."
+ :type 'boolean
+ :version "21.4"
+ :group 'grep)
+
(defcustom grep-scroll-output nil
"*Non-nil to scroll the *grep* buffer window as output appears.
@@ -230,6 +245,23 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
'(("^\\(.+?\\)[:( \t]+\
\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6))
+ ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+ 1 2
+ ((lambda ()
+ (setq compilation-error-screen-columns nil)
+ (- (match-beginning 5) (match-end 3) 8))
+ .
+ (lambda () (- (match-end 5) (match-end 3) 8)))
+ nil nil
+ (4 (list 'face nil 'invisible t 'intangible t))
+ (5 (list 'face compilation-column-face))
+ (6 (list 'face nil 'invisible t 'intangible t))
+ ;; highlight other matches on the same line
+ ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+ nil nil
+ (1 (list 'face nil 'invisible t 'intangible t))
+ (2 (list 'face compilation-column-face) t)
+ (3 (list 'face nil 'invisible t 'intangible t))))
("^Binary file \\(.+\\) matches$" 1 nil nil 1))
"Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
@@ -300,6 +332,10 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
(defun grep-process-setup ()
"Setup compilation variables and buffer for `grep'.
Set up `compilation-exit-message-function' and run `grep-setup-hook'."
+ (when grep-highlight-matches
+ ;; Modify `process-environment' locally bound in `compilation-start'
+ (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
+ (setenv "GREP_COLOR" "01;41"))
(set (make-local-variable 'compilation-exit-message-function)
(lambda (status code msg)
(if (eq status 'exit)