aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2005-07-19 14:21:23 +0000
committerJuri Linkov2005-07-19 14:21:23 +0000
commit983203eeb69a554bb4b4a13b88215c892b06def9 (patch)
tree1a957fd76def57460b97fda9ba68a5f5e72aaf9e
parent4a397e9af69faebfa6f0f104c88979c25b5e7582 (diff)
downloademacs-983203eeb69a554bb4b4a13b88215c892b06def9.tar.gz
emacs-983203eeb69a554bb4b4a13b88215c892b06def9.zip
(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.
-rw-r--r--lisp/progmodes/grep.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 0f1045eeb5a..8f6dd73cba1 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -196,6 +196,7 @@ See `compilation-error-screen-columns'"
196 (define-key map "p" 'previous-error-no-select) 196 (define-key map "p" 'previous-error-no-select)
197 (define-key map "{" 'compilation-previous-file) 197 (define-key map "{" 'compilation-previous-file)
198 (define-key map "}" 'compilation-next-file) 198 (define-key map "}" 'compilation-next-file)
199 (define-key map [backtab] 'compilation-previous-file)
199 (define-key map "\t" 'compilation-next-file) 200 (define-key map "\t" 'compilation-next-file)
200 201
201 ;; Set up the menu-bar 202 ;; Set up the menu-bar
@@ -255,16 +256,17 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
255\\(?:-\\(?:\\([0-9]+\\)\\4\\)?\\.?\\([0-9]+\\)?\\)?\\2" 256\\(?:-\\(?:\\([0-9]+\\)\\4\\)?\\.?\\([0-9]+\\)?\\)?\\2"
256 1 (3 . 6) (5 . 7)) 257 1 (3 . 6) (5 . 7))
257 ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\ 258 ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\
258\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\(?:\033\\[K\\)?\\)" 259\\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
259 2 3 260 2 3
260 ;; Calculate column positions (beg . end) of first grep match on a line 261 ;; Calculate column positions (beg . end) of first grep match on a line
261 ((lambda () 262 ((lambda ()
262 (setq compilation-error-screen-columns nil) 263 (setq compilation-error-screen-columns nil)
263 (- (match-beginning 5) (match-end 1) 8)) 264 (- (match-beginning 4) (match-end 1)))
264 . 265 .
265 (lambda () (- (match-end 5) (match-end 1) 8))) 266 (lambda () (- (match-end 5) (match-end 1)
267 (- (match-end 4) (match-beginning 4)))))
266 nil 1) 268 nil 1)
267 ("^Binary file \\(.+\\) matches$" 1 nil nil 1)) 269 ("^Binary file \\(.+\\) matches$" 1 nil nil 1 1))
268 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") 270 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
269 271
270(defvar grep-error "grep hit" 272(defvar grep-error "grep hit"
@@ -296,17 +298,21 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
296 (1 compilation-warning-face) 298 (1 compilation-warning-face)
297 (2 compilation-line-face)) 299 (2 compilation-line-face))
298 ;; Highlight grep matches and delete markers 300 ;; Highlight grep matches and delete markers
299 ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\(?:\033\\[K\\)?\\)" 301 ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
300 ;; Refontification does not work after the markers have been 302 ;; Refontification does not work after the markers have been
301 ;; deleted. So we use the font-lock-face property here as Font 303 ;; deleted. So we use the font-lock-face property here as Font
302 ;; Lock does not clear that. 304 ;; Lock does not clear that.
303 (2 (list 'face nil 'font-lock-face grep-match-face)) 305 (2 (list 'face nil 'font-lock-face grep-match-face))
304 ((lambda (p)) 306 ((lambda (bound))
305 (progn 307 (progn
306 ;; Delete markers with `replace-match' because it updates 308 ;; Delete markers with `replace-match' because it updates
307 ;; the match-data, whereas `delete-region' would render it obsolete. 309 ;; the match-data, whereas `delete-region' would render it obsolete.
308 (replace-match "" t t nil 3) 310 (replace-match "" t t nil 3)
309 (replace-match "" t t nil 1))))) 311 (replace-match "" t t nil 1))))
312 ("\\(\033\\[[0-9;]*[mK]\\)"
313 ;; Delete all remaining escape sequences
314 ((lambda (bound))
315 (replace-match "" t t nil 1))))
310 "Additional things to highlight in grep output. 316 "Additional things to highlight in grep output.
311This gets tacked on the end of the generated expressions.") 317This gets tacked on the end of the generated expressions.")
312 318
@@ -354,7 +360,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
354 (when (eq grep-highlight-matches t) 360 (when (eq grep-highlight-matches t)
355 ;; Modify `process-environment' locally bound in `compilation-start' 361 ;; Modify `process-environment' locally bound in `compilation-start'
356 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always")) 362 (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
357 (setenv "GREP_COLOR" "01;41")) 363 ;; for GNU grep 2.5.1
364 (setenv "GREP_COLOR" "01;31")
365 ;; for GNU grep 2.5.1-cvs
366 (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:ml=:cx=:ne"))
358 (set (make-local-variable 'compilation-exit-message-function) 367 (set (make-local-variable 'compilation-exit-message-function)
359 (lambda (status code msg) 368 (lambda (status code msg)
360 (if (eq status 'exit) 369 (if (eq status 'exit)
@@ -514,6 +523,7 @@ temporarily highlight in visited source lines."
514 command-args) 523 command-args)
515 'grep-mode nil highlight-regexp))) 524 'grep-mode nil highlight-regexp)))
516 525
526;;;###autoload
517(define-compilation-mode grep-mode "Grep" 527(define-compilation-mode grep-mode "Grep"
518 "Sets `grep-last-buffer' and `compilation-window-height'." 528 "Sets `grep-last-buffer' and `compilation-window-height'."
519 (setq grep-last-buffer (current-buffer)) 529 (setq grep-last-buffer (current-buffer))