Variable: rng-validate-mode
rng-validate-mode is a buffer-local variable defined in
rng-valid.el.gz.
Documentation
Non-nil if Rng-Validate mode is enabled.
Use the command rng-validate-mode(var)/rng-validate-mode(fun) to change this variable.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/nxml/rng-valid.el.gz
;;;###autoload
(define-minor-mode rng-validate-mode
"Minor mode performing continual validation against a RELAX NG schema.
Checks whether the buffer is a well-formed XML 1.0 document,
conforming to the XML Namespaces Recommendation and valid against a
RELAX NG schema. The mode-line indicates whether it is or not. Any
parts of the buffer that cause it not to be are considered errors and
are highlighted with face `rng-error'. A description of each error is
available as a tooltip. \\[rng-next-error] goes to the next error
after point. Clicking mouse-1 on the word `Invalid' in the mode-line
goes to the first error in the buffer. If the buffer changes, then it
will be automatically rechecked when Emacs becomes idle; the
rechecking will be paused whenever there is input pending.
By default, uses a vacuous schema that allows any well-formed XML
document. A schema can be specified explicitly using
\\[rng-set-schema-file-and-validate], or implicitly based on the buffer's
file name or on the root element name. In each case the schema must
be a RELAX NG schema using the compact schema \(such schemas
conventionally have a suffix of `.rnc'). The variable
`rng-schema-locating-files' specifies files containing rules
to use for finding the schema."
:global nil
(save-restriction
(widen)
(with-silent-modifications
(rng-clear-cached-state (point-min) (point-max)))
;; 1+ to clear empty overlays at (point-max)
(rng-clear-overlays (point-min) (1+ (point-max)))
(setq rng-validate-up-to-date-end (point-min)))
(rng-clear-conditional-region)
(setq rng-error-count 0)
;; do this here to avoid infinite loop if we set the schema
(remove-hook 'rng-schema-change-hook #'rng-validate-clear t)
(cond (rng-validate-mode
(unwind-protect
(save-excursion
;; An error can change the current buffer
(when (or (not rng-current-schema)
(eq rng-current-schema rng-any-element))
(rng-auto-set-schema t)))
(unless rng-current-schema (rng-set-schema-file-1 nil))
(add-hook 'rng-schema-change-hook #'rng-validate-clear nil t)
(add-hook 'after-change-functions #'rng-after-change-function nil t)
(add-hook 'kill-buffer-hook #'rng-kill-timers nil t)
(add-hook 'echo-area-clear-hook #'rng-echo-area-clear-function nil t)
(add-hook 'post-command-hook #'rng-maybe-echo-error-at-point nil t)
(rng-match-init-buffer)
(rng-activate-timers)
;; Start validating right away if the buffer is visible.
;; If it's not visible, don't do this, because the user
;; won't get any progress indication. When the user finds
;; a new file, then the buffer won't be visible
;; when this is invoked.
(when (get-buffer-window (current-buffer) 'visible)
(rng-validate-while-idle (current-buffer)))))
(t
(rng-cancel-timers)
(remove-hook 'kill-buffer-hook #'rng-cancel-timers t)
(remove-hook 'post-command-hook #'rng-maybe-echo-error-at-point t)
(remove-hook 'echo-area-clear-hook #'rng-echo-area-clear-function t)
(remove-hook 'after-change-functions #'rng-after-change-function t))))