Commit 983203ee authored by Juri Linkov's avatar Juri Linkov
Browse files

(grep-regexp-alist)

(grep-mode-font-lock-keywords, grep-process-setup):
Use default GNU grep match color "01;31m" instead of "01;41m".
(grep-regexp-alist, grep-mode-font-lock-keywords):
Use `\\[[0-9]*m' instead of `\\[00m'.
(grep-regexp-alist): Move `\\(?:\033\\[K\\)?' from sgr_end to
sgr_start where its handling is more important.  Use the real
length of sgr_start instead of constant 8.
(grep-mode-font-lock-keywords): Don't delete `\\(?:\033\\[K\\)?'
specially.  Delete all remaining escape sequences.
(grep-process-setup): Set "GREP_COLORS" for GNU grep 2.5.1-cvs.
(grep-regexp-alist): Make hyperlink only for binary file name
instead of the whole line.
(grep-mode-map): Bind `backtab' to `compilation-previous-file'.
(grep-mode): Add autoload.
parent 4a397e9a
...@@ -196,6 +196,7 @@ See `compilation-error-screen-columns'" ...@@ -196,6 +196,7 @@ See `compilation-error-screen-columns'"
(define-key map "p" 'previous-error-no-select) (define-key map "p" 'previous-error-no-select)
(define-key map "{" 'compilation-previous-file) (define-key map "{" 'compilation-previous-file)
(define-key map "}" 'compilation-next-file) (define-key map "}" 'compilation-next-file)
(define-key map [backtab] 'compilation-previous-file)
(define-key map "\t" 'compilation-next-file) (define-key map "\t" 'compilation-next-file)
;; Set up the menu-bar ;; Set up the menu-bar
...@@ -255,16 +256,17 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies ...@@ -255,16 +256,17 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
\\(?:-\\(?:\\([0-9]+\\)\\4\\)?\\.?\\([0-9]+\\)?\\)?\\2" \\(?:-\\(?:\\([0-9]+\\)\\4\\)?\\.?\\([0-9]+\\)?\\)?\\2"
1 (3 . 6) (5 . 7)) 1 (3 . 6) (5 . 7))
("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\ ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\
\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\(?:\033\\[K\\)?\\)" \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
2 3 2 3
;; Calculate column positions (beg . end) of first grep match on a line ;; Calculate column positions (beg . end) of first grep match on a line
((lambda () ((lambda ()
(setq compilation-error-screen-columns nil) (setq compilation-error-screen-columns nil)
(- (match-beginning 5) (match-end 1) 8)) (- (match-beginning 4) (match-end 1)))
. .
(lambda () (- (match-end 5) (match-end 1) 8))) (lambda () (- (match-end 5) (match-end 1)
(- (match-end 4) (match-beginning 4)))))
nil 1) nil 1)
("^Binary file \\(.+\\) matches$" 1 nil nil 1)) ("^Binary file \\(.+\\) matches$" 1 nil nil 1 1))
"Regexp used to match grep hits. See `compilation-error-regexp-alist'.") "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
(defvar grep-error "grep hit" (defvar grep-error "grep hit"
...@@ -296,17 +298,21 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies ...@@ -296,17 +298,21 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
(1 compilation-warning-face) (1 compilation-warning-face)
(2 compilation-line-face)) (2 compilation-line-face))
;; Highlight grep matches and delete markers ;; Highlight grep matches and delete markers
("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\(?:\033\\[K\\)?\\)" ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
;; Refontification does not work after the markers have been ;; Refontification does not work after the markers have been
;; deleted. So we use the font-lock-face property here as Font ;; deleted. So we use the font-lock-face property here as Font
;; Lock does not clear that. ;; Lock does not clear that.
(2 (list 'face nil 'font-lock-face grep-match-face)) (2 (list 'face nil 'font-lock-face grep-match-face))
((lambda (p)) ((lambda (bound))
(progn (progn
;; Delete markers with `replace-match' because it updates ;; Delete markers with `replace-match' because it updates
;; the match-data, whereas `delete-region' would render it obsolete. ;; the match-data, whereas `delete-region' would render it obsolete.
(replace-match "" t t nil 3) (replace-match "" t t nil 3)
(replace-match "" t t nil 1))))) (replace-match "" t t nil 1))))
("\\(\033\\[[0-9;]*[mK]\\)"
;; Delete all remaining escape sequences
((lambda (bound))
(replace-match "" t t nil 1))))
"Additional things to highlight in grep output. "Additional things to highlight in grep output.
This gets tacked on the end of the generated expressions.") This gets tacked on the end of the generated expressions.")
...@@ -354,7 +360,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." ...@@ -354,7 +360,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
(when (eq grep-highlight-matches t) (when (eq grep-highlight-matches t)
;; Modify `process-environment' locally bound in `compilation-start' ;; Modify `process-environment' locally bound in `compilation-start'
(setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always")) (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
(setenv "GREP_COLOR" "01;41")) ;; for GNU grep 2.5.1
(setenv "GREP_COLOR" "01;31")
;; for GNU grep 2.5.1-cvs
(setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:ml=:cx=:ne"))
(set (make-local-variable 'compilation-exit-message-function) (set (make-local-variable 'compilation-exit-message-function)
(lambda (status code msg) (lambda (status code msg)
(if (eq status 'exit) (if (eq status 'exit)
...@@ -514,6 +523,7 @@ temporarily highlight in visited source lines." ...@@ -514,6 +523,7 @@ temporarily highlight in visited source lines."
command-args) command-args)
'grep-mode nil highlight-regexp))) 'grep-mode nil highlight-regexp)))
;;;###autoload
(define-compilation-mode grep-mode "Grep" (define-compilation-mode grep-mode "Grep"
"Sets `grep-last-buffer' and `compilation-window-height'." "Sets `grep-last-buffer' and `compilation-window-height'."
(setq grep-last-buffer (current-buffer)) (setq grep-last-buffer (current-buffer))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment