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: Thu, 04 Aug 2005 05:14:19 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>     After adding the underline attribute to compilation and grep faces
>     now some non-navigational messages are displayed as links.  This is
>     misleading.  Please see examples of such messages in the section
>     `* Miscellaneous' in etc/compilation.txt, and `* GNU grep 2.5.1:
>     other messages' in etc/grep.txt, and try to move the mouse pointer
>     over link-like underlined parts.
>
> I fixed most of this, but 
>
>     Binary file 2005-06 matches
>
> still matches wrong.  Can you debug that?

This is already fixed with my latest patch.

But I see now that fontification of compilation messages has
degraded compared to earlier versions.  The process exit status
is no more distinguished by a different color (where green was used
for successful, and red was used for abnormally exited process),
configuration checking results have the same color for yes and no
(where green was used for yes, and red - for no).

I propose a patch that restores these colors with the following values:

In the compilation buffer:

  yes - green
  no - red
  other - orange

  Compilation finished          - green
  Compilation exited abnormally - red

In the grep buffer:

  matches found     - green
  no matches found  - orange
  exited abnormally - red

  Binary file emacs-7 matches

where emacs-7 is displayed as a file link (green underlined)

All this is achieved by adding three new face variables

  compilation-info-text-face
  compilation-warning-text-face
  compilation-error-text-face

which are variants of existing face variables, but without underlines:

Index: lisp/progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.368
diff -c -r1.368 compile.el
*** lisp/progmodes/compile.el   4 Aug 2005 01:36:10 -0000       1.368
--- lisp/progmodes/compile.el   4 Aug 2005 02:12:14 -0000
***************
*** 377,389 ****
     '(;; configure output lines.
       ("^[Cc]hecking \\(?:[Ff]or \\|[Ii]f \\|[Ww]hether \\(?:to 
\\)?\\)?\\(.+\\)\\.\\.\\. *\\(?:(cached) *\\)?\\(\\(yes\\(?: 
.+\\)?\\)\\|no\\|\\(.*\\)\\)$"
        (1 font-lock-variable-name-face)
!       (2 font-lock-keyword-face))
       ;; Command output lines.  Recognize `make[n]:' lines too.
       ("^\\([[:alnum:]_/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
        (1 font-lock-function-name-face) (3 compilation-line-face nil t))
       (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1)
!      ("^Compilation finished" . font-lock-keyword-face)
!      ("^Compilation exited abnormally" . font-lock-keyword-face))
     "Additional things to highlight in Compilation mode.
  This gets tacked on the end of the generated expressions.")
  
--- 377,389 ----
     '(;; configure output lines.
       ("^[Cc]hecking \\(?:[Ff]or \\|[Ii]f \\|[Ww]hether \\(?:to 
\\)?\\)?\\(.+\\)\\.\\.\\. *\\(?:(cached) *\\)?\\(\\(yes\\(?: 
.+\\)?\\)\\|no\\|\\(.*\\)\\)$"
        (1 font-lock-variable-name-face)
!       (2 (compilation-text-face '(4 . 3))))
       ;; Command output lines.  Recognize `make[n]:' lines too.
       ("^\\([[:alnum:]_/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
        (1 font-lock-function-name-face) (3 compilation-line-face nil t))
       (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1)
!      ("^Compilation finished" . compilation-info-text-face)
!      ("^Compilation exited abnormally" . compilation-error-text-face))
     "Additional things to highlight in Compilation mode.
  This gets tacked on the end of the generated expressions.")
  
***************
*** 468,473 ****
--- 468,479 ----
  ;; History of compile commands.
  (defvar compile-history nil)
  
+ (defface compilation-error
+   '((t :inherit font-lock-warning-face))
+   "Face for displaying compilation errors."
+   :group 'font-lock-highlighting-faces
+   :version "22.1")
+ 
  (defface compilation-warning
    '((((class color) (min-colors 16)) (:foreground "Orange" :weight bold))
      (((class color)) (:foreground "cyan" :weight bold))
***************
*** 487,530 ****
       (:foreground "Green" :weight bold))
      (((class color)) (:foreground "green" :weight bold))
      (t (:weight bold)))
!   "Face used to highlight compiler warnings."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  ;; backward-compatibility alias
  (put 'compilation-info-face 'face-alias 'compilation-info)
  
  (defface compilation-error-file-name
!   '((default :inherit font-lock-warning-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in compilation errors."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-warning-file-name
!   '((default :inherit font-lock-warning-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in compilation errors."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-info-file-name
    '((default :inherit compilation-info)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in compilation errors."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-line-number
    '((default :inherit font-lock-variable-name-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in compilation errors."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-column-number
    '((default :inherit font-lock-type-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in compilation errors."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
--- 493,536 ----
       (:foreground "Green" :weight bold))
      (((class color)) (:foreground "green" :weight bold))
      (t (:weight bold)))
!   "Face used to highlight compiler information."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  ;; backward-compatibility alias
  (put 'compilation-info-face 'face-alias 'compilation-info)
  
  (defface compilation-error-file-name
!   '((default :inherit compilation-error)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in error messages."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-warning-file-name
!   '((default :inherit compilation-warning)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in warning messages."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-info-file-name
    '((default :inherit compilation-info)
      (((supports :underline t)) :underline t))
!   "Face for displaying file names in informational messages."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-line-number
    '((default :inherit font-lock-variable-name-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying line number in messages."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
  (defface compilation-column-number
    '((default :inherit font-lock-type-face)
      (((supports :underline t)) :underline t))
!   "Face for displaying column number in messages."
    :group 'font-lock-highlighting-faces
    :version "22.1")
  
