emacs-devel
[Top][All Lists]
Advanced

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

nxml-mode faces


From: Jason Rumney
Subject: nxml-mode faces
Date: Tue, 18 Dec 2007 13:48:19 +0000
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Does anyone have any objection to the patch below, which makes use of
existing font-lock faces rather than inventing an entirely separate
color scheme?

Fontification I think is an improvement over xml-mode that can be
changed if others do not agree:

1. Keywords in the prolog, such as SYSTEM and PUBLIC are fontified as
keywords, as is CDATA. xml-mode does not fontify these.

2. Entity and character references are fontified in
font-lock-constant-face. xml-mode fontifies entity references in
font-lock-variable-name face (the same as attribute names), and does not
fontify numeric character references at all.


Changes in fontification compared to xml-mode that are due to
differences in internal implementation:

1. The opening ! and ? of processing instruction and prolog (in nxml
terminology) elements are fontified with the opening <, rather than the
following "element" name. The ? before the closing tag of a processing
instruction is fontified with the closing > in both cases, so xml-mode
seems a little inconsistent here.

2. The content of processing instructions is fontified in
font-lock-doc-face. xml-mode formats the contents as if it were a normal
XML element, but the content of a processing instruction is arbitrary
and not considered part of the XML. If the chosen face does not seem
appropriate, font-lock-comment-face or default could be other candidates.



Index: lisp/nxml/nxml-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/nxml/nxml-mode.el,v
retrieving revision 1.3
diff -c -r1.3 nxml-mode.el
*** lisp/nxml/nxml-mode.el    28 Nov 2007 04:08:30 -0000    1.3
--- lisp/nxml/nxml-mode.el    18 Dec 2007 13:07:47 -0000
***************
*** 147,185 ****
    :group 'nxml
    :type 'boolean)
 
