diff options
author | Michael Olson <mwolson@gnu.org> | 2008-06-06 16:14:49 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2008-06-06 16:14:49 +0000 |
commit | e8ec402f1b86a1ed2c61bbc7de27aaefa2adb496 (patch) | |
tree | 5f38efb237d6a61a93748ebee3028643e2fb49b9 /lisp/nxml/nxml-util.el | |
parent | 0a3a94b3d28f55ceb4d443da17c00c9bda83eb4a (diff) | |
download | emacs-e8ec402f1b86a1ed2c61bbc7de27aaefa2adb496.tar.gz |
nXML: Use font lock
Diffstat (limited to 'lisp/nxml/nxml-util.el')
-rw-r--r-- | lisp/nxml/nxml-util.el | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/lisp/nxml/nxml-util.el b/lisp/nxml/nxml-util.el index 3aab1ee6b8c..2e90dfc32dc 100644 --- a/lisp/nxml/nxml-util.el +++ b/lisp/nxml/nxml-util.el @@ -24,6 +24,35 @@ ;;; Code: +(defconst nxml-debug nil + "enable nxml debugging. effective only at compile time") + +(eval-when-compile + (require 'cl)) + +(defsubst nxml-debug (format &rest args) + (when nxml-debug + (apply #'message format args))) + +(defmacro nxml-debug-change (name start end) + (when nxml-debug + `(nxml-debug "%s: %S" ,name + (buffer-substring-no-properties ,start ,end)))) + +(defmacro nxml-debug-set-inside (start end) + (when nxml-debug + `(let ((overlay (make-overlay ,start ,end))) + (overlay-put overlay 'face '(:background "red")) + (overlay-put overlay 'nxml-inside-debug t) + (nxml-debug-change "nxml-set-inside" ,start ,end)))) + +(defmacro nxml-debug-clear-inside (start end) + (when nxml-debug + `(loop for overlay in (overlays-in ,start ,end) + if (overlay-get overlay 'nxml-inside-debug) + do (delete-overlay overlay) + finally (nxml-debug-change "nxml-clear-inside" ,start ,end)))) + (defun nxml-make-namespace (str) "Return a symbol for the namespace URI STR. STR must be a string. If STR is the empty string, return nil. @@ -37,12 +66,21 @@ Otherwise, return the symbol whose name is STR prefixed with a colon." This is the inverse of `nxml-make-namespace'." (and ns (substring (symbol-name ns) 1))) -(defconst nxml-xml-namespace-uri +(defconst nxml-xml-namespace-uri (nxml-make-namespace "http://www.w3.org/XML/1998/namespace")) (defconst nxml-xmlns-namespace-uri (nxml-make-namespace "http://www.w3.org/2000/xmlns/")) +(defmacro nxml-with-degradation-on-error (context &rest body) + (if (not nxml-debug) + (let ((error-symbol (make-symbol "err"))) + `(condition-case ,error-symbol + (progn ,@body) + (error + (nxml-degrade ,context ,error-symbol)))) + `(progn ,@body))) + (defmacro nxml-with-unmodifying-text-property-changes (&rest body) "Evaluate BODY without any text property changes modifying the buffer. Any text properties changes happen as usual but the changes are not treated as |