diff options
| author | Jason Rumney | 2007-12-20 15:19:09 +0000 |
|---|---|---|
| committer | Jason Rumney | 2007-12-20 15:19:09 +0000 |
| commit | 92bbfd0ded8c7cae87028eb009f1d399cb34b9e0 (patch) | |
| tree | 0ccf8dad40387dc0b76b9f34d5cb2cfabbf42311 | |
| parent | 8776814431482831336f345f3ffdb806dc9ff916 (diff) | |
| download | emacs-92bbfd0ded8c7cae87028eb009f1d399cb34b9e0.tar.gz emacs-92bbfd0ded8c7cae87028eb009f1d399cb34b9e0.zip | |
(nxml-faces): Rename from nxml-highlighting-faces.
Parent group is font-lock-faces.
(nxml-light-blue-color, nxml-dark-blue-color, nxml-green-color)
(nxml-sky-blue-color, nxml-dark-green-color, nxml-light-green-color):
(nxml-version): Remove.
(nxml-delimited-data, nxml-name, nxml-ref, nxml-delimiter)
(nxml-text, nxml-comment-content, nxml-comment-delimiter)
(nxml-processing-instruction-delimiter)
(nxml-processing-instruction-target)
(nxml-processing-instruction-content, nxml-cdata-section-delimiter)
(nxml-cdata-section-CDATA, nxml-cdata-section-content)
(nxml-char-ref-number, nxml-char-ref-delimiter, nxml-entity-ref-name)
(nxml-entity-ref-delimiter, nxml-tag-delimiter, nxml-tag-slash)
(nxml-element-prefix, nxml-element-colon, nxml-element-local-name)
(nxml-attribute-prefix, nxml-attribute-colon)
(nxml-attribute-local-name, nxml-namespace-attribute-xmlns)
(nxml-namespace-attribute-colon, nxml-namespace-attribute-prefix)
(nxml-attribute-value, nxml-attribute-value-delimiter)
(nxml-namespace-attibute-value)
(nxml-namespace-attribure-value-delimiter)
(nxml-prolog-literal-delimiter, nxml-prolog-literal-content)
(nxml-prolog-keyword, nxml-markup-declaration-delimiter, nxml-hash)
(nxml-glyph): Rename, removing -face suffix.
Inherit from existing font-lock faces.
(nxml-apply-fontify-rule, nxml-char-ref-display-extra):
Use new face names.
| -rw-r--r-- | lisp/nxml/nxml-mode.el | 417 |
1 files changed, 188 insertions, 229 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 42d16359fbc..973197242f3 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el | |||
| @@ -52,10 +52,10 @@ | |||
| 52 | :group 'languages | 52 | :group 'languages |
| 53 | :group 'wp) | 53 | :group 'wp) |
| 54 | 54 | ||
| 55 | (defgroup nxml-highlighting-faces nil | 55 | (defgroup nxml-faces nil |
| 56 | "Faces for XML syntax highlighting." | 56 | "Faces for XML syntax highlighting." |
| 57 | :group 'nxml | 57 | :group 'nxml |
| 58 | :group 'font-lock-highlighting-faces) | 58 | :group 'font-lock-faces) |
| 59 | 59 | ||
| 60 | (defcustom nxml-syntax-highlight-flag t | 60 | (defcustom nxml-syntax-highlight-flag t |
| 61 | "*Non-nil means nxml-mode should perform syntax highlighting." | 61 | "*Non-nil means nxml-mode should perform syntax highlighting." |
| @@ -64,7 +64,7 @@ | |||
| 64 | 64 | ||
| 65 | (defcustom nxml-char-ref-display-glyph-flag t | 65 | (defcustom nxml-char-ref-display-glyph-flag t |
| 66 | "*Non-nil means display glyph following character reference. | 66 | "*Non-nil means display glyph following character reference. |
| 67 | The glyph is displayed in `nxml-glyph-face'. The hook | 67 | The glyph is displayed in face `nxml-glyph'. The hook |
| 68 | `nxml-glyph-set-hook' can be used to customize for which characters | 68 | `nxml-glyph-set-hook' can be used to customize for which characters |
| 69 | glyphs are displayed." | 69 | glyphs are displayed." |
| 70 | :group 'nxml | 70 | :group 'nxml |
| @@ -147,229 +147,201 @@ The XML declaration is inserted using `nxml-insert-xml-declaration'." | |||
| 147 | :group 'nxml | 147 | :group 'nxml |
| 148 | :type 'boolean) | 148 | :type 'boolean) |
| 149 | 149 | ||
| 150 | ;; The following are the colors we use with a light background. | 150 | (defface nxml-delimited-data |
| 151 | ;; The two blues have the same hue but contrasting saturation/value. | 151 | '((t (:inherit font-lock-doc-face))) |
| 152 | ;; The hue of the green is 120 degrees different from that of the | ||
| 153 | ;; blue. The red used for highlighting errors is 120 degrees | ||
| 154 | ;; different again. We use the light blue only for refs and | ||
| 155 | ;; delimiters, since these are short (long stretches in a light color | ||
| 156 | ;; would be too hard to read). The dark blue is closest to black | ||
| 157 | ;; (which we use by default for text), so we use it for attribute | ||
| 158 | ;; values, which are similar to text. | ||
| 159 | |||
| 160 | (defconst nxml-light-blue-color "#9292C9") ; hue 240 | ||
| 161 | (defconst nxml-dark-blue-color "#3A3A7B") ; hue 240 | ||
| 162 | (defconst nxml-green-color "#257A25") ; hue 120 | ||
| 163 | |||
| 164 | ;; Similar principles apply with a dark background. However, | ||
| 165 | ;; we switch green and blue, because darker blues are very hard to | ||
| 166 | ;; read (for me anyway) on a dark background. | ||
| 167 | |||
| 168 | (defconst nxml-sky-blue-color "#ACACFC") ; hue 240 | ||
| 169 | (defconst nxml-dark-green-color "#00AD00") ; hue 120 | ||
| 170 | (defconst nxml-light-green-color "#70F170") ; hue 120 | ||
| 171 | |||
| 172 | (defface nxml-delimited-data-face | ||
| 173 | `((((class color) (background light)) (:foreground ,nxml-dark-blue-color)) | ||
| 174 | (((class color) (background dark)) (:foreground ,nxml-light-green-color))) | ||
| 175 | "Face used to highlight data enclosed between delimiters. | 152 | "Face used to highlight data enclosed between delimiters. |
| 176 | By default, this is inherited by `nxml-attribute-value-face' | 153 | This is not used directly, but only via inheritance by other faces." |
| 177 | and `nxml-processing-instruction-content-face'." | 154 | :group 'nxml-faces) |
| 178 | :group 'nxml-highlighting-faces) | ||
| 179 | 155 | ||
| 180 | (defface nxml-name-face | 156 | (defface nxml-name |
| 181 | `((((class color) (background light)) (:foreground ,nxml-green-color)) | 157 | '((t (:inherit font-lock-builtin-face))) |
| 182 | (((class color) (background dark)) (:foreground ,nxml-sky-blue-color))) | ||
| 183 | "Face used to highlight various names. | 158 | "Face used to highlight various names. |
| 184 | This includes element and attribute names, processing | 159 | This includes element and attribute names, processing |
| 185 | instruction targets and the CDATA keyword in a CDATA section. | 160 | instruction targets and the CDATA keyword in a CDATA section. |
| 186 | This is not used directly, but only via inheritance by other faces." | 161 | This is not used directly, but only via inheritance by other faces." |
| 187 | :group 'nxml-highlighting-faces) | 162 | :group 'nxml-faces) |
| 188 | 163 | ||
| 189 | (defface nxml-ref-face | 164 | (defface nxml-ref |
| 190 | `((((class color) (background light)) (:foreground ,nxml-light-blue-color)) | 165 | '((t (:inherit font-lock-constant-face))) |
| 191 | (((class color) (background dark)) (:foreground ,nxml-dark-green-color))) | ||
| 192 | "Face used to highlight character and entity references. | 166 | "Face used to highlight character and entity references. |
| 193 | This is not used directly, but only via inheritance by other faces." | 167 | This is not used directly, but only via inheritance by other faces." |
| 194 | :group 'nxml-highlighting-faces) | 168 | :group 'nxml-faces) |
| 195 | 169 | ||
| 196 | (defface nxml-delimiter-face | 170 | (defface nxml-delimiter |
| 197 | `((((class color) (background light)) (:foreground ,nxml-light-blue-color)) | 171 | nil |
| 198 | (((class color) (background dark)) (:foreground ,nxml-dark-green-color)) | ||
| 199 | (t (:bold t))) | ||
| 200 | "Face used to highlight delimiters. | 172 | "Face used to highlight delimiters. |
| 201 | This is not used directly, but only via inheritance by other faces." | 173 | This is not used directly, but only via inheritance by other faces." |
| 202 | :group 'nxml-highlighting-faces) | 174 | :group 'nxml-faces) |
| 203 | 175 | ||
| 204 | (defface nxml-text-face | 176 | (defface nxml-text |
| 205 | nil | 177 | nil |
| 206 | "Face used to highlight text." | 178 | "Face used to highlight text." |
| 207 | :group 'nxml-highlighting-faces) | 179 | :group 'nxml-faces) |
| 208 | 180 | ||
| 209 | (defface nxml-comment-content-face | 181 | (defface nxml-comment-content |
| 210 | '((t (:italic t))) | 182 | '((t (:inherit font-lock-comment-face))) |
| 211 | "Face used to highlight the content of comments." | 183 | "Face used to highlight the content of comments." |
| 212 | :group 'nxml-highlighting-faces) | 184 | :group 'nxml-faces) |
| 213 | 185 | ||
| 214 | (defface nxml-comment-delimiter-face | 186 | (defface nxml-comment-delimiter |
| 215 | '((t (:inherit nxml-delimiter-face))) | 187 | '((t (:inherit font-lock-comment-delimiter-face))) |
| 216 | "Face used for the delimiters of comments, i.e <!-- and -->." | 188 | "Face used for the delimiters of comments, i.e <!-- and -->." |
| 217 | :group 'nxml-highlighting-faces) | 189 | :group 'nxml-faces) |
| 218 | 190 | ||
| 219 | (defface nxml-processing-instruction-delimiter-face | 191 | (defface nxml-processing-instruction-delimiter |
| 220 | '((t (:inherit nxml-delimiter-face))) | 192 | '((t (:inherit nxml-delimiter))) |
| 221 | "Face used for the delimiters of processing instructions, i.e <? and ?>." | 193 | "Face used for the delimiters of processing instructions, i.e <? and ?>." |
| 222 | :group 'nxml-highlighting-faces) | 194 | :group 'nxml-faces) |
| 223 | 195 | ||
| 224 | (defface nxml-processing-instruction-target-face | 196 | (defface nxml-processing-instruction-target |
| 225 | '((t (:inherit nxml-name-face))) | 197 | '((t (:inherit font-lock-keyword-face))) |
| 226 | "Face used for the target of processing instructions." | 198 | "Face used for the target of processing instructions." |
| 227 | :group 'nxml-highlighting-faces) | 199 | :group 'nxml-faces) |
| 228 | 200 | ||
| 229 | (defface nxml-processing-instruction-content-face | 201 | (defface nxml-processing-instruction-content |
| 230 | '((t (:inherit nxml-delimited-data-face))) | 202 | '((t (:inherit nxml-delimited-data))) |
| 231 | "Face used for the content of processing instructions." | 203 | "Face used for the content of processing instructions." |
| 232 | :group 'nxml-highlighting-faces) | 204 | :group 'nxml-faces) |
| 233 | 205 | ||
| 234 | (defface nxml-cdata-section-delimiter-face | 206 | (defface nxml-cdata-section-delimiter |
| 235 | '((t (:inherit nxml-delimiter-face))) | 207 | '((t (:inherit nxml-delimiter))) |
| 236 | "Face used for the delimiters of CDATA sections, i.e <![, [, and ]]>." | 208 | "Face used for the delimiters of CDATA sections, i.e <![, [, and ]]>." |
| 237 | :group 'nxml-highlighting-faces) | 209 | :group 'nxml-faces) |
| 238 | 210 | ||
| 239 | (defface nxml-cdata-section-CDATA-face | 211 | (defface nxml-cdata-section-CDATA |
| 240 | '((t (:inherit nxml-name-face))) | 212 | '((t (:inherit nxml-name))) |
| 241 | "Face used for the CDATA keyword in CDATA sections." | 213 | "Face used for the CDATA keyword in CDATA sections." |
| 242 | :group 'nxml-highlighting-faces) | 214 | :group 'nxml-faces) |
| 243 | 215 | ||
| 244 | (defface nxml-cdata-section-content-face | 216 | (defface nxml-cdata-section-content |
| 245 | '((t (:inherit nxml-text-face))) | 217 | '((t (:inherit nxml-text))) |
| 246 | "Face used for the content of CDATA sections." | 218 | "Face used for the content of CDATA sections." |
| 247 | :group 'nxml-highlighting-faces) | 219 | :group 'nxml-faces) |
| 248 | 220 | ||
| 249 | (defface nxml-char-ref-number-face | 221 | (defface nxml-char-ref-number |
| 250 | '((t (:inherit nxml-ref-face))) | 222 | '((t (:inherit nxml-ref))) |
| 251 | "Face used for the number in character references. | 223 | "Face used for the number in character references. |
| 252 | This includes ths `x' in hex references." | 224 | This includes ths `x' in hex references." |
| 253 | :group 'nxml-highlighting-faces) | 225 | :group 'nxml-faces) |
| 254 | 226 | ||
| 255 | (defface nxml-char-ref-delimiter-face | 227 | (defface nxml-char-ref-delimiter |
| 256 | '((t (:inherit nxml-ref-face))) | 228 | '((t (:inherit nxml-ref))) |
| 257 | "Face used for the delimiters of character references, i.e &# and ;." | 229 | "Face used for the delimiters of character references, i.e &# and ;." |
| 258 | :group 'nxml-highlighting-faces) | 230 | :group 'nxml-faces) |
| 259 | 231 | ||
| 260 | (defface nxml-entity-ref-name-face | 232 | (defface nxml-entity-ref-name |
| 261 | '((t (:inherit nxml-ref-face))) | 233 | '((t (:inherit nxml-ref))) |
| 262 | "Face used for the entity name in general entity references." | 234 | "Face used for the entity name in general entity references." |
| 263 | :group 'nxml-highlighting-faces) | 235 | :group 'nxml-faces) |
| 264 | 236 | ||
| 265 | (defface nxml-entity-ref-delimiter-face | 237 | (defface nxml-entity-ref-delimiter |
| 266 | '((t (:inherit nxml-ref-face))) | 238 | '((t (:inherit nxml-ref))) |
| 267 | "Face used for the delimiters of entity references, i.e & and ;." | 239 | "Face used for the delimiters of entity references, i.e & and ;." |
| 268 | :group 'nxml-highlighting-faces) | 240 | :group 'nxml-faces) |
| 269 | 241 | ||
| 270 | (defface nxml-tag-delimiter-face | 242 | (defface nxml-tag-delimiter |
| 271 | '((t (:inherit nxml-delimiter-face))) | 243 | '((t (:inherit nxml-delimiter))) |
| 272 | "Face used for the angle brackets delimiting tags. | 244 | "Face used for the angle brackets delimiting tags. |
| 273 | `nxml-tag-slash-face' is used for slashes." | 245 | `nxml-tag-slash' is used for slashes." |
| 274 | :group 'nxml-highlighting-faces) | 246 | :group 'nxml-faces) |
| 275 | 247 | ||
| 276 | (defface nxml-tag-slash-face | 248 | (defface nxml-tag-slash |
| 277 | '((t (:inherit nxml-name-face))) | 249 | '((t (:inherit nxml-tag-delimiter))) |
| 278 | "Face used for slashes in tags, both in end-tags and empty-elements." | 250 | "Face used for slashes in tags, both in end-tags and empty-elements." |
| 279 | :group 'nxml-highlighting-faces) | 251 | :group 'nxml-faces) |
| 280 | 252 | ||
| 281 | (defface nxml-element-prefix-face | 253 | (defface nxml-element-prefix |
| 282 | '((t (:inherit nxml-name-face))) | 254 | '((t (:inherit nxml-name))) |
| 283 | "Face used for the prefix of elements." | 255 | "Face used for the prefix of elements." |
| 284 | :group 'nxml-highlighting-faces) | 256 | :group 'nxml-faces) |
| 285 | 257 | ||
| 286 | (defface nxml-element-colon-face | 258 | (defface nxml-element-colon |
| 287 | '((t (:inherit nxml-name-face))) | 259 | nil |
| 288 | "Face used for the colon in element names." | 260 | "Face used for the colon in element names." |
| 289 | :group 'nxml-highlighting-faces) | 261 | :group 'nxml-faces) |
| 290 | 262 | ||
| 291 | (defface nxml-element-local-name-face | 263 | (defface nxml-element-local-name |
| 292 | '((t (:inherit nxml-name-face))) | 264 | '((t (:inherit font-lock-function-name-face))) |
| 293 | "Face used for the local name of elements." | 265 | "Face used for the local name of elements." |
| 294 | :group 'nxml-highlighting-faces) | 266 | :group 'nxml-faces) |
| 295 | 267 | ||
| 296 | (defface nxml-attribute-prefix-face | 268 | (defface nxml-attribute-prefix |
| 297 | '((t (:inherit nxml-name-face))) | 269 | '((t (:inherit nxml-name))) |
| 298 | "Face used for the prefix of attributes." | 270 | "Face used for the prefix of attributes." |
| 299 | :group 'nxml-highlighting-faces) | 271 | :group 'nxml-faces) |
| 300 | 272 | ||
| 301 | (defface nxml-attribute-colon-face | 273 | (defface nxml-attribute-colon |
| 302 | '((t (:inherit nxml-name-face))) | 274 | '((t (:inherit nxml-delimiter))) |
| 303 | "Face used for the colon in attribute names." | 275 | "Face used for the colon in attribute names." |
| 304 | :group 'nxml-highlighting-faces) | 276 | :group 'nxml-faces) |
| 305 | 277 | ||
| 306 | (defface nxml-attribute-local-name-face | 278 | (defface nxml-attribute-local-name |
| 307 | '((t (:inherit nxml-name-face))) | 279 | '((t (:inherit font-lock-variable-name-face))) |
| 308 | "Face used for the local name of attributes." | 280 | "Face used for the local name of attributes." |
| 309 | :group 'nxml-highlighting-faces) | 281 | :group 'nxml-faces) |
| 310 | 282 | ||
| 311 | (defface nxml-namespace-attribute-xmlns-face | 283 | (defface nxml-namespace-attribute-xmlns |
| 312 | '((t (:inherit nxml-name-face))) | 284 | '((t (:inherit nxml-attribute-prefix))) |
| 313 | "Face used for `xmlns' in namespace attributes." | 285 | "Face used for `xmlns' in namespace attributes." |
| 314 | :group 'nxml-highlighting-faces) | 286 | :group 'nxml-faces) |
| 315 | 287 | ||
| 316 | (defface nxml-namespace-attribute-colon-face | 288 | (defface nxml-namespace-attribute-colon |
| 317 | '((t (:inherit nxml-name-face))) | 289 | '((t (:inherit nxml-attribute-colon))) |
| 318 | "Face used for the colon in namespace attributes." | 290 | "Face used for the colon in namespace attributes." |
| 319 | :group 'nxml-highlighting-faces) | 291 | :group 'nxml-faces) |
| 320 | 292 | ||
| 321 | (defface nxml-namespace-attribute-prefix-face | 293 | (defface nxml-namespace-attribute-prefix |
| 322 | '((t (:inherit nxml-name-face))) | 294 | '((t (:inherit nxml-attribute-local-name))) |
| 323 | "Face used for the prefix declared in namespace attributes." | 295 | "Face used for the prefix declared in namespace attributes." |
| 324 | :group 'nxml-highlighting-faces) | 296 | :group 'nxml-faces) |
| 325 | 297 | ||
| 326 | (defface nxml-attribute-value-face | 298 | (defface nxml-attribute-value |
| 327 | '((t (:inherit nxml-delimited-data-face))) | 299 | '((t (:inherit font-lock-string-face))) |
| 328 | "Face used for the value of attributes." | 300 | "Face used for the value of attributes." |
| 329 | :group 'nxml-highlighting-faces) | 301 | :group 'nxml-faces) |
| 330 | 302 | ||
| 331 | (defface nxml-attribute-value-delimiter-face | 303 | (defface nxml-attribute-value-delimiter |
| 332 | '((t (:inherit nxml-delimiter-face))) | 304 | '((t (:inherit nxml-attribute-value))) |
| 333 | "Face used for the delimiters of attribute values." | 305 | "Face used for the delimiters of attribute values." |
| 334 | :group 'nxml-highlighting-faces) | 306 | :group 'nxml-faces) |
| 335 | 307 | ||
| 336 | (defface nxml-namespace-attribute-value-face | 308 | (defface nxml-namespace-attribute-value |
| 337 | '((t (:inherit nxml-attribute-value-face))) | 309 | '((t (:inherit nxml-attribute-value))) |
| 338 | "Face used for the value of namespace attributes." | 310 | "Face used for the value of namespace attributes." |
| 339 | :group 'nxml-highlighting-faces) | 311 | :group 'nxml-faces) |
| 340 | 312 | ||
| 341 | (defface nxml-namespace-attribute-value-delimiter-face | 313 | (defface nxml-namespace-attribute-value-delimiter |
| 342 | '((t (:inherit nxml-attribute-value-delimiter-face))) | 314 | '((t (:inherit nxml-attribute-value-delimiter))) |
| 343 | "Face used for the delimiters of namespace attribute values." | 315 | "Face used for the delimiters of namespace attribute values." |
| 344 | :group 'nxml-highlighting-faces) | 316 | :group 'nxml-faces) |
| 345 | 317 | ||
| 346 | (defface nxml-prolog-literal-delimiter-face | 318 | (defface nxml-prolog-literal-delimiter |
| 347 | '((t (:inherit nxml-delimiter-face))) | 319 | '((t (:inherit nxml-delimited-data))) |
| 348 | "Face used for the delimiters of literals in the prolog." | 320 | "Face used for the delimiters of literals in the prolog." |
| 349 | :group 'nxml-highlighting-faces) | 321 | :group 'nxml-faces) |
| 350 | 322 | ||
| 351 | (defface nxml-prolog-literal-content-face | 323 | (defface nxml-prolog-literal-content |
| 352 | '((t (:inherit nxml-delimited-data-face))) | 324 | '((t (:inherit nxml-delimited-data))) |
| 353 | "Face used for the content of literals in the prolog." | 325 | "Face used for the content of literals in the prolog." |
| 354 | :group 'nxml-highlighting-faces) | 326 | :group 'nxml-faces) |
| 355 | 327 | ||
| 356 | (defface nxml-prolog-keyword-face | 328 | (defface nxml-prolog-keyword |
| 357 | '((t (:inherit nxml-name-face))) | 329 | '((t (:inherit font-lock-keyword-face))) |
| 358 | "Face used for keywords in the prolog." | 330 | "Face used for keywords in the prolog." |
| 359 | :group 'nxml-highlighting-faces) | 331 | :group 'nxml-faces) |
| 360 | 332 | ||
| 361 | (defface nxml-markup-declaration-delimiter-face | 333 | (defface nxml-markup-declaration-delimiter |
| 362 | '((t (:inherit nxml-delimiter-face))) | 334 | '((t (:inherit nxml-delimiter))) |
| 363 | "Face used for the delimiters of markup declarations in the prolog. | 335 | "Face used for the delimiters of markup declarations in the prolog. |
| 364 | The delimiters are <! and >." | 336 | The delimiters are <! and >." |
| 365 | :group 'nxml-highlighting-faces) | 337 | :group 'nxml-faces) |
| 366 | 338 | ||
| 367 | (defface nxml-hash-face | 339 | (defface nxml-hash |
| 368 | '((t (:inherit nxml-name-face))) | 340 | '((t (:inherit nxml-name))) |
| 369 | "Face used for # before a name in the prolog." | 341 | "Face used for # before a name in the prolog." |
| 370 | :group 'nxml-highlighting-faces) | 342 | :group 'nxml-faces) |
| 371 | 343 | ||
| 372 | (defface nxml-glyph-face | 344 | (defface nxml-glyph |
| 373 | '((((type x)) | 345 | '((((type x)) |
| 374 | (:family | 346 | (:family |
| 375 | "misc-fixed" | 347 | "misc-fixed" |
| @@ -391,14 +363,10 @@ The delimiters are <! and >." | |||
| 391 | :slant | 363 | :slant |
| 392 | normal))) | 364 | normal))) |
| 393 | "Face used for glyph for char references." | 365 | "Face used for glyph for char references." |
| 394 | :group 'nxml-highlighting-faces) | 366 | :group 'nxml-faces) |
| 395 | 367 | ||
| 396 | ;;; Global variables | 368 | ;;; Global variables |
| 397 | 369 | ||
| 398 | ;; This is initialized in rng-auto.el. | ||
| 399 | (defvar nxml-version nil | ||
| 400 | "*The version of nxml-mode that is being used.") | ||
| 401 | |||
| 402 | (defvar nxml-prolog-regions nil | 370 | (defvar nxml-prolog-regions nil |
| 403 | "List of regions in the prolog to be fontified. | 371 | "List of regions in the prolog to be fontified. |
| 404 | See the function `xmltok-forward-prolog' for more information.") | 372 | See the function `xmltok-forward-prolog' for more information.") |
| @@ -941,142 +909,142 @@ Leave point after last fontified position." | |||
| 941 | 909 | ||
| 942 | (put 'start-tag | 910 | (put 'start-tag |
| 943 | 'nxml-fontify-rule | 911 | 'nxml-fontify-rule |
| 944 | '([nil 1 nxml-tag-delimiter-face] | 912 | '([nil 1 nxml-tag-delimiter] |
| 945 | [-1 nil nxml-tag-delimiter-face] | 913 | [-1 nil nxml-tag-delimiter] |
| 946 | (element-qname . 1) | 914 | (element-qname . 1) |
| 947 | attributes)) | 915 | attributes)) |
| 948 | 916 | ||
| 949 | (put 'partial-start-tag | 917 | (put 'partial-start-tag |
| 950 | 'nxml-fontify-rule | 918 | 'nxml-fontify-rule |
| 951 | '([nil 1 nxml-tag-delimiter-face] | 919 | '([nil 1 nxml-tag-delimiter] |
| 952 | (element-qname . 1) | 920 | (element-qname . 1) |
| 953 | attributes)) | 921 | attributes)) |
| 954 | 922 | ||
| 955 | (put 'end-tag | 923 | (put 'end-tag |
| 956 | 'nxml-fontify-rule | 924 | 'nxml-fontify-rule |
| 957 | '([nil 1 nxml-tag-delimiter-face] | 925 | '([nil 1 nxml-tag-delimiter] |
| 958 | [1 2 nxml-tag-slash-face] | 926 | [1 2 nxml-tag-slash] |
| 959 | [-1 nil nxml-tag-delimiter-face] | 927 | [-1 nil nxml-tag-delimiter] |
| 960 | (element-qname . 2))) | 928 | (element-qname . 2))) |
| 961 | 929 | ||
| 962 | (put 'partial-end-tag | 930 | (put 'partial-end-tag |
| 963 | 'nxml-fontify-rule | 931 | 'nxml-fontify-rule |
| 964 | '([nil 1 nxml-tag-delimiter-face] | 932 | '([nil 1 nxml-tag-delimiter] |
| 965 | [1 2 nxml-tag-slash-face] | 933 | [1 2 nxml-tag-slash] |
| 966 | (element-qname . 2))) | 934 | (element-qname . 2))) |
| 967 | 935 | ||
| 968 | (put 'empty-element | 936 | (put 'empty-element |
| 969 | 'nxml-fontify-rule | 937 | 'nxml-fontify-rule |
| 970 | '([nil 1 nxml-tag-delimiter-face] | 938 | '([nil 1 nxml-tag-delimiter] |
| 971 | [-2 -1 nxml-tag-slash-face] | 939 | [-2 -1 nxml-tag-slash] |
| 972 | [-1 nil nxml-tag-delimiter-face] | 940 | [-1 nil nxml-tag-delimiter] |
| 973 | (element-qname . 1) | 941 | (element-qname . 1) |
| 974 | attributes)) | 942 | attributes)) |
| 975 | 943 | ||
| 976 | (put 'partial-empty-element | 944 | (put 'partial-empty-element |
| 977 | 'nxml-fontify-rule | 945 | 'nxml-fontify-rule |
| 978 | '([nil 1 nxml-tag-delimiter-face] | 946 | '([nil 1 nxml-tag-delimiter] |
| 979 | [-1 nil nxml-tag-slash-face] | 947 | [-1 nil nxml-tag-slash] |
| 980 | (element-qname . 1) | 948 | (element-qname . 1) |
| 981 | attributes)) | 949 | attributes)) |
| 982 | 950 | ||
| 983 | (put 'char-ref | 951 | (put 'char-ref |
| 984 | 'nxml-fontify-rule | 952 | 'nxml-fontify-rule |
| 985 | '([nil 2 nxml-char-ref-delimiter-face] | 953 | '([nil 2 nxml-char-ref-delimiter] |
| 986 | [2 -1 nxml-char-ref-number-face] | 954 | [2 -1 nxml-char-ref-number] |
| 987 | [-1 nil nxml-char-ref-delimiter-face] | 955 | [-1 nil nxml-char-ref-delimiter] |
| 988 | char-ref)) | 956 | char-ref)) |
| 989 | 957 | ||
| 990 | (put 'entity-ref | 958 | (put 'entity-ref |
| 991 | 'nxml-fontify-rule | 959 | 'nxml-fontify-rule |
| 992 | '([nil 1 nxml-entity-ref-delimiter-face] | 960 | '([nil 1 nxml-entity-ref-delimiter] |
| 993 | [1 -1 nxml-entity-ref-name-face] | 961 | [1 -1 nxml-entity-ref-name] |
| 994 | [-1 nil nxml-entity-ref-delimiter-face])) | 962 | [-1 nil nxml-entity-ref-delimiter])) |
| 995 | 963 | ||
| 996 | (put 'comment | 964 | (put 'comment |
| 997 | 'nxml-fontify-rule | 965 | 'nxml-fontify-rule |
| 998 | '([nil 4 nxml-comment-delimiter-face] | 966 | '([nil 4 nxml-comment-delimiter] |
| 999 | [4 -3 nxml-comment-content-face] | 967 | [4 -3 nxml-comment-content] |
| 1000 | [-3 nil nxml-comment-delimiter-face])) | 968 | [-3 nil nxml-comment-delimiter])) |
| 1001 | 969 | ||
| 1002 | (put 'processing-instruction | 970 | (put 'processing-instruction |
| 1003 | 'nxml-fontify-rule | 971 | 'nxml-fontify-rule |
| 1004 | '([nil 2 nxml-processing-instruction-delimiter-face] | 972 | '([nil 2 nxml-processing-instruction-delimiter] |
| 1005 | [-2 nil nxml-processing-instruction-delimiter-face] | 973 | [-2 nil nxml-processing-instruction-delimiter] |
| 1006 | processing-instruction-content)) | 974 | processing-instruction-content)) |
| 1007 | 975 | ||
| 1008 | (put 'cdata-section | 976 | (put 'cdata-section |
| 1009 | 'nxml-fontify-rule | 977 | 'nxml-fontify-rule |
| 1010 | '([nil 3 nxml-cdata-section-delimiter-face] ; <![ | 978 | '([nil 3 nxml-cdata-section-delimiter] ; <![ |
| 1011 | [3 8 nxml-cdata-section-CDATA-face] ; CDATA | 979 | [3 8 nxml-cdata-section-CDATA] ; CDATA |
| 1012 | [8 9 nxml-cdata-section-delimiter-face] ; [ | 980 | [8 9 nxml-cdata-section-delimiter] ; [ |
| 1013 | [9 -3 nxml-cdata-section-content-face] ; ]]> | 981 | [9 -3 nxml-cdata-section-content] ; ]]> |
| 1014 | [-3 nil nxml-cdata-section-delimiter-face])) | 982 | [-3 nil nxml-cdata-section-delimiter])) |
| 1015 | 983 | ||
| 1016 | (put 'data | 984 | (put 'data |
| 1017 | 'nxml-fontify-rule | 985 | 'nxml-fontify-rule |
| 1018 | '([nil nil nxml-text-face])) | 986 | '([nil nil nxml-text])) |
| 1019 | 987 | ||
| 1020 | ;; Prolog region types in list returned by xmltok-forward-prolog. | 988 | ;; Prolog region types in list returned by xmltok-forward-prolog. |
| 1021 | 989 | ||
| 1022 | (put 'xml-declaration | 990 | (put 'xml-declaration |
| 1023 | 'nxml-fontify-rule | 991 | 'nxml-fontify-rule |
| 1024 | '([nil 2 nxml-processing-instruction-delimiter-face] | 992 | '([nil 2 nxml-processing-instruction-delimiter] |
| 1025 | [2 5 nxml-processing-instruction-target-face] | 993 | [2 5 nxml-processing-instruction-target] |
| 1026 | [-2 nil nxml-processing-instruction-delimiter-face])) | 994 | [-2 nil nxml-processing-instruction-delimiter])) |
| 1027 | 995 | ||
| 1028 | (put 'xml-declaration-attribute-name | 996 | (put 'xml-declaration-attribute-name |
| 1029 | 'nxml-fontify-rule | 997 | 'nxml-fontify-rule |
| 1030 | '([nil nil nxml-attribute-local-name-face])) | 998 | '([nil nil nxml-attribute-local-name])) |
| 1031 | 999 | ||
| 1032 | (put 'xml-declaration-attribute-value | 1000 | (put 'xml-declaration-attribute-value |
| 1033 | 'nxml-fontify-rule | 1001 | 'nxml-fontify-rule |
| 1034 | '([nil 1 nxml-attribute-value-delimiter-face] | 1002 | '([nil 1 nxml-attribute-value-delimiter] |
| 1035 | [1 -1 nxml-attribute-value-face] | 1003 | [1 -1 nxml-attribute-value] |
| 1036 | [-1 nil nxml-attribute-value-delimiter-face])) | 1004 | [-1 nil nxml-attribute-value-delimiter])) |
| 1037 | 1005 | ||
| 1038 | (put 'processing-instruction-left | 1006 | (put 'processing-instruction-left |
| 1039 | 'nxml-fontify-rule | 1007 | 'nxml-fontify-rule |
| 1040 | '([nil 2 nxml-processing-instruction-delimiter-face] | 1008 | '([nil 2 nxml-processing-instruction-delimiter] |
| 1041 | [2 nil nxml-processing-instruction-target-face])) | 1009 | [2 nil nxml-processing-instruction-target])) |
| 1042 | 1010 | ||
| 1043 | (put 'processing-instruction-right | 1011 | (put 'processing-instruction-right |
| 1044 | 'nxml-fontify-rule | 1012 | 'nxml-fontify-rule |
| 1045 | '([nil -2 nxml-processing-instruction-content-face] | 1013 | '([nil -2 nxml-processing-instruction-content] |
| 1046 | [-2 nil nxml-processing-instruction-delimiter-face])) | 1014 | [-2 nil nxml-processing-instruction-delimiter])) |
| 1047 | 1015 | ||
| 1048 | (put 'literal | 1016 | (put 'literal |
| 1049 | 'nxml-fontify-rule | 1017 | 'nxml-fontify-rule |
| 1050 | '([nil 1 nxml-prolog-literal-delimiter-face] | 1018 | '([nil 1 nxml-prolog-literal-delimiter] |
| 1051 | [1 -1 nxml-prolog-literal-content-face] | 1019 | [1 -1 nxml-prolog-literal-content] |
| 1052 | [-1 nil nxml-prolog-literal-delimiter-face])) | 1020 | [-1 nil nxml-prolog-literal-delimiter])) |
| 1053 | 1021 | ||
| 1054 | (put 'keyword | 1022 | (put 'keyword |
| 1055 | 'nxml-fontify-rule | 1023 | 'nxml-fontify-rule |
| 1056 | '([nil nil nxml-prolog-keyword-face])) | 1024 | '([nil nil nxml-prolog-keyword])) |
| 1057 | 1025 | ||
| 1058 | (put 'markup-declaration-open | 1026 | (put 'markup-declaration-open |
| 1059 | 'nxml-fontify-rule | 1027 | 'nxml-fontify-rule |
| 1060 | '([0 2 nxml-markup-declaration-delimiter-face] | 1028 | '([0 2 nxml-markup-declaration-delimiter] |
| 1061 | [2 nil nxml-prolog-keyword-face])) | 1029 | [2 nil nxml-prolog-keyword])) |
| 1062 | 1030 | ||
| 1063 | (put 'markup-declaration-close | 1031 | (put 'markup-declaration-close |
| 1064 | 'nxml-fontify-rule | 1032 | 'nxml-fontify-rule |
| 1065 | '([nil nil nxml-markup-declaration-delimiter-face])) | 1033 | '([nil nil nxml-markup-declaration-delimiter])) |
| 1066 | 1034 | ||
| 1067 | (put 'internal-subset-open | 1035 | (put 'internal-subset-open |
| 1068 | 'nxml-fontify-rule | 1036 | 'nxml-fontify-rule |
| 1069 | '([nil nil nxml-markup-declaration-delimiter-face])) | 1037 | '([nil nil nxml-markup-declaration-delimiter])) |
| 1070 | 1038 | ||
| 1071 | (put 'internal-subset-close | 1039 | (put 'internal-subset-close |
| 1072 | 'nxml-fontify-rule | 1040 | 'nxml-fontify-rule |
| 1073 | '([nil 1 nxml-markup-declaration-delimiter-face] | 1041 | '([nil 1 nxml-markup-declaration-delimiter] |
| 1074 | [-1 nil nxml-markup-declaration-delimiter-face])) | 1042 | [-1 nil nxml-markup-declaration-delimiter])) |
| 1075 | 1043 | ||
| 1076 | (put 'hash-name | 1044 | (put 'hash-name |
| 1077 | 'nxml-fontify-rule | 1045 | 'nxml-fontify-rule |
| 1078 | '([nil 1 nxml-hash-face] | 1046 | '([nil 1 nxml-hash] |
| 1079 | [1 nil nxml-prolog-keyword-face])) | 1047 | [1 nil nxml-prolog-keyword])) |
| 1080 | 1048 | ||
| 1081 | (defun nxml-apply-fontify-rule (&optional type start end) | 1049 | (defun nxml-apply-fontify-rule (&optional type start end) |
| 1082 | (let ((rule (get (or type xmltok-type) 'nxml-fontify-rule))) | 1050 | (let ((rule (get (or type xmltok-type) 'nxml-fontify-rule))) |
| @@ -1101,21 +1069,21 @@ Leave point after last fontified position." | |||
| 1101 | (nxml-fontify-qname (+ start (cdr action)) | 1069 | (nxml-fontify-qname (+ start (cdr action)) |
| 1102 | xmltok-name-colon | 1070 | xmltok-name-colon |
| 1103 | xmltok-name-end | 1071 | xmltok-name-end |
| 1104 | 'nxml-element-prefix-face | 1072 | 'nxml-element-prefix |
| 1105 | 'nxml-element-colon-face | 1073 | 'nxml-element-colon |
| 1106 | 'nxml-element-local-name-face))) | 1074 | 'nxml-element-local-name))) |
| 1107 | ((eq action 'attributes) | 1075 | ((eq action 'attributes) |
| 1108 | (nxml-fontify-attributes)) | 1076 | (nxml-fontify-attributes)) |
| 1109 | ((eq action 'processing-instruction-content) | 1077 | ((eq action 'processing-instruction-content) |
| 1110 | (nxml-set-face (+ start 2) | 1078 | (nxml-set-face (+ start 2) |
| 1111 | xmltok-name-end | 1079 | xmltok-name-end |
| 1112 | 'nxml-processing-instruction-target-face) | 1080 | 'nxml-processing-instruction-target) |
| 1113 | (nxml-set-face (save-excursion | 1081 | (nxml-set-face (save-excursion |
| 1114 | (goto-char xmltok-name-end) | 1082 | (goto-char xmltok-name-end) |
| 1115 | (skip-chars-forward " \t\r\n") | 1083 | (skip-chars-forward " \t\r\n") |
| 1116 | (point)) | 1084 | (point)) |
| 1117 | (- end 2) | 1085 | (- end 2) |
| 1118 | 'nxml-processing-instruction-content-face)) | 1086 | 'nxml-processing-instruction-content)) |
| 1119 | ((eq action 'char-ref) | 1087 | ((eq action 'char-ref) |
| 1120 | (nxml-char-ref-display-extra start | 1088 | (nxml-char-ref-display-extra start |
| 1121 | end | 1089 | end |
| @@ -1138,25 +1106,25 @@ Leave point after last fontified position." | |||
| 1138 | (nxml-fontify-qname (xmltok-attribute-name-start att) | 1106 | (nxml-fontify-qname (xmltok-attribute-name-start att) |
| 1139 | (xmltok-attribute-name-colon att) | 1107 | (xmltok-attribute-name-colon att) |
| 1140 | (xmltok-attribute-name-end att) | 1108 | (xmltok-attribute-name-end att) |
| 1141 | 'nxml-namespace-attribute-xmlns-face | 1109 | 'nxml-namespace-attribute-xmlns |
| 1142 | 'nxml-namespace-attribute-colon-face | 1110 | 'nxml-namespace-attribute-colon |
| 1143 | 'nxml-namespace-attribute-prefix-face | 1111 | 'nxml-namespace-attribute-prefix |
| 1144 | 'nxml-namespace-attribute-xmlns-face) | 1112 | 'nxml-namespace-attribute-xmlns) |
| 1145 | (nxml-fontify-qname (xmltok-attribute-name-start att) | 1113 | (nxml-fontify-qname (xmltok-attribute-name-start att) |
| 1146 | (xmltok-attribute-name-colon att) | 1114 | (xmltok-attribute-name-colon att) |
| 1147 | (xmltok-attribute-name-end att) | 1115 | (xmltok-attribute-name-end att) |
| 1148 | 'nxml-attribute-prefix-face | 1116 | 'nxml-attribute-prefix |
| 1149 | 'nxml-attribute-colon-face | 1117 | 'nxml-attribute-colon |
| 1150 | 'nxml-attribute-local-name-face)) | 1118 | 'nxml-attribute-local-name)) |
| 1151 | (let ((start (xmltok-attribute-value-start att)) | 1119 | (let ((start (xmltok-attribute-value-start att)) |
| 1152 | (end (xmltok-attribute-value-end att)) | 1120 | (end (xmltok-attribute-value-end att)) |
| 1153 | (refs (xmltok-attribute-refs att)) | 1121 | (refs (xmltok-attribute-refs att)) |
| 1154 | (delimiter-face (if namespace-declaration | 1122 | (delimiter-face (if namespace-declaration |
| 1155 | 'nxml-namespace-attribute-value-delimiter-face | 1123 | 'nxml-namespace-attribute-value-delimiter |
| 1156 | 'nxml-attribute-value-delimiter-face)) | 1124 | 'nxml-attribute-value-delimiter)) |
| 1157 | (value-face (if namespace-declaration | 1125 | (value-face (if namespace-declaration |
| 1158 | 'nxml-namespace-attribute-value-face | 1126 | 'nxml-namespace-attribute-value |
| 1159 | 'nxml-attribute-value-face))) | 1127 | 'nxml-attribute-value))) |
| 1160 | (when start | 1128 | (when start |
| 1161 | (nxml-set-face (1- start) start delimiter-face) | 1129 | (nxml-set-face (1- start) start delimiter-face) |
| 1162 | (nxml-set-face end (1+ end) delimiter-face) | 1130 | (nxml-set-face end (1+ end) delimiter-face) |
| @@ -2598,7 +2566,7 @@ With a prefix argument, inserts the character directly." | |||
| 2598 | (when nxml-char-ref-extra-display | 2566 | (when nxml-char-ref-extra-display |
| 2599 | (let ((name (nxml-get-char-name n)) | 2567 | (let ((name (nxml-get-char-name n)) |
| 2600 | (glyph-string (and nxml-char-ref-display-glyph-flag | 2568 | (glyph-string (and nxml-char-ref-display-glyph-flag |
| 2601 | (nxml-glyph-display-string n 'nxml-glyph-face))) | 2569 | (nxml-glyph-display-string n 'nxml-glyph))) |
| 2602 | ov) | 2570 | ov) |
| 2603 | (when (or name glyph-string) | 2571 | (when (or name glyph-string) |
| 2604 | (setq ov (make-overlay start end nil t)) | 2572 | (setq ov (make-overlay start end nil t)) |
| @@ -2608,7 +2576,7 @@ With a prefix argument, inserts the character directly." | |||
| 2608 | (when glyph-string | 2576 | (when glyph-string |
| 2609 | (overlay-put ov | 2577 | (overlay-put ov |
| 2610 | 'after-string | 2578 | 'after-string |
| 2611 | (propertize glyph-string 'face 'nxml-glyph-face))))))) | 2579 | (propertize glyph-string 'face 'nxml-glyph))))))) |
| 2612 | 2580 | ||
| 2613 | (defun nxml-clear-char-ref-extra-display (start end) | 2581 | (defun nxml-clear-char-ref-extra-display (start end) |
| 2614 | (let ((ov (overlays-in start end))) | 2582 | (let ((ov (overlays-in start end))) |
| @@ -2617,15 +2585,6 @@ With a prefix argument, inserts the character directly." | |||
| 2617 | (delete-overlay (car ov))) | 2585 | (delete-overlay (car ov))) |
| 2618 | (setq ov (cdr ov))))) | 2586 | (setq ov (cdr ov))))) |
| 2619 | 2587 | ||
| 2620 | ;;; Versioning | ||
| 2621 | |||
| 2622 | (defun nxml-version () | ||
| 2623 | "Show the version of nXML mode that is being used." | ||
| 2624 | (interactive) | ||
| 2625 | (if nxml-version | ||
| 2626 | (message "nXML mode version %s" nxml-version) | ||
| 2627 | (message "nXML mode version unknown"))) | ||
| 2628 | |||
| 2629 | 2588 | ||
| 2630 | (defun nxml-start-delimiter-length (type) | 2589 | (defun nxml-start-delimiter-length (type) |
| 2631 | (or (get type 'nxml-start-delimiter-length) | 2590 | (or (get type 'nxml-start-delimiter-length) |