- ;; The following are the colors we use with a light background.
- ;; The two blues have the same hue but contrasting saturation/value.
- ;; The hue of the green is 120 degrees different from that of the
- ;; blue.  The red used for highlighting errors is 120 degrees
- ;; different again.  We use the light blue only for refs and
- ;; delimiters, since these are short (long stretches in a light color
- ;; would be too hard to read).  The dark blue is closest to black
- ;; (which we use by default for text), so we use it for attribute
- ;; values, which are similar to text.
-
- (defconst nxml-light-blue-color "#9292C9") ; hue 240
- (defconst nxml-dark-blue-color "#3A3A7B") ; hue 240
- (defconst nxml-green-color "#257A25") ; hue 120
-
- ;; Similar principles apply with a dark background.  However,
- ;; we switch green and blue, because darker blues are very hard to
- ;; read (for me anyway) on a dark background.
-
- (defconst nxml-sky-blue-color "#ACACFC") ; hue 240
- (defconst nxml-dark-green-color "#00AD00") ; hue 120
- (defconst nxml-light-green-color "#70F170") ; hue 120
-
  (defface nxml-delimited-data-face
!   `((((class color) (background light)) (:foreground
,nxml-dark-blue-color))
!     (((class color) (background dark)) (:foreground
,nxml-light-green-color)))
    "Face used to highlight data enclosed between delimiters.
! By default, this is inherited by `nxml-attribute-value-face'
! and `nxml-processing-instruction-content-face'."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-name-face
!   `((((class color) (background light)) (:foreground ,nxml-green-color))
!     (((class color) (background dark)) (:foreground
,nxml-sky-blue-color)))
    "Face used to highlight various names.
  This includes element and attribute names, processing
  instruction targets and the CDATA keyword in a CDATA section.
--- 147,160 ----
    :group 'nxml
    :type 'boolean)
 
  (defface nxml-delimited-data-face
!   '((t (:inherit font-lock-doc-face)))
    "Face used to highlight data enclosed between delimiters.
! This is not used directly, but only by inheritance by other faces."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-name-face
!   '((t (:inherit font-lock-builtin-face)))
    "Face used to highlight various names.
  This includes element and attribute names, processing
  instruction targets and the CDATA keyword in a CDATA section.
***************
*** 187,202 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-ref-face
!   `((((class color) (background light)) (:foreground
,nxml-light-blue-color))
!     (((class color) (background dark)) (:foreground
,nxml-dark-green-color)))
    "Face used to highlight character and entity references.
  This is not used directly, but only via inheritance by other faces."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-delimiter-face
!   `((((class color) (background light)) (:foreground
,nxml-light-blue-color))
!     (((class color) (background dark)) (:foreground
,nxml-dark-green-color))
!     (t (:bold t)))
    "Face used to highlight delimiters.
  This is not used directly, but only via inheritance by other faces."
    :group 'nxml-highlighting-faces)
--- 162,174 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-ref-face
!   '((t (:inherit font-lock-constant-face)))
    "Face used to highlight character and entity references.
  This is not used directly, but only via inheritance by other faces."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-delimiter-face
!   nil
    "Face used to highlight delimiters.
  This is not used directly, but only via inheritance by other faces."
    :group 'nxml-highlighting-faces)
***************
*** 207,218 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-comment-content-face
!   '((t (:italic t)))
    "Face used to highlight the content of comments."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-comment-delimiter-face
!   '((t (:inherit nxml-delimiter-face)))
    "Face used for the delimiters of comments, i.e <!-- and -->."
    :group 'nxml-highlighting-faces)
 
--- 179,190 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-comment-content-face
!   '((t (:inherit font-lock-comment-face)))
    "Face used to highlight the content of comments."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-comment-delimiter-face
!   '((t (:inherit font-lock-comment-delimiter-face)))
    "Face used for the delimiters of comments, i.e <!-- and -->."
    :group 'nxml-highlighting-faces)
 
***************
*** 222,228 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-processing-instruction-target-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the target of processing instructions."
    :group 'nxml-highlighting-faces)
 
--- 194,200 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-processing-instruction-target-face
!   '((t (:inherit font-lock-keyword-face)))
    "Face used for the target of processing instructions."
    :group 'nxml-highlighting-faces)
 
***************
*** 274,280 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-tag-slash-face
!   '((t (:inherit nxml-name-face)))
    "Face used for slashes in tags, both in end-tags and empty-elements."
    :group 'nxml-highlighting-faces)
 
--- 246,252 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-tag-slash-face
!   '((t (:inherit nxml-tag-delimiter-face)))
    "Face used for slashes in tags, both in end-tags and empty-elements."
    :group 'nxml-highlighting-faces)
 
***************
*** 284,295 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-element-colon-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the colon in element names."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-element-local-name-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the local name of elements."
    :group 'nxml-highlighting-faces)
 
--- 256,267 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-element-colon-face
!   nil
    "Face used for the colon in element names."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-element-local-name-face
!   '((t (:inherit font-lock-function-name-face)))
    "Face used for the local name of elements."
    :group 'nxml-highlighting-faces)
 
***************
*** 299,335 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-colon-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the colon in attribute names."
    :group 'nxml-highlighting-faces)
   
  (defface nxml-attribute-local-name-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the local name of attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-xmlns-face
!   '((t (:inherit nxml-name-face)))
    "Face used for `xmlns' in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-colon-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the colon in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-prefix-face
!   '((t (:inherit nxml-name-face)))
    "Face used for the prefix declared in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-value-face
!   '((t (:inherit nxml-delimited-data-face)))
    "Face used for the value of attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-value-delimiter-face
!   '((t (:inherit nxml-delimiter-face)))
    "Face used for the delimiters of attribute values."
    :group 'nxml-highlighting-faces)
 
--- 271,307 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-colon-face
!   '((t (:inherit nxml-delimiter-face)))
    "Face used for the colon in attribute names."
    :group 'nxml-highlighting-faces)
   
  (defface nxml-attribute-local-name-face
!   '((t (:inherit font-lock-variable-name-face)))
    "Face used for the local name of attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-xmlns-face
!   '((t (:inherit nxml-attribute-prefix-face)))
    "Face used for `xmlns' in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-colon-face
!   '((t (:inherit nxml-attribute-colon-face)))
    "Face used for the colon in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-namespace-attribute-prefix-face
!   '((t (:inherit nxml-attribute-local-name-face)))
    "Face used for the prefix declared in namespace attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-value-face
!   '((t (:inherit font-lock-string-face)))
    "Face used for the value of attributes."
    :group 'nxml-highlighting-faces)
 
  (defface nxml-attribute-value-delimiter-face
!   '((t (:inherit nxml-attribute-value-face)))
    "Face used for the delimiters of attribute values."
    :group 'nxml-highlighting-faces)
 
***************
*** 344,350 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-prolog-literal-delimiter-face
!   '((t (:inherit nxml-delimiter-face)))
    "Face used for the delimiters of literals in the prolog."
    :group 'nxml-highlighting-faces)
 
--- 316,322 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-prolog-literal-delimiter-face
!   '((t (:inherit nxml-delimited-data-face)))
    "Face used for the delimiters of literals in the prolog."
    :group 'nxml-highlighting-faces)
 
***************
*** 354,360 ****
    :group 'nxml-highlighting-faces)
 
  (defface nxml-prolog-keyword-face
!   '((t (:inherit nxml-name-face)))
    "Face used for keywords in the prolog."
    :group 'nxml-highlighting-faces)
 
--- 326,332 ----
    :group 'nxml-highlighting-faces)
 
  (defface nxml-prolog-keyword-face
!   '((t (:inherit font-lock-keyword-face)))
    "Face used for keywords in the prolog."
    :group 'nxml-highlighting-faces)
 
Index: lisp/nxml/rng-valid.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/nxml/rng-valid.el,v
retrieving revision 1.3
diff -c -r1.3 rng-valid.el
*** lisp/nxml/rng-valid.el    28 Nov 2007 04:13:52 -0000    1.3
--- lisp/nxml/rng-valid.el    18 Dec 2007 12:10:24 -0000
***************
*** 107,113 ****
    :group 'nxml
    :group 'languages)
 
! (defface rng-error-face '((t (:underline "red")))
    "Face for highlighting XML errors."
    :group 'relax-ng)
 
--- 107,113 ----
    :group 'nxml
    :group 'languages)
 
! (defface rng-error-face '((t (:inherit font-lock-warning-face)))
    "Face for highlighting XML errors."
    :group 'relax-ng)
 





reply via email to

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