2016-01-15 10:29:20 -05:00
|
|
|
;;; rng-loc.el --- Locate the schema to use for validation -*- lexical-binding:t -*-
|
2007-11-23 06:58:00 +00:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
;; Copyright (C) 2003, 2007-2020 Free Software Foundation, Inc.
|
2007-11-23 06:58:00 +00:00
|
|
|
|
|
|
|
;; Author: James Clark
|
2014-03-20 23:56:55 -07:00
|
|
|
;; Keywords: wp, hypermedia, languages, XML, RelaxNG
|
2007-11-23 06:58:00 +00:00
|
|
|
|
2007-11-28 04:14:05 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
2007-11-23 06:58:00 +00:00
|
|
|
|
2008-05-06 04:29:13 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-11-28 04:14:05 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 04:29:13 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2007-11-23 06:58:00 +00:00
|
|
|
|
2007-11-28 04:14:05 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2007-11-23 06:58:00 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'nxml-util)
|
|
|
|
(require 'nxml-parse)
|
|
|
|
(require 'rng-parse)
|
|
|
|
(require 'rng-uri)
|
|
|
|
(require 'rng-util)
|
|
|
|
(require 'xmltok)
|
|
|
|
|
2016-01-15 10:29:20 -05:00
|
|
|
(defvar-local rng-current-schema-file-name nil
|
2007-11-23 06:58:00 +00:00
|
|
|
"Filename of schema being used for current buffer.
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
It is nil if using a vacuous schema.")
|
2007-11-23 06:58:00 +00:00
|
|
|
|
2007-12-19 00:55:56 +00:00
|
|
|
(defvar rng-schema-locating-files-default
|
2007-12-19 01:46:23 +00:00
|
|
|
(list "schemas.xml" (expand-file-name "schema/schemas.xml" data-directory))
|
2007-11-23 06:58:00 +00:00
|
|
|
"Default value for variable `rng-schema-locating-files'.")
|
|
|
|
|
2007-12-19 00:55:56 +00:00
|
|
|
(defvar rng-schema-locating-file-schema-file
|
2007-12-19 01:46:23 +00:00
|
|
|
(expand-file-name "schema/locate.rnc" data-directory)
|
2007-11-23 06:58:00 +00:00
|
|
|
"File containing schema for schema locating files.")
|
|
|
|
|
|
|
|
(defvar rng-schema-locating-file-schema nil
|
|
|
|
"Schema for schema locating files or nil if not yet loaded.")
|
|
|
|
|
|
|
|
(defcustom rng-schema-locating-files rng-schema-locating-files-default
|
2010-12-02 19:10:25 -08:00
|
|
|
"List of schema locating files."
|
2007-11-23 06:58:00 +00:00
|
|
|
:type '(repeat file)
|
|
|
|
:group 'relax-ng)
|
|
|
|
|
2007-12-19 00:55:56 +00:00
|
|
|
(defvar rng-schema-loader-alist '(("rnc" . rng-c-load-schema))
|
2007-11-23 06:58:00 +00:00
|
|
|
"Alist of schema extensions vs schema loader functions.")
|
|
|
|
|
|
|
|
(defvar rng-cached-document-element nil)
|
|
|
|
|
|
|
|
(defvar rng-document-type-history nil)
|
|
|
|
|
|
|
|
(defun rng-set-document-type (type-id)
|
|
|
|
(interactive (list (rng-read-type-id)))
|
|
|
|
(condition-case err
|
|
|
|
(when (not (string= type-id ""))
|
|
|
|
(let ((schema-file (rng-locate-schema-file type-id)))
|
|
|
|
(unless schema-file
|
|
|
|
(error "Could not locate schema for type id `%s'" type-id))
|
|
|
|
(rng-set-schema-file-1 schema-file))
|
|
|
|
(rng-save-schema-location-1 t type-id)
|
|
|
|
(rng-what-schema))
|
|
|
|
(nxml-file-parse-error
|
|
|
|
(nxml-display-file-parse-error err))))
|
|
|
|
|
|
|
|
(defun rng-read-type-id ()
|
|
|
|
(condition-case err
|
|
|
|
(let ((type-ids (rng-possible-type-ids))
|
|
|
|
(completion-ignore-case nil))
|
|
|
|
(completing-read "Document type id: "
|
|
|
|
(mapcar (lambda (x) (cons x nil))
|
|
|
|
type-ids)
|
|
|
|
nil
|
|
|
|
t
|
|
|
|
nil
|
|
|
|
'rng-document-type-history))
|
|
|
|
(nxml-file-parse-error
|
|
|
|
(nxml-display-file-parse-error err))))
|
|
|
|
|
|
|
|
(defun rng-set-schema-file (filename)
|
|
|
|
"Set the schema for the current buffer to the schema in FILENAME.
|
|
|
|
FILENAME must be the name of a file containing a schema.
|
|
|
|
The extension of FILENAME is used to determine what kind of schema it
|
|
|
|
is. The variable `rng-schema-loader-alist' maps from schema
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
extensions to schema loader functions. The function
|
2007-11-23 06:58:00 +00:00
|
|
|
`rng-c-load-schema' is the loader for RELAX NG compact syntax. The
|
|
|
|
association is between the buffer and the schema: the association is
|
|
|
|
lost when the buffer is killed."
|
|
|
|
(interactive "fSchema file: ")
|
|
|
|
(condition-case err
|
|
|
|
(progn
|
|
|
|
(rng-set-schema-file-1 filename)
|
|
|
|
(rng-save-schema-location-1 t))
|
|
|
|
(nxml-file-parse-error
|
|
|
|
(nxml-display-file-parse-error err))))
|
|
|
|
|
|
|
|
(defun rng-set-vacuous-schema ()
|
|
|
|
"Set the schema for the current buffer to allow any well-formed XML."
|
|
|
|
(interactive)
|
|
|
|
(rng-set-schema-file-1 nil)
|
|
|
|
(rng-what-schema))
|
|
|
|
|
|
|
|
(defun rng-set-schema-file-1 (filename)
|
|
|
|
(setq filename (and filename (expand-file-name filename)))
|
|
|
|
(setq rng-current-schema
|
|
|
|
(if filename
|
|
|
|
(rng-load-schema filename)
|
|
|
|
rng-any-element))
|
|
|
|
(setq rng-current-schema-file-name filename)
|
|
|
|
(run-hooks 'rng-schema-change-hook))
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
|
2007-11-23 06:58:00 +00:00
|
|
|
(defun rng-load-schema (filename)
|
|
|
|
(let* ((extension (file-name-extension filename))
|
|
|
|
(loader (cdr (assoc extension rng-schema-loader-alist))))
|
|
|
|
(or loader
|
|
|
|
(if extension
|
|
|
|
(error "No schema loader available for file extension `%s'"
|
|
|
|
extension)
|
|
|
|
(error "No schema loader available for null file extension")))
|
|
|
|
(funcall loader filename)))
|
|
|
|
|
|
|
|
(defun rng-what-schema ()
|
|
|
|
"Display a message saying what schema `rng-validate-mode' is using."
|
|
|
|
(interactive)
|
|
|
|
(if rng-current-schema-file-name
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
(message "Using schema %s"
|
2007-11-23 06:58:00 +00:00
|
|
|
(abbreviate-file-name rng-current-schema-file-name))
|
|
|
|
(message "Using vacuous schema")))
|
|
|
|
|
|
|
|
(defun rng-auto-set-schema (&optional no-display-error)
|
|
|
|
"Set the schema for this buffer based on the buffer's contents and file-name."
|
|
|
|
(interactive)
|
|
|
|
(condition-case err
|
|
|
|
(progn
|
|
|
|
(rng-set-schema-file-1 (rng-locate-schema-file))
|
|
|
|
(rng-what-schema))
|
|
|
|
(nxml-file-parse-error
|
|
|
|
(if no-display-error
|
|
|
|
(error "%s at position %s in %s"
|
|
|
|
(nth 3 err)
|
|
|
|
(nth 2 err)
|
|
|
|
(abbreviate-file-name (nth 1 err)))
|
|
|
|
(nxml-display-file-parse-error err)))))
|
|
|
|
|
|
|
|
(defun rng-locate-schema-file (&optional type-id)
|
|
|
|
"Return the file-name of the schema to use for the current buffer.
|
|
|
|
Return nil if no schema could be located.
|
|
|
|
If TYPE-ID is non-nil, then locate the schema for this TYPE-ID."
|
|
|
|
(let* ((rng-cached-document-element nil)
|
|
|
|
(schema
|
|
|
|
(if type-id
|
|
|
|
(cons type-id nil)
|
|
|
|
(rng-locate-schema-file-using rng-schema-locating-files)))
|
|
|
|
files type-ids)
|
|
|
|
(while (consp schema)
|
|
|
|
(setq files rng-schema-locating-files)
|
|
|
|
(setq type-id (car schema))
|
|
|
|
(setq schema nil)
|
|
|
|
(when (member type-id type-ids)
|
|
|
|
(error "Type-id loop for type-id `%s'" type-id))
|
|
|
|
(setq type-ids (cons type-id type-ids))
|
|
|
|
(while (and files (not schema))
|
|
|
|
(setq schema
|
|
|
|
(rng-locate-schema-file-from-type-id type-id
|
|
|
|
(car files)))
|
|
|
|
(setq files (cdr files))))
|
|
|
|
(and schema
|
|
|
|
(rng-uri-file-name schema))))
|
|
|
|
|
|
|
|
(defun rng-possible-type-ids ()
|
|
|
|
"Return a list of the known type IDs."
|
|
|
|
(let ((files rng-schema-locating-files)
|
|
|
|
type-ids)
|
|
|
|
(while files
|
|
|
|
(setq type-ids (rng-possible-type-ids-using (car files) type-ids))
|
|
|
|
(setq files (cdr files)))
|
|
|
|
(rng-uniquify-equal (sort type-ids 'string<))))
|
|
|
|
|
|
|
|
(defun rng-locate-schema-file-using (files)
|
|
|
|
"Locate a schema using the schema locating files FILES.
|
|
|
|
FILES is a list of file-names.
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
Return either a URI, a list (TYPE-ID) where TYPE-ID is a string,
|
2007-11-23 06:58:00 +00:00
|
|
|
or nil."
|
|
|
|
(let (rules
|
|
|
|
;; List of types that override normal order-based
|
|
|
|
;; priority, most important first
|
|
|
|
preferred-types
|
|
|
|
;; Best result found so far; same form as return value.
|
|
|
|
best-so-far)
|
|
|
|
(while (and (progn
|
|
|
|
(while (and (not rules) files)
|
|
|
|
(setq rules (rng-get-parsed-schema-locating-file
|
|
|
|
(car files)))
|
|
|
|
(setq files (cdr files)))
|
|
|
|
rules)
|
|
|
|
(or (not best-so-far) preferred-types))
|
|
|
|
(let* ((rule (car rules))
|
|
|
|
(rule-type (car rule))
|
|
|
|
(rule-matcher (get rule-type 'rng-rule-matcher)))
|
|
|
|
(setq rules (cdr rules))
|
|
|
|
(cond (rule-matcher
|
|
|
|
(when (and (or (not best-so-far)
|
|
|
|
(memq rule-type preferred-types)))
|
|
|
|
(setq best-so-far
|
|
|
|
(funcall rule-matcher (cdr rule)))
|
|
|
|
preferred-types)
|
|
|
|
(setq preferred-types
|
|
|
|
(nbutlast preferred-types
|
|
|
|
(length (memq rule-type preferred-types)))))
|
|
|
|
((eq rule-type 'applyFollowingRules)
|
|
|
|
(when (not best-so-far)
|
|
|
|
(let ((prefer (cdr (assq 'ruleType (cdr rule)))))
|
|
|
|
(when (and prefer
|
|
|
|
(not (memq (setq prefer (intern prefer))
|
|
|
|
preferred-types)))
|
|
|
|
(setq preferred-types
|
|
|
|
(nconc preferred-types (list prefer)))))))
|
|
|
|
((eq rule-type 'include)
|
|
|
|
(let ((uri (cdr (assq 'rules (cdr rule)))))
|
|
|
|
(when uri
|
|
|
|
(setq rules
|
|
|
|
(append (rng-get-parsed-schema-locating-file
|
|
|
|
(rng-uri-file-name uri))
|
|
|
|
rules))))))))
|
|
|
|
best-so-far))
|
|
|
|
|
2016-01-15 10:29:20 -05:00
|
|
|
(put 'documentElement 'rng-rule-matcher #'rng-match-document-element-rule)
|
|
|
|
(put 'namespace 'rng-rule-matcher #'rng-match-namespace-rule)
|
|
|
|
(put 'uri 'rng-rule-matcher #'rng-match-uri-rule)
|
|
|
|
(put 'transformURI 'rng-rule-matcher #'rng-match-transform-uri-rule)
|
|
|
|
(put 'default 'rng-rule-matcher #'rng-match-default-rule)
|
2007-11-23 06:58:00 +00:00
|
|
|
|
|
|
|
(defun rng-match-document-element-rule (props)
|
|
|
|
(let ((document-element (rng-document-element))
|
|
|
|
(prefix (cdr (assq 'prefix props)))
|
|
|
|
(local-name (cdr (assq 'localName props))))
|
|
|
|
(and (or (not prefix)
|
|
|
|
(if (= (length prefix) 0)
|
|
|
|
(not (nth 1 document-element))
|
|
|
|
(string= prefix (nth 1 document-element))))
|
|
|
|
(or (not local-name)
|
|
|
|
(string= local-name
|
|
|
|
(nth 2 document-element)))
|
|
|
|
(rng-match-default-rule props))))
|
|
|
|
|
|
|
|
(defun rng-match-namespace-rule (props)
|
|
|
|
(let ((document-element (rng-document-element))
|
|
|
|
(ns (cdr (assq 'ns props))))
|
|
|
|
(and document-element
|
|
|
|
ns
|
|
|
|
(eq (nth 0 document-element)
|
|
|
|
(if (string= ns "")
|
|
|
|
nil
|
|
|
|
(nxml-make-namespace ns)))
|
|
|
|
(rng-match-default-rule props))))
|
|
|
|
|
|
|
|
(defun rng-document-element ()
|
|
|
|
"Return a list (NS PREFIX LOCAL-NAME).
|
|
|
|
NS is t if the document has a non-nil, but not otherwise known namespace."
|
|
|
|
(or rng-cached-document-element
|
|
|
|
(setq rng-cached-document-element
|
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(widen)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let (xmltok-dtd)
|
|
|
|
(xmltok-save
|
|
|
|
(xmltok-forward-prolog)
|
|
|
|
(xmltok-forward)
|
|
|
|
(when (memq xmltok-type '(start-tag
|
|
|
|
partial-start-tag
|
|
|
|
empty-element
|
|
|
|
partial-empty-element))
|
|
|
|
(list (rng-get-start-tag-namespace)
|
|
|
|
(xmltok-start-tag-prefix)
|
|
|
|
(xmltok-start-tag-local-name))))))))))
|
|
|
|
|
|
|
|
(defun rng-get-start-tag-namespace ()
|
|
|
|
(let ((prefix (xmltok-start-tag-prefix))
|
|
|
|
namespace att value)
|
|
|
|
(while xmltok-namespace-attributes
|
|
|
|
(setq att (car xmltok-namespace-attributes))
|
|
|
|
(setq xmltok-namespace-attributes (cdr xmltok-namespace-attributes))
|
|
|
|
(when (if prefix
|
|
|
|
(and (xmltok-attribute-prefix att)
|
|
|
|
(string= (xmltok-attribute-local-name att)
|
|
|
|
prefix))
|
|
|
|
(not (xmltok-attribute-prefix att)))
|
|
|
|
(setq value (xmltok-attribute-value att))
|
|
|
|
(setq namespace (if value (nxml-make-namespace value) t))))
|
|
|
|
(if (and prefix (not namespace))
|
|
|
|
t
|
|
|
|
namespace)))
|
|
|
|
|
|
|
|
(defun rng-match-transform-uri-rule (props)
|
|
|
|
(let ((from-pattern (cdr (assq 'fromPattern props)))
|
|
|
|
(to-pattern (cdr (assq 'toPattern props)))
|
|
|
|
(file-name (buffer-file-name)))
|
|
|
|
(and file-name
|
|
|
|
(setq file-name (expand-file-name file-name))
|
|
|
|
(rng-file-name-matches-uri-pattern-p file-name from-pattern)
|
|
|
|
(condition-case ()
|
|
|
|
(let ((new-file-name
|
|
|
|
(replace-match
|
|
|
|
(save-match-data
|
|
|
|
(rng-uri-pattern-file-name-replace-match to-pattern))
|
|
|
|
t
|
|
|
|
nil
|
|
|
|
file-name)))
|
|
|
|
(and (file-name-absolute-p new-file-name)
|
|
|
|
(file-exists-p new-file-name)
|
|
|
|
(rng-file-name-uri new-file-name)))
|
|
|
|
(rng-uri-error nil)))))
|
|
|
|
|
|
|
|
(defun rng-match-uri-rule (props)
|
|
|
|
(let ((resource (cdr (assq 'resource props)))
|
|
|
|
(pattern (cdr (assq 'pattern props)))
|
|
|
|
(file-name (buffer-file-name)))
|
|
|
|
(and file-name
|
|
|
|
(setq file-name (expand-file-name file-name))
|
|
|
|
(cond (resource
|
|
|
|
(condition-case ()
|
|
|
|
(eq (compare-strings (rng-uri-file-name resource)
|
|
|
|
0
|
|
|
|
nil
|
|
|
|
(expand-file-name file-name)
|
|
|
|
0
|
|
|
|
nil
|
|
|
|
nxml-file-name-ignore-case)
|
|
|
|
t)
|
|
|
|
(rng-uri-error nil)))
|
|
|
|
(pattern
|
|
|
|
(rng-file-name-matches-uri-pattern-p file-name
|
|
|
|
pattern)))
|
|
|
|
(rng-match-default-rule props))))
|
|
|
|
|
|
|
|
(defun rng-file-name-matches-uri-pattern-p (file-name pattern)
|
|
|
|
(condition-case ()
|
|
|
|
(and (let ((case-fold-search nxml-file-name-ignore-case))
|
|
|
|
(string-match (rng-uri-pattern-file-name-regexp pattern)
|
|
|
|
file-name))
|
|
|
|
t)
|
|
|
|
(rng-uri-error nil)))
|
|
|
|
|
|
|
|
(defun rng-match-default-rule (props)
|
|
|
|
(or (cdr (assq 'uri props))
|
|
|
|
(let ((type-id (cdr (assq 'typeId props))))
|
|
|
|
(and type-id
|
|
|
|
(cons (rng-collapse-space type-id) nil)))))
|
|
|
|
|
|
|
|
(defun rng-possible-type-ids-using (file type-ids)
|
|
|
|
(let ((rules (rng-get-parsed-schema-locating-file file))
|
|
|
|
rule)
|
|
|
|
(while rules
|
|
|
|
(setq rule (car rules))
|
|
|
|
(setq rules (cdr rules))
|
|
|
|
(cond ((eq (car rule) 'typeId)
|
|
|
|
(let ((id (cdr (assq 'id (cdr rule)))))
|
|
|
|
(when id
|
|
|
|
(setq type-ids
|
|
|
|
(cons (rng-collapse-space id)
|
|
|
|
type-ids)))))
|
|
|
|
((eq (car rule) 'include)
|
|
|
|
(let ((uri (cdr (assq 'rules (cdr rule)))))
|
|
|
|
(when uri
|
|
|
|
(setq type-ids
|
|
|
|
(rng-possible-type-ids-using
|
|
|
|
(rng-get-parsed-schema-locating-file
|
|
|
|
(rng-uri-file-name uri))
|
|
|
|
type-ids)))))))
|
|
|
|
type-ids))
|
|
|
|
|
|
|
|
(defun rng-locate-schema-file-from-type-id (type-id file)
|
|
|
|
"Locate the schema for type id TYPE-ID using schema locating file FILE.
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
Return either a URI, a list (TYPE-ID) where TYPE-ID is a string,
|
2007-11-23 06:58:00 +00:00
|
|
|
or nil."
|
|
|
|
(let ((rules (rng-get-parsed-schema-locating-file file))
|
|
|
|
schema rule)
|
|
|
|
(while (and rules (not schema))
|
|
|
|
(setq rule (car rules))
|
|
|
|
(setq rules (cdr rules))
|
|
|
|
(cond ((and (eq (car rule) 'typeId)
|
|
|
|
(let ((id (assq 'id (cdr rule))))
|
|
|
|
(and id
|
|
|
|
(string= (rng-collapse-space (cdr id)) type-id))))
|
|
|
|
(setq schema (rng-match-default-rule (cdr rule))))
|
|
|
|
((eq (car rule) 'include)
|
|
|
|
(let ((uri (cdr (assq 'rules (cdr rule)))))
|
|
|
|
(when uri
|
|
|
|
(setq schema
|
|
|
|
(rng-locate-schema-file-from-type-id
|
|
|
|
type-id
|
|
|
|
(rng-uri-file-name uri))))))))
|
|
|
|
schema))
|
|
|
|
|
|
|
|
(defvar rng-schema-locating-file-alist nil)
|
|
|
|
|
|
|
|
(defun rng-get-parsed-schema-locating-file (file)
|
|
|
|
"Return a list of rules for the schema locating file FILE."
|
|
|
|
(setq file (expand-file-name file))
|
|
|
|
(let ((cached (assoc file rng-schema-locating-file-alist))
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(mtime (file-attribute-modification-time (file-attributes file)))
|
2007-11-23 06:58:00 +00:00
|
|
|
parsed)
|
|
|
|
(cond ((not mtime)
|
|
|
|
(when cached
|
|
|
|
(setq rng-schema-locating-file-alist
|
|
|
|
(delq cached rng-schema-locating-file-alist)))
|
|
|
|
nil)
|
|
|
|
((and cached (equal (nth 1 cached) mtime))
|
|
|
|
(nth 2 cached))
|
|
|
|
(t
|
|
|
|
(setq parsed (rng-parse-schema-locating-file file))
|
|
|
|
(if cached
|
|
|
|
(setcdr cached (list mtime parsed))
|
|
|
|
(setq rng-schema-locating-file-alist
|
|
|
|
(cons (list file mtime parsed)
|
|
|
|
rng-schema-locating-file-alist)))
|
|
|
|
parsed))))
|
Fix typos, and general docstring cleanup.
* nxml/nxml-glyph.el (nxml-glyph-set-hook):
* nxml/nxml-uchnm.el (nxml-unicode-blocks)
(nxml-unicode-block-char-name-set):
* nxml/nxml-util.el (nxml-debug, nxml-make-namespace):
* nxml/rng-nxml.el (rng-set-state-after):
* nxml/rng-uri.el (rng-file-name-uri): Fix typo in docstring.
* nxml/rng-cmpct.el (rng-c-lookup-create, rng-c-parse-primary)
(rng-c-parse-annotation-body):
* nxml/rng-dt.el (rng-dt-namespace-context-getter): Reflow docstrings.
* nxml/nxml-mode.el (nxml, nxml-mode, nxml-after-change1)
(nxml-extend-region, nxml-merge-indent-context-type, nxml-complete)
(nxml-forward-balanced-item, nxml-dynamic-markup-word)
(nxml-define-char-name-set, nxml-toggle-char-ref-extra-display):
Fix typos in docstrings.
(nxml-attribute-indent): Reflow docstring.
(nxml-bind-meta-tab-to-complete-flag, nxml-last-fontify-end)
(nxml-default-buffer-file-coding-system): Doc fixes.
* nxml/nxml-ns.el (nxml-ns-state, nxml-ns-initial-state)
(nxml-ns-set-prefix): Fix typos in docstrings.
(nxml-ns-push-state, nxml-ns-pop-state, nxml-ns-set-default):
Reflow docstring.
(nxml-ns-get-prefix, nxml-ns-get-default): Doc fixes.
* nxml/nxml-outln.el (nxml-hide-all-text-content)
(nxml-show-direct-text-content, nxml-show-direct-subheadings)
(nxml-hide-direct-text-content, nxml-hide-subheadings)
(nxml-hide-text-content, nxml-show-subheadings, nxml-hide-other)
(nxml-outline-display-rest, nxml-outline-set-overlay)
(nxml-section-tag-forward, nxml-section-tag-backward)
(nxml-back-to-section-start): Fix typos in docstrings.
* nxml/nxml-parse.el (nxml-validate-function, nxml-parse-file):
Doc fixes.
* nxml/nxml-rap.el (nxml-scan-end, nxml-move-tag-backwards)
(nxml-scan-element-forward, nxml-scan-element-backward): Doc fixes.
(nxml-scan-after-change): Fix typo in docstring.
* nxml/rng-match.el (rng-being-compiled, rng-normalize-choice-list)
(rng-name-class-possible-names): Doc fixes.
(rng-memo-map-add, rng-intern-group, rng-match-possible-namespace-uris)
(rng-match-possible-start-tag-names, rng-match-possible-value-strings):
Fix typos in docstrings.
(rng-intern-group-shortcut, rng-intern-choice-shortcut):
Reflow docstrings.
* nxml/rng-util.el (rng-uniquify-eq, rng-uniquify-equal): Doc fixes.
(rng-substq, rng-complete-before-point): Fix typos in docstrings.
* nxml/rng-xsd.el (rng-xsd-make-date-time-regexp)
(rng-xsd-convert-date-time): Reflow docstrings.
(rng-xsd-compile): Fix typo in docstring.
* nxml/rng-loc.el (rng-current-schema-file-name)
(rng-locate-schema-file-using, rng-locate-schema-file-from-type-id):
Doc fixes.
(rng-set-schema-file): Fix typo in docstring.
* nxml/rng-valid.el (rng-error-count, rng-validate-mode)
(rng-do-some-validation, rng-process-start-tag, rng-process-text):
Fix typos in docstrings.
(rng-message-overlay, rng-conditional-up-to-date-start)
(rng-conditional-up-to-date-end): Doc fixes.
(rng-next-error, rng-previous-error): Reflow docstrings.
* nxml/xmltok.el (xmltok-attribute-raw-normalized-value): Doc fix.
(xmltok-dtd, xmltok-dependent-regions, xmltok-attribute-refs)
(xmltok-valid-char-p, xmltok-standalone, xmltok-forward-prolog)
(xmltok-merge-attributes): Fix typos in docstrings.
(xmltok-make-attribute, xmltok-forward-special)
(xmltok-get-declared-encoding-position): Reflow docstrings.
* nxml/xsd-regexp.el (xsdre-char-class-to-range-list): Doc fix.
(xsdre-range-list-union, xsdre-check-range-list, xsdre-current-regexp):
Fix typos in docstrings.
2008-07-03 12:25:23 +00:00
|
|
|
|
2007-11-23 06:58:00 +00:00
|
|
|
(defconst rng-locate-namespace-uri
|
|
|
|
(nxml-make-namespace "http://thaiopensource.com/ns/locating-rules/1.0"))
|
|
|
|
|
|
|
|
(defun rng-parse-schema-locating-file (file)
|
|
|
|
"Return list of rules.
|
|
|
|
Each rule has the form (TYPE (ATTR . VAL) ...), where
|
|
|
|
TYPE is a symbol for the element name, ATTR is a symbol for the attribute
|
|
|
|
and VAL is a string for the value.
|
|
|
|
Attribute values representing URIs are made absolute and xml:base
|
|
|
|
attributes are removed."
|
|
|
|
(when (and (not rng-schema-locating-file-schema)
|
|
|
|
rng-schema-locating-file-schema-file)
|
|
|
|
(setq rng-schema-locating-file-schema
|
|
|
|
(rng-load-schema rng-schema-locating-file-schema-file)))
|
|
|
|
(let* ((element
|
|
|
|
(if rng-schema-locating-file-schema
|
|
|
|
(rng-parse-validate-file rng-schema-locating-file-schema
|
|
|
|
file)
|
|
|
|
(nxml-parse-file file)))
|
|
|
|
(children (cddr element))
|
|
|
|
(base-uri (rng-file-name-uri file))
|
|
|
|
child name rules atts att props prop-name prop-value)
|
|
|
|
(when (equal (car element)
|
|
|
|
(cons rng-locate-namespace-uri "locatingRules"))
|
|
|
|
(while children
|
|
|
|
(setq child (car children))
|
|
|
|
(setq children (cdr children))
|
|
|
|
(when (consp child)
|
|
|
|
(setq name (car child))
|
|
|
|
(when (eq (car name) rng-locate-namespace-uri)
|
|
|
|
(setq atts (cadr child))
|
|
|
|
(setq props nil)
|
|
|
|
(while atts
|
|
|
|
(setq att (car atts))
|
|
|
|
(when (stringp (car att))
|
|
|
|
(setq prop-name (intern (car att)))
|
|
|
|
(setq prop-value (cdr att))
|
|
|
|
(when (memq prop-name '(uri rules resource))
|
|
|
|
(setq prop-value
|
|
|
|
(rng-uri-resolve prop-value base-uri)))
|
|
|
|
(setq props (cons (cons prop-name prop-value)
|
|
|
|
props)))
|
|
|
|
(setq atts (cdr atts)))
|
|
|
|
(setq rules
|
|
|
|
(cons (cons (intern (cdr name)) (nreverse props))
|
|
|
|
rules))))))
|
|
|
|
(nreverse rules)))
|
|
|
|
|
|
|
|
(defun rng-save-schema-location ()
|
|
|
|
"Save the association between the buffer's file and the current schema.
|
|
|
|
This ensures that the schema that is currently being used will be used
|
|
|
|
if the file is edited in a future session. The association will be
|
|
|
|
saved to the first writable file in `rng-schema-locating-files'."
|
|
|
|
(interactive)
|
|
|
|
(rng-save-schema-location-1 nil))
|
|
|
|
|
|
|
|
(defun rng-save-schema-location-1 (prompt &optional type-id)
|
|
|
|
(unless (or rng-current-schema-file-name type-id)
|
|
|
|
(error "Buffer is using a vacuous schema"))
|
|
|
|
(let ((files rng-schema-locating-files)
|
|
|
|
(document-file-name (buffer-file-name))
|
|
|
|
(schema-file-name rng-current-schema-file-name)
|
|
|
|
file)
|
|
|
|
(while (and files (not file))
|
|
|
|
(if (file-writable-p (car files))
|
|
|
|
(setq file (expand-file-name (car files)))
|
|
|
|
(setq files (cdr files))))
|
|
|
|
(cond ((not file)
|
|
|
|
(if prompt
|
|
|
|
nil
|
|
|
|
(error "No writable schema locating file configured")))
|
|
|
|
((not document-file-name)
|
|
|
|
(if prompt
|
|
|
|
nil
|
|
|
|
(error "Buffer does not have a filename")))
|
|
|
|
((and prompt
|
|
|
|
(not (y-or-n-p (format "Save %s to %s "
|
|
|
|
(if type-id
|
|
|
|
"type identifier"
|
|
|
|
"schema location")
|
|
|
|
file)))))
|
|
|
|
(t
|
2009-11-05 21:01:32 +00:00
|
|
|
(with-current-buffer (find-file-noselect file)
|
2007-11-23 06:58:00 +00:00
|
|
|
(let ((modified (buffer-modified-p)))
|
|
|
|
(if (> (buffer-size) 0)
|
|
|
|
(let (xmltok-dtd)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(xmltok-save
|
|
|
|
(xmltok-forward-prolog)
|
|
|
|
(xmltok-forward)
|
|
|
|
(unless (eq xmltok-type 'start-tag)
|
|
|
|
(error "Locating file `%s' invalid" file))))
|
|
|
|
(insert "<?xml version=\"1.0\"?>\n"
|
|
|
|
"<locatingRules xmlns=\""
|
|
|
|
(nxml-namespace-name rng-locate-namespace-uri)
|
|
|
|
"\">")
|
|
|
|
(let ((pos (point)))
|
|
|
|
(insert "\n</locatingRules>\n")
|
|
|
|
(goto-char pos)))
|
|
|
|
(insert "\n")
|
|
|
|
(insert (let ((locating-file-uri (rng-file-name-uri file)))
|
|
|
|
(format "<uri resource=\"%s\" %s=\"%s\"/>"
|
|
|
|
(rng-escape-string
|
|
|
|
(rng-relative-uri
|
|
|
|
(rng-file-name-uri document-file-name)
|
|
|
|
locating-file-uri))
|
|
|
|
(if type-id "typeId" "uri")
|
|
|
|
(rng-escape-string
|
|
|
|
(or type-id
|
|
|
|
(rng-relative-uri
|
|
|
|
(rng-file-name-uri schema-file-name)
|
|
|
|
locating-file-uri))))))
|
|
|
|
(indent-according-to-mode)
|
|
|
|
(when (or (not modified)
|
|
|
|
(y-or-n-p (format "Save file %s "
|
|
|
|
(buffer-file-name))))
|
|
|
|
(save-buffer))))))))
|
|
|
|
|
|
|
|
(provide 'rng-loc)
|
|
|
|
|
|
|
|
;;; rng-loc.el ends here
|