Mercurial > emacs
comparison lisp/nxml/nxml-util.el @ 95598:8c4c0ca00399
nXML: Use font lock
author | Michael Olson <mwolson@gnu.org> |
---|---|
date | Fri, 06 Jun 2008 16:14:49 +0000 |
parents | d495d4d5452f |
children | d17729251339 |
comparison
equal
deleted
inserted
replaced
95597:d89ef0f12bd4 | 95598:8c4c0ca00399 |
---|---|
22 | 22 |
23 ;;; Commentary: | 23 ;;; Commentary: |
24 | 24 |
25 ;;; Code: | 25 ;;; Code: |
26 | 26 |
27 (defconst nxml-debug nil | |
28 "enable nxml debugging. effective only at compile time") | |
29 | |
30 (eval-when-compile | |
31 (require 'cl)) | |
32 | |
33 (defsubst nxml-debug (format &rest args) | |
34 (when nxml-debug | |
35 (apply #'message format args))) | |
36 | |
37 (defmacro nxml-debug-change (name start end) | |
38 (when nxml-debug | |
39 `(nxml-debug "%s: %S" ,name | |
40 (buffer-substring-no-properties ,start ,end)))) | |
41 | |
42 (defmacro nxml-debug-set-inside (start end) | |
43 (when nxml-debug | |
44 `(let ((overlay (make-overlay ,start ,end))) | |
45 (overlay-put overlay 'face '(:background "red")) | |
46 (overlay-put overlay 'nxml-inside-debug t) | |
47 (nxml-debug-change "nxml-set-inside" ,start ,end)))) | |
48 | |
49 (defmacro nxml-debug-clear-inside (start end) | |
50 (when nxml-debug | |
51 `(loop for overlay in (overlays-in ,start ,end) | |
52 if (overlay-get overlay 'nxml-inside-debug) | |
53 do (delete-overlay overlay) | |
54 finally (nxml-debug-change "nxml-clear-inside" ,start ,end)))) | |
55 | |
27 (defun nxml-make-namespace (str) | 56 (defun nxml-make-namespace (str) |
28 "Return a symbol for the namespace URI STR. | 57 "Return a symbol for the namespace URI STR. |
29 STR must be a string. If STR is the empty string, return nil. | 58 STR must be a string. If STR is the empty string, return nil. |
30 Otherwise, return the symbol whose name is STR prefixed with a colon." | 59 Otherwise, return the symbol whose name is STR prefixed with a colon." |
31 (if (string-equal str "") | 60 (if (string-equal str "") |
35 (defun nxml-namespace-name (ns) | 64 (defun nxml-namespace-name (ns) |
36 "Return the namespace URI corresponding to the symbol NS. | 65 "Return the namespace URI corresponding to the symbol NS. |
37 This is the inverse of `nxml-make-namespace'." | 66 This is the inverse of `nxml-make-namespace'." |
38 (and ns (substring (symbol-name ns) 1))) | 67 (and ns (substring (symbol-name ns) 1))) |
39 | 68 |
40 (defconst nxml-xml-namespace-uri | 69 (defconst nxml-xml-namespace-uri |
41 (nxml-make-namespace "http://www.w3.org/XML/1998/namespace")) | 70 (nxml-make-namespace "http://www.w3.org/XML/1998/namespace")) |
42 | 71 |
43 (defconst nxml-xmlns-namespace-uri | 72 (defconst nxml-xmlns-namespace-uri |
44 (nxml-make-namespace "http://www.w3.org/2000/xmlns/")) | 73 (nxml-make-namespace "http://www.w3.org/2000/xmlns/")) |
74 | |
75 (defmacro nxml-with-degradation-on-error (context &rest body) | |
76 (if (not nxml-debug) | |
77 (let ((error-symbol (make-symbol "err"))) | |
78 `(condition-case ,error-symbol | |
79 (progn ,@body) | |
80 (error | |
81 (nxml-degrade ,context ,error-symbol)))) | |
82 `(progn ,@body))) | |
45 | 83 |
46 (defmacro nxml-with-unmodifying-text-property-changes (&rest body) | 84 (defmacro nxml-with-unmodifying-text-property-changes (&rest body) |
47 "Evaluate BODY without any text property changes modifying the buffer. | 85 "Evaluate BODY without any text property changes modifying the buffer. |
48 Any text properties changes happen as usual but the changes are not treated as | 86 Any text properties changes happen as usual but the changes are not treated as |
49 modifications to the buffer." | 87 modifications to the buffer." |