;;; nxml-rap.el --- low-level support for random access parsing for nXML mode
-;; Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2007-2011 Free Software Foundation, Inc.
;; Author: James Clark
;; Keywords: XML
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defvar nxml-scan-end nil
"Marker giving position up to which we have scanned.
nxml-scan-end must be >= nxml-prolog-end. Furthermore, nxml-scan-end
-must not an inside position in the following sense. A position is
+must not be an inside position in the following sense. A position is
inside if the following character is a part of, but not the first
character of, a CDATA section, comment or processing instruction.
Furthermore all positions >= nxml-prolog-end and < nxml-scan-end that
-are inside positions must have a non-nil nxml-inside property whose
-value is a symbol specifying what it is inside. Any characters with a
-non-nil fontified property must have position < nxml-scan-end and the
-correct face. Dependent regions must also be established for any
+are inside positions must have a non-nil `nxml-inside' property whose
+value is a symbol specifying what it is inside. Any characters with a
+non-nil `fontified' property must have position < nxml-scan-end and
+the correct face. Dependent regions must also be established for any
unclosed constructs starting before nxml-scan-end.
-There must be no nxml-inside properties after nxml-scan-end.")
+There must be no `nxml-inside' properties after nxml-scan-end.")
(make-variable-buffer-local 'nxml-scan-end)
(defsubst nxml-get-inside (pos)
(get-text-property pos 'nxml-inside))
(defsubst nxml-clear-inside (start end)
+ (nxml-debug-clear-inside start end)
(remove-text-properties start end '(nxml-inside nil)))
(defsubst nxml-set-inside (start end type)
+ (nxml-debug-set-inside start end)
(put-text-property start end 'nxml-inside type))
(defun nxml-inside-end (pos)
"Restore `nxml-scan-end' invariants after a change.
The change happened between START and END.
Return position after which lexical state is unchanged.
-END must be > nxml-prolog-end."
+END must be > `nxml-prolog-end'. START must be outside
+any 'inside' regions and at the beginning of a token."
(if (>= start nxml-scan-end)
nxml-scan-end
- (goto-char start)
- (nxml-move-outside-backwards)
- (setq start (point))
(let ((inside-remove-start start)
xmltok-errors
xmltok-dependent-regions)
(setq adjusted-start ostart)))))
(setq overlays (cdr overlays)))
adjusted-start))
-
+
(defun nxml-mark-parse-dependent-regions ()
(while xmltok-dependent-regions
(apply 'nxml-mark-parse-dependent-region
(set-marker nxml-scan-end (point)))
xmltok-type))
+(defun nxml-move-tag-backwards (bound)
+ "Move point backwards outside any 'inside' regions or tags.
+Point will not move past `nxml-prolog-end'.
+Point will either be at BOUND or a '<' character starting a tag
+outside any 'inside' regions. Ignores dependent regions.
+As a precondition, point must be >= BOUND."
+ (nxml-move-outside-backwards)
+ (when (not (equal (char-after) ?<))
+ (if (search-backward "<" bound t)
+ (progn
+ (nxml-move-outside-backwards)
+ (when (not (equal (char-after) ?<))
+ (search-backward "<" bound t)))
+ (goto-char bound))))
+
(defun nxml-move-outside-backwards ()
"Move point to first character of the containing special thing.
Leave point unmoved if it is not inside anything special."
(defun nxml-scan-element-forward (from &optional up)
"Scan forward from FROM over a single balanced element.
-Point must between tokens. Return the position of the end of the tag
-that ends the element. `xmltok-start' will contain the position of the
-start of the tag. If UP is non-nil, then scan past end-tag of element
-containing point. If no element is found, return nil. If a
-well-formedness error prevents scanning, signal an nxml-scan-error.
-Point is not moved."
+Point must be between tokens. Return the position of the end of
+the tag that ends the element. `xmltok-start' will contain the
+position of the start of the tag. If UP is non-nil, then scan
+past end-tag of element containing point. If no element is
+found, return nil. If a well-formedness error prevents scanning,
+signal an `nxml-scan-error'. Point is not moved."
(let ((open-tags (and up t))
found)
(save-excursion
(defun nxml-scan-element-backward (from &optional up bound)
"Scan backward from FROM over a single balanced element.
-Point must between tokens. Return the position of the end of the tag
-that starts the element. `xmltok-start' will contain the position of
-the start of the tag. If UP is non-nil, then scan past start-tag of
-element containing point. If BOUND is non-nil, then don't scan back
-past BOUND. If no element is found, return nil. If a well-formedness
-error prevents scanning, signal an nxml-scan-error. Point is not
-moved."
+Point must be between tokens. Return the position of the end of
+the tag that starts the element. `xmltok-start' will contain the
+position of the start of the tag. If UP is non-nil, then scan
+past start-tag of element containing point. If BOUND is non-nil,
+then don't scan back past BOUND. If no element is found, return
+nil. If a well-formedness error prevents scanning, signal an
+`nxml-scan-error'. Point is not moved."
(let ((open-tags (and up t))
token-end found)
(save-excursion
(provide 'nxml-rap)
-;; arch-tag: cba241ec-4c59-4ef3-aa51-2cf92b3dd24f
;;; nxml-rap.el ends here