***************
*** 537,560 ****
  (defvar compilation-error-face 'compilation-error-file-name
    "Face name to use for file name in error messages.")
  
  (defvar compilation-warning-face 'compilation-warning-file-name
    "Face name to use for file name in warning messages.")
  
  (defvar compilation-info-face 'compilation-info-file-name
    "Face name to use for file name in informational messages.")
  
  (defvar compilation-line-face 'compilation-line-number
    "Face name to use for line number in message.")
  
  (defvar compilation-column-face 'compilation-column-number
!   "Face name to use for column number in message.")
  
  ;; same faces as dired uses
  (defvar compilation-enter-directory-face 'font-lock-function-name-face
!   "Face name to use for column number in message.")
  
  (defvar compilation-leave-directory-face 'font-lock-type-face
!   "Face name to use for column number in message.")
  
  
  
--- 543,575 ----
  (defvar compilation-error-face 'compilation-error-file-name
    "Face name to use for file name in error messages.")
  
+ (defvar compilation-error-text-face 'compilation-error
+   "Face name to use for text of error messages.")
+ 
  (defvar compilation-warning-face 'compilation-warning-file-name
    "Face name to use for file name in warning messages.")
  
+ (defvar compilation-warning-text-face 'compilation-warning
+   "Face name to use for text of warning messages.")
+ 
  (defvar compilation-info-face 'compilation-info-file-name
    "Face name to use for file name in informational messages.")
  
+ (defvar compilation-info-text-face 'compilation-info
+   "Face name to use for text of informational messages.")
+ 
  (defvar compilation-line-face 'compilation-line-number
    "Face name to use for line number in message.")
  
  (defvar compilation-column-face 'compilation-column-number
!   "Face name to use for column number in messages.")
  
  ;; same faces as dired uses
  (defvar compilation-enter-directory-face 'font-lock-function-name-face
!   "Face name to use for entering directory messages.")
  
  (defvar compilation-leave-directory-face 'font-lock-type-face
!   "Face name to use for leaving directory messages.")
  
  
  
***************
*** 569,574 ****
--- 584,594 ----
    (or (and (car type) (match-end (car type)) compilation-warning-face)
        (and (cdr type) (match-end (cdr type)) compilation-info-face)
        compilation-error-face))
+ 
+ (defun compilation-text-face (type)
+   (or (and (car type) (match-end (car type)) compilation-warning-text-face)
+       (and (cdr type) (match-end (cdr type)) compilation-info-text-face)
+       compilation-error-text-face))
  
  ;; Internal function for calculating the text properties of a directory
  ;; change message.  The directory property is important, because it is

Index: lisp/progmodes/grep.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.43
diff -c -r1.43 grep.el
*** lisp/progmodes/grep.el      4 Aug 2005 01:36:49 -0000       1.43
--- lisp/progmodes/grep.el      4 Aug 2005 02:12:34 -0000
***************
*** 261,267 ****
        (lambda () (- (match-end 5) (match-end 1)
                    (- (match-end 4) (match-beginning 4)))))
       nil 1)
!     ("^Binary file \\(.+\\) matches$" 1 nil nil 1 1))
    "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
  
  (defvar grep-error "grep hit"
--- 261,267 ----
        (lambda () (- (match-end 5) (match-end 1)
                    (- (match-end 4) (match-beginning 4)))))
       nil 1)
!     ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1))
    "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
  
  (defvar grep-error "grep hit"
***************
*** 272,279 ****
  (defvar grep-hit-face compilation-info-face
    "Face name to use for grep hits.")
  
! ;; compilation-error-face is wrong for this; it's designed to look like a 
link.
! (defvar grep-error-face       font-lock-keyword-face
    "Face name to use for grep error messages.")
  
  (defvar grep-match-face       'match
--- 272,278 ----
  (defvar grep-hit-face compilation-info-face
    "Face name to use for grep hits.")
  
! (defvar grep-error-face       compilation-error-face
    "Face name to use for grep error messages.")
  
  (defvar grep-match-face       'match
***************
*** 290,301 ****
       ;; remove match from grep-regexp-alist before fontifying
       ("^Grep finished \\(?:(\\(matches found\\))\\|with \\(no matches 
found\\)\\).*"
        (0 '(face nil message nil help-echo nil mouse-face nil) t)
!       (1 font-lock-keyword-face nil t)
!       (2 font-lock-keyword-face nil t))
       ("^Grep \\(exited abnormally\\) with code \\([0-9]+\\).*"
        (0 '(face nil message nil help-echo nil mouse-face nil) t)
!       (1 grep-error-face)
!       (2 grep-error-face))
       ("^[^\n-]+-[0-9]+-.*" (0 grep-context-face))
       ;; Highlight grep matches and delete markers
       ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
--- 289,300 ----
       ;; remove match from grep-regexp-alist before fontifying
       ("^Grep finished \\(?:(\\(matches found\\))\\|with \\(no matches 
found\\)\\).*"
        (0 '(face nil message nil help-echo nil mouse-face nil) t)
!       (1 compilation-info-text-face nil t)
!       (2 compilation-warning-text-face nil t))
       ("^Grep \\(exited abnormally\\) with code \\([0-9]+\\).*"
        (0 '(face nil message nil help-echo nil mouse-face nil) t)
!       (1 compilation-error-text-face)
!       (2 compilation-error-text-face))
       ("^[^\n-]+-[0-9]+-.*" (0 grep-context-face))
       ;; Highlight grep matches and delete markers
       ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"

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





reply via email to

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