+(defconst nxml-debug nil
+ "Enable nxml debugging. Effective only at compile time.")
+
+(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))))
+