emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep.el regexp


From: Juri Linkov
Subject: Re: grep.el regexp
Date: Tue, 19 Jul 2005 18:55:07 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Please find below a patch that removes recognition of all grep formats
except those listed in etc/grep.txt.

I'm also tempted to add recognition of column numbers for possible
search scripts that outputs them, with the rule:

 ("^\\([^:\n]+\\)\\(:[ 
\t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?"
  1 3 (4 . 5))

but it will recognize lines with the leading number and colon as the
column number (look the example in etc/grep.txt).  This wouldn't be
a problem if fontification was able to skip already fontified lines,
and not to apply the rule with column numbers when the rule that
accepts escape sequences for column calculation was applied.
But I haven't found a way to do that.

Index: lisp/progmodes/grep.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.39
diff -u -r1.39 grep.el
--- lisp/progmodes/grep.el      19 Jul 2005 14:21:23 -0000      1.39
+++ lisp/progmodes/grep.el      19 Jul 2005 15:54:54 -0000
@@ -248,13 +248,8 @@
 
 ;;;###autoload
 (defvar grep-regexp-alist
-  ;; rms: I removed the code to match parens around the line number
-  ;; because it causes confusion and so we will find out if anyone needs it.
-  ;; It causes confusion with a file name that contains a number in parens.
-  '(("^\\(.+?\\)\\([: \t]\\)+\
-\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
-\\(?:-\\(?:\\([0-9]+\\)\\4\\)?\\.?\\([0-9]+\\)?\\)?\\2"
-     1 (3 . 6) (5 . 7))
+  '(("^\\([^:\n]+\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2"
+     1 3)
     ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\
 \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
      2 3
@@ -283,6 +278,9 @@
 (defvar grep-match-face        'match
   "Face name to use for grep matches.")
 
+(defvar grep-context-face 'shadow
+  "Face name to use for grep context lines.")
+
 (defvar grep-mode-font-lock-keywords
    '(;; Command output lines.
      ("^\\([A-Za-z_0-9/\.+-]+\\)[ \t]*:" 1 font-lock-function-name-face)
@@ -297,6 +295,7 @@
       (0 '(face nil message nil help-echo nil mouse-face nil) t)
       (1 compilation-warning-face)
       (2 compilation-line-face))
+     ("^[^\n-]+-[0-9]+-.*" (0 grep-context-face))
      ;; Highlight grep matches and delete markers
      ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
       ;; Refontification does not work after the markers have been

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]