aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/sgml-mode.el16
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 75d56392fab..87c9e820e1f 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -239,6 +239,7 @@ separated by a space."
239 :type '(choice (const nil) integer) 239 :type '(choice (const nil) integer)
240 :group 'sgml) 240 :group 'sgml)
241 241
242(defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*")
242(defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*") 243(defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
243(defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)")) 244(defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)"))
244(defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*") 245(defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*")
@@ -246,13 +247,24 @@ separated by a space."
246 "Regular expression that matches a non-empty start tag. 247 "Regular expression that matches a non-empty start tag.
247Any terminating `>' or `/' is not matched.") 248Any terminating `>' or `/' is not matched.")
248 249
250(defface sgml-namespace-face
251 '((t (:inherit font-lock-builtin-face)))
252 "`sgml-mode' face used to highlight the namespace part of identifiers.")
253(defvar sgml-namespace-face 'sgml-namespace-face)
249 254
250;; internal 255;; internal
251(defconst sgml-font-lock-keywords-1 256(defconst sgml-font-lock-keywords-1
252 `((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face) 257 `((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face)
253 (,(concat "<\\(/?" sgml-name-re"\\)") 1 font-lock-function-name-face) 258 ;; We could use the simpler "\\(" sgml-namespace-re ":\\)?" instead,
259 ;; but it would cause a bit more backtracking in the re-matcher.
260 (,(concat "</?\\(" sgml-namespace-re "\\)\\(?::\\(" sgml-name-re "\\)\\)?")
261 (1 (if (match-end 2) sgml-namespace-face font-lock-function-name-face))
262 (2 font-lock-function-name-face nil t))
254 ;; FIXME: this doesn't cover the variables using a default value. 263 ;; FIXME: this doesn't cover the variables using a default value.
255 (,(concat "\\(" sgml-name-re "\\)=[\"']") 1 font-lock-variable-name-face) 264 (,(concat "\\(" sgml-namespace-re "\\)\\(?::\\("
265 sgml-name-re "\\)\\)?=[\"']")
266 (1 (if (match-end 2) sgml-namespace-face font-lock-variable-name-face))
267 (2 font-lock-variable-name-face nil t))
256 (,(concat "[&%]" sgml-name-re ";?") . font-lock-variable-name-face))) 268 (,(concat "[&%]" sgml-name-re ";?") . font-lock-variable-name-face)))
257 269
258(defconst sgml-font-lock-keywords-2 270(defconst sgml-font-lock-keywords-2