diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-05-15 14:31:51 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-05-15 14:31:51 -0400 |
commit | c99904740ebcfde5533c29798618b968d56c0bf4 (patch) | |
tree | a9f40e16ec3f07f31dace8af562a0ea3cf6d3bae /lisp/nxml/nxml-rap.el | |
parent | e3772e9833f971a450562350dc233bf00be7c5eb (diff) | |
download | emacs-c99904740ebcfde5533c29798618b968d56c0bf4.tar.gz |
* lisp/nxml/nxml-mode.el: Treat unclosed <[[, <?, comment, and other
literals as extending to EOB.
(nxml-last-fontify-end): Remove unused variable.
(nxml-after-change1): Use with-silent-modifications.
(nxml-extend-after-change-region): Simplify.
(nxml-extend-after-change-region1): Remove function.
(nxml-after-change1): Don't adjust for dependent regions.
(nxml-fontify-matcher): Simplify.
* lisp/nxml/xmltok.el (xmltok-dependent-regions): Remove variable.
(xmltok-add-dependent): Remove function.
(xmltok-scan-after-lt, xmltok-scan-after-processing-instruction-open)
(xmltok-scan-after-comment-open, xmltok-scan-prolog-literal)
(xmltok-scan-prolog-after-processing-instruction-open): Treat
unclosed <[[, <?, comment, and other literals as extending to EOB.
* lisp/nxml/rng-valid.el (rng-mark-xmltok-dependent-regions)
(rng-mark-xmltok-dependent-region, rng-dependent-region-changed):
Remove functions.
(rng-do-some-validation-1): Don't mark dependent regions.
* lisp/nxml/nxml-rap.el (nxml-adjust-start-for-dependent-regions)
(nxml-mark-parse-dependent-regions, nxml-mark-parse-dependent-region)
(nxml-clear-dependent-regions): Remove functions.
(nxml-scan-after-change, nxml-scan-prolog, nxml-tokenize-forward)
(nxml-ensure-scan-up-to-date):
Don't clear&mark dependent regions.
Diffstat (limited to 'lisp/nxml/nxml-rap.el')
-rw-r--r-- | lisp/nxml/nxml-rap.el | 86 |
1 files changed, 8 insertions, 78 deletions
diff --git a/lisp/nxml/nxml-rap.el b/lisp/nxml/nxml-rap.el index 5bc4d74456b..ac4e9ac4cd9 100644 --- a/lisp/nxml/nxml-rap.el +++ b/lisp/nxml/nxml-rap.el @@ -69,18 +69,6 @@ ;; typical proportion of comments, CDATA sections and processing ;; instructions is small relative to other things. Secondly, to scan ;; we just search for the regexp <[!?]. -;; -;; One problem is unclosed comments, processing instructions and CDATA -;; sections. Suppose, for example, we encounter a <!-- but there's no -;; matching -->. This is not an unexpected situation if the user is -;; creating a comment. It is not helpful to treat the whole of the -;; file starting from the <!-- onwards as a single unclosed comment -;; token. Instead we treat just the <!-- as a piece of not well-formed -;; markup and continue. The problem is that if at some later stage a -;; --> gets added to the buffer after the unclosed <!--, we will need -;; to reparse the buffer starting from the <!--. We need to keep -;; track of these reparse dependencies; they are called dependent -;; regions in the code. ;;; Code: @@ -144,8 +132,7 @@ any 'inside' regions and at the beginning of a token." (if (>= start nxml-scan-end) nxml-scan-end (let ((inside-remove-start start) - xmltok-errors - xmltok-dependent-regions) + xmltok-errors) (while (or (when (xmltok-forward-special (min end nxml-scan-end)) (when (memq xmltok-type '(comment @@ -169,9 +156,7 @@ any 'inside' regions and at the beginning of a token." (when inside-end (setq end inside-end) t)))) - (nxml-clear-inside inside-remove-start end) - (nxml-clear-dependent-regions start end) - (nxml-mark-parse-dependent-regions)) + (nxml-clear-inside inside-remove-start end)) (when (> end nxml-scan-end) (set-marker nxml-scan-end end)) end)) @@ -182,63 +167,14 @@ any 'inside' regions and at the beginning of a token." (defun nxml-scan-prolog () (goto-char (point-min)) (let (xmltok-dtd - xmltok-errors - xmltok-dependent-regions) + xmltok-errors) (setq nxml-prolog-regions (xmltok-forward-prolog)) (setq nxml-prolog-end (point)) - (nxml-clear-inside (point-min) nxml-prolog-end) - (nxml-clear-dependent-regions (point-min) nxml-prolog-end) - (nxml-mark-parse-dependent-regions)) + (nxml-clear-inside (point-min) nxml-prolog-end)) (when (< nxml-scan-end nxml-prolog-end) (set-marker nxml-scan-end nxml-prolog-end))) -;;; Dependent regions - -(defun nxml-adjust-start-for-dependent-regions (start end pre-change-length) - (let ((overlays (overlays-in (1- start) start)) - (adjusted-start start)) - (while overlays - (let* ((overlay (car overlays)) - (ostart (overlay-start overlay))) - (when (and (eq (overlay-get overlay 'category) 'nxml-dependent) - (< ostart adjusted-start)) - (let ((funargs (overlay-get overlay 'nxml-funargs))) - (when (apply (car funargs) - (append (list start - end - pre-change-length - ostart - (overlay-end overlay)) - (cdr funargs))) - (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 - (car xmltok-dependent-regions)) - (setq xmltok-dependent-regions - (cdr xmltok-dependent-regions)))) - -(defun nxml-mark-parse-dependent-region (fun start end &rest args) - (let ((overlay (make-overlay start end nil t t))) - (overlay-put overlay 'category 'nxml-dependent) - (overlay-put overlay 'nxml-funargs (cons fun args)))) - -(put 'nxml-dependent 'evaporate t) - -(defun nxml-clear-dependent-regions (start end) - (let ((overlays (overlays-in start end))) - (while overlays - (let* ((overlay (car overlays)) - (category (overlay-get overlay 'category))) - (when (and (eq category 'nxml-dependent) - (<= start (overlay-start overlay))) - (delete-overlay overlay))) - (setq overlays (cdr overlays))))) - ;;; Random access parsing (defun nxml-token-after () @@ -286,17 +222,14 @@ Sets variables like `nxml-token-after'." (point))) (defun nxml-tokenize-forward () - (let (xmltok-dependent-regions - xmltok-errors) + (let (xmltok-errors) (when (and (xmltok-forward) (> (point) nxml-scan-end)) (cond ((memq xmltok-type '(comment cdata-section processing-instruction)) (with-silent-modifications - (nxml-set-inside (1+ xmltok-start) (point) xmltok-type))) - (xmltok-dependent-regions - (nxml-mark-parse-dependent-regions))) + (nxml-set-inside (1+ xmltok-start) (point) xmltok-type)))) (set-marker nxml-scan-end (point))) xmltok-type)) @@ -304,7 +237,7 @@ Sets variables like `nxml-token-after'." "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. +outside any 'inside' regions. As a precondition, point must be >= BOUND." (nxml-move-outside-backwards) (when (not (equal (char-after) ?<)) @@ -331,8 +264,7 @@ Leave point unmoved if it is not inside anything special." (when (< nxml-scan-end pos) (save-excursion (goto-char nxml-scan-end) - (let (xmltok-errors - xmltok-dependent-regions) + (let (xmltok-errors) (while (when (xmltok-forward-special pos) (when (memq xmltok-type '(comment @@ -346,8 +278,6 @@ Leave point unmoved if it is not inside anything special." t (setq pos (point)) nil))) - (nxml-clear-dependent-regions nxml-scan-end pos) - (nxml-mark-parse-dependent-regions) (set-marker nxml-scan-end pos)))))) ;;; Element scanning |