* 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.
This commit is contained in:
parent
e3772e9833
commit
c99904740e
5 changed files with 154 additions and 364 deletions
|
@ -1,7 +1,34 @@
|
|||
2013-05-15 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.
|
||||
|
||||
2013-05-15 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* progmodes/octave.el (octave-goto-function-definition): Improve
|
||||
and fix callers.
|
||||
* progmodes/octave.el (octave-goto-function-definition):
|
||||
Improve and fix callers.
|
||||
|
||||
2013-05-15 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
|
@ -277,7 +304,8 @@
|
|||
their declaration.
|
||||
(vhdl-mode-syntax-table-init): Remove.
|
||||
|
||||
* progmodes/m4-mode.el (m4-mode-syntax-table): Add comment on last change.
|
||||
* progmodes/m4-mode.el (m4-mode-syntax-table): Add comment on
|
||||
last change.
|
||||
|
||||
* progmodes/ld-script.el (ld-script-mode-syntax-table): Use symbol
|
||||
syntax for "_".
|
||||
|
@ -292,7 +320,8 @@
|
|||
Handle a _ with symbol syntax.
|
||||
(autoconf-mode): Don't change the syntax-table for imenu and font-lock.
|
||||
|
||||
* progmodes/ada-mode.el (ada-mode-abbrev-table): Consolidate declaration.
|
||||
* progmodes/ada-mode.el (ada-mode-abbrev-table):
|
||||
Consolidate declaration.
|
||||
(ada-mode-syntax-table, ada-mode-symbol-syntax-table): Initialize in
|
||||
the declaration.
|
||||
(ada-create-syntax-table): Remove.
|
||||
|
|
|
@ -352,11 +352,6 @@ Use `nxml-parent-document-set' to set it.")
|
|||
See the function `xmltok-forward-prolog' for more information.")
|
||||
(make-variable-buffer-local 'nxml-prolog-regions)
|
||||
|
||||
(defvar nxml-last-fontify-end nil
|
||||
"Position where fontification last ended.
|
||||
It is nil if the buffer changed since the last fontification.")
|
||||
(make-variable-buffer-local 'nxml-last-fontify-end)
|
||||
|
||||
(defvar nxml-degraded nil
|
||||
"Non-nil if currently operating in degraded mode.
|
||||
Degraded mode is enabled when an internal error is encountered in the
|
||||
|
@ -538,7 +533,6 @@ Many aspects this mode can be customized using
|
|||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(nxml-clear-dependent-regions (point-min) (point-max))
|
||||
(setq nxml-scan-end (copy-marker (point-min) nil))
|
||||
(with-silent-modifications
|
||||
(nxml-clear-inside (point-min) (point-max))
|
||||
|
@ -583,12 +577,9 @@ Many aspects this mode can be customized using
|
|||
;; Clean up fontification.
|
||||
(save-excursion
|
||||
(widen)
|
||||
(let ((inhibit-read-only t)
|
||||
(buffer-undo-list t)
|
||||
(modified (buffer-modified-p)))
|
||||
(with-silent-modifications
|
||||
(nxml-with-invisible-motion
|
||||
(remove-text-properties (point-min) (point-max) '(face)))
|
||||
(set-buffer-modified-p modified)))
|
||||
(remove-text-properties (point-min) (point-max) '(face)))))
|
||||
(remove-hook 'change-major-mode-hook 'nxml-cleanup t))
|
||||
|
||||
(defun nxml-degrade (context err)
|
||||
|
@ -638,10 +629,6 @@ the full extent of the area needing refontification.
|
|||
For bookkeeping, call this function even when fontification is
|
||||
disabled."
|
||||
(let ((pre-change-end (+ start pre-change-length)))
|
||||
(setq start
|
||||
(nxml-adjust-start-for-dependent-regions start
|
||||
end
|
||||
pre-change-length))
|
||||
;; If the prolog might have changed, rescan the prolog
|
||||
(when (<= start
|
||||
;; Add 2 so as to include the < and following char that
|
||||
|
@ -902,26 +889,16 @@ Called with `font-lock-beg' and `font-lock-end' dynamically bound."
|
|||
|
||||
(defun nxml-extend-after-change-region (start end pre-change-length)
|
||||
(unless nxml-degraded
|
||||
(setq nxml-last-fontify-end nil)
|
||||
(let ((region (nxml-with-degradation-on-error
|
||||
'nxml-extend-after-change-region
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(save-match-data
|
||||
(nxml-with-invisible-motion
|
||||
(with-silent-modifications
|
||||
(nxml-extend-after-change-region1
|
||||
start end pre-change-length)))))))))
|
||||
(if (consp region) region))))
|
||||
|
||||
(defun nxml-extend-after-change-region1 (start end pre-change-length)
|
||||
(let* ((region (nxml-after-change1 start end pre-change-length))
|
||||
(font-lock-beg (car region))
|
||||
(font-lock-end (cdr region)))
|
||||
|
||||
(nxml-extend-region)
|
||||
(cons font-lock-beg font-lock-end)))
|
||||
(nxml-with-degradation-on-error
|
||||
'nxml-extend-after-change-region
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(save-match-data
|
||||
(nxml-with-invisible-motion
|
||||
(with-silent-modifications
|
||||
(nxml-after-change1
|
||||
start end pre-change-length)))))))))
|
||||
|
||||
(defun nxml-fontify-matcher (bound)
|
||||
"Called as font-lock keyword matcher."
|
||||
|
@ -936,13 +913,12 @@ Called with `font-lock-beg' and `font-lock-end' dynamically bound."
|
|||
(nxml-fontify-prolog)
|
||||
(goto-char nxml-prolog-end))
|
||||
|
||||
(let (xmltok-dependent-regions
|
||||
xmltok-errors)
|
||||
(let (xmltok-errors)
|
||||
(while (and (nxml-tokenize-forward)
|
||||
(<= (point) bound)) ; Intervals are open-ended.
|
||||
(nxml-apply-fontify-rule)))
|
||||
|
||||
(setq nxml-last-fontify-end (point)))
|
||||
)
|
||||
|
||||
;; Since we did the fontification internally, tell font-lock to not
|
||||
;; do anything itself.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -530,7 +530,6 @@ Return t if there is work to do, nil otherwise."
|
|||
xmltok-replacement
|
||||
xmltok-attributes
|
||||
xmltok-namespace-attributes
|
||||
xmltok-dependent-regions
|
||||
xmltok-errors)
|
||||
(when (= (point) 1)
|
||||
(let ((regions (xmltok-forward-prolog)))
|
||||
|
@ -566,7 +565,6 @@ Return t if there is work to do, nil otherwise."
|
|||
;; do this before setting rng-validate-up-to-date-end
|
||||
;; in case we get a quit
|
||||
(rng-mark-xmltok-errors)
|
||||
(rng-mark-xmltok-dependent-regions)
|
||||
(setq rng-validate-up-to-date-end
|
||||
(marker-position rng-conditional-up-to-date-end))
|
||||
(rng-clear-conditional-region)
|
||||
|
@ -591,7 +589,6 @@ Return t if there is work to do, nil otherwise."
|
|||
(when (not have-remaining-chars)
|
||||
(rng-process-end-document))
|
||||
(rng-mark-xmltok-errors)
|
||||
(rng-mark-xmltok-dependent-regions)
|
||||
(setq rng-validate-up-to-date-end pos)
|
||||
(when rng-conditional-up-to-date-end
|
||||
(cond ((<= rng-conditional-up-to-date-end pos)
|
||||
|
@ -661,57 +658,9 @@ Return t if there is work to do, nil otherwise."
|
|||
;; if overlays left over from a previous use
|
||||
;; of rng-validate-mode that ended with a change of mode
|
||||
(when rng-error-count
|
||||
(setq rng-error-count (1- rng-error-count)))))
|
||||
((and (eq category 'rng-dependent)
|
||||
(<= beg (overlay-start overlay)))
|
||||
(delete-overlay overlay))))
|
||||
(setq rng-error-count (1- rng-error-count)))))))
|
||||
(setq overlays (cdr overlays))))))
|
||||
|
||||
;;; Dependent regions
|
||||
|
||||
(defun rng-mark-xmltok-dependent-regions ()
|
||||
(while xmltok-dependent-regions
|
||||
(apply 'rng-mark-xmltok-dependent-region
|
||||
(car xmltok-dependent-regions))
|
||||
(setq xmltok-dependent-regions
|
||||
(cdr xmltok-dependent-regions))))
|
||||
|
||||
(defun rng-mark-xmltok-dependent-region (fun start end &rest args)
|
||||
(let ((overlay (make-overlay start end nil t t)))
|
||||
(overlay-put overlay 'category 'rng-dependent)
|
||||
(overlay-put overlay 'rng-funargs (cons fun args))))
|
||||
|
||||
(put 'rng-dependent 'evaporate t)
|
||||
(put 'rng-dependent 'modification-hooks '(rng-dependent-region-changed))
|
||||
(put 'rng-dependent 'insert-behind-hooks '(rng-dependent-region-changed))
|
||||
|
||||
(defun rng-dependent-region-changed (overlay
|
||||
after-p
|
||||
change-start
|
||||
change-end
|
||||
&optional pre-change-length)
|
||||
(when (and after-p
|
||||
;; Emacs sometimes appears to call deleted overlays
|
||||
(overlay-start overlay)
|
||||
(let ((funargs (overlay-get overlay 'rng-funargs)))
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(apply (car funargs)
|
||||
(append (list change-start
|
||||
change-end
|
||||
pre-change-length
|
||||
(overlay-start overlay)
|
||||
(overlay-end overlay))
|
||||
(cdr funargs))))))))
|
||||
(rng-after-change-function (overlay-start overlay)
|
||||
change-end
|
||||
(+ pre-change-length
|
||||
(- (overlay-start overlay)
|
||||
change-start)))
|
||||
(delete-overlay overlay)))
|
||||
|
||||
;;; Error state
|
||||
|
||||
(defun rng-mark-xmltok-errors ()
|
||||
|
|
|
@ -132,33 +132,6 @@ from referencing the entity in element content and AR is either nil,
|
|||
meaning the replacement text included a <, or a string which is the
|
||||
normalized attribute value.")
|
||||
|
||||
(defvar xmltok-dependent-regions nil
|
||||
"List of descriptors of regions that a parsed token depends on.
|
||||
|
||||
A token depends on a region if the region occurs after the token and a
|
||||
change in the region may require the token to be reparsed. This only
|
||||
happens with markup that is not well-formed. For example, if a <?
|
||||
occurs without a matching ?>, then the <? is returned as a
|
||||
not-well-formed token. However, this token is dependent on region
|
||||
from the end of the token to the end of the buffer: if this ever
|
||||
contains ?> then the buffer must be reparsed from the <?.
|
||||
|
||||
A region descriptor is a list (FUN START END ARG ...), where FUN is a
|
||||
function to be called when the region changes, START and END are
|
||||
integers giving the start and end of the region, and ARG... are
|
||||
additional arguments to be passed to FUN. FUN will be called with 5
|
||||
arguments followed by the additional arguments if any: the position of
|
||||
the start of the changed area in the region, the position of the end
|
||||
of the changed area in the region, the length of the changed area
|
||||
before the change, the position of the start of the region, the
|
||||
position of the end of the region. FUN must return non-nil if the
|
||||
region needs reparsing. FUN will be called in a `save-excursion'
|
||||
with match-data saved.
|
||||
|
||||
`xmltok-forward', `xmltok-forward-special' and `xmltok-forward-prolog'
|
||||
may add entries to the beginning of this list, but will not clear it.
|
||||
`xmltok-forward' and `xmltok-forward-special' will only add entries
|
||||
when returning tokens of type not-well-formed.")
|
||||
|
||||
(defvar xmltok-errors nil
|
||||
"List of errors detected by `xmltok-forward' and `xmltok-forward-prolog'.
|
||||
|
@ -176,7 +149,6 @@ indicating the position of the error.")
|
|||
xmltok-replacement
|
||||
xmltok-attributes
|
||||
xmltok-namespace-attributes
|
||||
xmltok-dependent-regions
|
||||
xmltok-errors)
|
||||
,@body))
|
||||
|
||||
|
@ -298,14 +270,6 @@ and VALUE-END, otherwise a STRING giving the value."
|
|||
(or end (point)))
|
||||
xmltok-errors)))
|
||||
|
||||
(defun xmltok-add-dependent (fun &optional start end &rest args)
|
||||
(setq xmltok-dependent-regions
|
||||
(cons (cons fun
|
||||
(cons (or start xmltok-start)
|
||||
(cons (or end (point-max))
|
||||
args)))
|
||||
xmltok-dependent-regions)))
|
||||
|
||||
(defun xmltok-forward ()
|
||||
(setq xmltok-start (point))
|
||||
(let* ((case-fold-search nil)
|
||||
|
@ -684,14 +648,8 @@ Return the type of the token."
|
|||
(setq xmltok-type 'empty-element))
|
||||
((xmltok-after-lt start cdata-section-open)
|
||||
(setq xmltok-type
|
||||
(if (search-forward "]]>" nil t)
|
||||
'cdata-section
|
||||
(xmltok-add-error "No closing ]]>")
|
||||
(xmltok-add-dependent 'xmltok-unclosed-reparse-p
|
||||
nil
|
||||
nil
|
||||
"]]>")
|
||||
'not-well-formed)))
|
||||
(progn (search-forward "]]>" nil 'move)
|
||||
'cdata-section)))
|
||||
((xmltok-after-lt start processing-instruction-question)
|
||||
(xmltok-scan-after-processing-instruction-open))
|
||||
((xmltok-after-lt start comment-open)
|
||||
|
@ -758,68 +716,44 @@ Return the type of the token."
|
|||
;; xmltok-scan-prolog-after-processing-instruction-open
|
||||
;; XXX maybe should include rest of line (up to any <,>) in unclosed PI
|
||||
(defun xmltok-scan-after-processing-instruction-open ()
|
||||
(cond ((not (search-forward "?>" nil t))
|
||||
(xmltok-add-error "No closing ?>"
|
||||
xmltok-start
|
||||
(+ xmltok-start 2))
|
||||
(xmltok-add-dependent 'xmltok-unclosed-reparse-p
|
||||
nil
|
||||
nil
|
||||
"?>")
|
||||
(setq xmltok-type 'not-well-formed))
|
||||
(t
|
||||
(cond ((not (save-excursion
|
||||
(goto-char (+ 2 xmltok-start))
|
||||
(and (looking-at (xmltok-ncname regexp))
|
||||
(setq xmltok-name-end (match-end 0)))))
|
||||
(setq xmltok-name-end (+ xmltok-start 2))
|
||||
(xmltok-add-error "<? not followed by name"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 3)))
|
||||
((not (or (memq (char-after xmltok-name-end)
|
||||
'(?\n ?\t ?\r ? ))
|
||||
(= xmltok-name-end (- (point) 2))))
|
||||
(xmltok-add-error "Target not followed by whitespace"
|
||||
xmltok-name-end
|
||||
(1+ xmltok-name-end)))
|
||||
((and (= xmltok-name-end (+ xmltok-start 5))
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start 2))
|
||||
(let ((case-fold-search t))
|
||||
(looking-at "xml"))))
|
||||
(xmltok-add-error "Processing instruction target is xml"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 5))))
|
||||
(setq xmltok-type 'processing-instruction))))
|
||||
(search-forward "?>" nil 'move)
|
||||
(cond ((not (save-excursion
|
||||
(goto-char (+ 2 xmltok-start))
|
||||
(and (looking-at (xmltok-ncname regexp))
|
||||
(setq xmltok-name-end (match-end 0)))))
|
||||
(setq xmltok-name-end (+ xmltok-start 2))
|
||||
(xmltok-add-error "<? not followed by name"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 3)))
|
||||
((not (or (memq (char-after xmltok-name-end)
|
||||
'(?\n ?\t ?\r ? ))
|
||||
(= xmltok-name-end (- (point) 2))))
|
||||
(xmltok-add-error "Target not followed by whitespace"
|
||||
xmltok-name-end
|
||||
(1+ xmltok-name-end)))
|
||||
((and (= xmltok-name-end (+ xmltok-start 5))
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start 2))
|
||||
(let ((case-fold-search t))
|
||||
(looking-at "xml"))))
|
||||
(xmltok-add-error "Processing instruction target is xml"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 5))))
|
||||
(setq xmltok-type 'processing-instruction))
|
||||
|
||||
(defun xmltok-scan-after-comment-open ()
|
||||
(setq xmltok-type
|
||||
(cond ((not (search-forward "--" nil t))
|
||||
(xmltok-add-error "No closing -->")
|
||||
(xmltok-add-dependent 'xmltok-unclosed-reparse-p
|
||||
nil
|
||||
nil
|
||||
;; not --> because
|
||||
;; -- is not allowed
|
||||
;; in comments in XML
|
||||
"--")
|
||||
'not-well-formed)
|
||||
((eq (char-after) ?>)
|
||||
(goto-char (1+ (point)))
|
||||
'comment)
|
||||
(t
|
||||
(xmltok-add-dependent
|
||||
'xmltok-semi-closed-reparse-p
|
||||
nil
|
||||
(point)
|
||||
"--"
|
||||
2)
|
||||
;; just include the <!-- in the token
|
||||
(goto-char (+ xmltok-start 4))
|
||||
;; Need do this after the goto-char because
|
||||
;; marked error should just apply to <!--
|
||||
(xmltok-add-error "First following `--' not followed by `>'")
|
||||
'not-well-formed))))
|
||||
(let ((found-- (search-forward "--" nil 'move)))
|
||||
(setq xmltok-type
|
||||
(cond ((or (eq (char-after) ?>) (not found--))
|
||||
(goto-char (1+ (point)))
|
||||
'comment)
|
||||
(t
|
||||
;; just include the <!-- in the token
|
||||
(goto-char (+ xmltok-start 4))
|
||||
;; Need do this after the goto-char because
|
||||
;; marked error should just apply to <!--
|
||||
(xmltok-add-error "First following `--' not followed by `>'")
|
||||
'not-well-formed)))))
|
||||
|
||||
(defun xmltok-scan-attributes ()
|
||||
(let ((recovering nil)
|
||||
|
@ -1124,7 +1058,7 @@ comment, processing-instruction-left, processing-instruction-right,
|
|||
markup-declaration-open, markup-declaration-close,
|
||||
internal-subset-open, internal-subset-close, hash-name, keyword,
|
||||
literal, encoding-name.
|
||||
Adds to `xmltok-errors' and `xmltok-dependent-regions' as appropriate."
|
||||
Adds to `xmltok-errors' as appropriate."
|
||||
(let ((case-fold-search nil)
|
||||
xmltok-start
|
||||
xmltok-type
|
||||
|
@ -1148,7 +1082,6 @@ Adds to `xmltok-errors' and `xmltok-dependent-regions' as appropriate."
|
|||
(1- xmltok-internal-subset-start)
|
||||
xmltok-internal-subset-start))
|
||||
(xmltok-parse-entities)
|
||||
;; XXX prune dependent-regions for those entirely in prolog
|
||||
(nreverse xmltok-prolog-regions)))
|
||||
|
||||
(defconst xmltok-bad-xml-decl-regexp
|
||||
|
@ -1648,95 +1581,68 @@ If LIMIT is non-nil, then do not consider characters beyond LIMIT."
|
|||
(end (save-excursion
|
||||
(goto-char safe-end)
|
||||
(search-forward delim nil t))))
|
||||
(or (cond ((not end)
|
||||
(xmltok-add-dependent 'xmltok-unclosed-reparse-p
|
||||
nil
|
||||
nil
|
||||
delim)
|
||||
nil)
|
||||
((save-excursion
|
||||
(goto-char end)
|
||||
(looking-at "[ \t\r\n>%[]"))
|
||||
(goto-char end)
|
||||
(setq xmltok-type 'literal))
|
||||
((eq (1+ safe-end) end)
|
||||
(goto-char end)
|
||||
(xmltok-add-error (format "Missing space after %s" delim)
|
||||
safe-end)
|
||||
(setq xmltok-type 'literal))
|
||||
(t
|
||||
(xmltok-add-dependent 'xmltok-semi-closed-reparse-p
|
||||
xmltok-start
|
||||
(1+ end)
|
||||
delim
|
||||
1)
|
||||
nil))
|
||||
(progn
|
||||
(xmltok-add-error (format "Missing closing %s" delim))
|
||||
(goto-char safe-end)
|
||||
(skip-chars-backward " \t\r\n")
|
||||
(setq xmltok-type 'not-well-formed)))))
|
||||
(cond ((or (not end)
|
||||
(save-excursion
|
||||
(goto-char end)
|
||||
(looking-at "[ \t\r\n>%[]")))
|
||||
(goto-char end))
|
||||
((eq (1+ safe-end) end)
|
||||
(goto-char end)
|
||||
(xmltok-add-error (format "Missing space after %s" delim)
|
||||
safe-end)))
|
||||
(setq xmltok-type 'literal)))
|
||||
|
||||
(defun xmltok-scan-prolog-after-processing-instruction-open ()
|
||||
(cond ((not (search-forward "?>" nil t))
|
||||
(xmltok-add-error "No closing ?>"
|
||||
xmltok-start
|
||||
(+ xmltok-start 2))
|
||||
(xmltok-add-dependent 'xmltok-unclosed-reparse-p
|
||||
nil
|
||||
nil
|
||||
"?>")
|
||||
(setq xmltok-type 'not-well-formed))
|
||||
(t
|
||||
(let* ((end (point))
|
||||
(target
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start 2))
|
||||
(and (looking-at (xmltok-ncname regexp))
|
||||
(or (memq (char-after (match-end 0))
|
||||
'(?\n ?\t ?\r ? ))
|
||||
(= (match-end 0) (- end 2)))
|
||||
(match-string-no-properties 0)))))
|
||||
(cond ((not target)
|
||||
(xmltok-add-error "\
|
||||
(search-forward "?>" nil 'move)
|
||||
(let* ((end (point))
|
||||
(target
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start 2))
|
||||
(and (looking-at (xmltok-ncname regexp))
|
||||
(or (memq (char-after (match-end 0))
|
||||
'(?\n ?\t ?\r ? ))
|
||||
(= (match-end 0) (- end 2)))
|
||||
(match-string-no-properties 0)))))
|
||||
(cond ((not target)
|
||||
(xmltok-add-error "\
|
||||
Processing instruction does not start with a name"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 3)))
|
||||
((not (and (= (length target) 3)
|
||||
(let ((case-fold-search t))
|
||||
(string-match "xml" target)))))
|
||||
((= xmltok-start 1)
|
||||
(xmltok-add-error "Invalid XML declaration"
|
||||
xmltok-start
|
||||
(point)))
|
||||
((save-excursion
|
||||
(goto-char xmltok-start)
|
||||
(looking-at (xmltok-xml-declaration regexp)))
|
||||
(xmltok-add-error "XML declaration not at beginning of file"
|
||||
xmltok-start
|
||||
(point)))
|
||||
(t
|
||||
(xmltok-add-error "Processing instruction has target of xml"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 5))))
|
||||
(xmltok-add-prolog-region 'processing-instruction-left
|
||||
xmltok-start
|
||||
(+ xmltok-start
|
||||
2
|
||||
(if target
|
||||
(length target)
|
||||
0)))
|
||||
(xmltok-add-prolog-region 'processing-instruction-right
|
||||
(if target
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start
|
||||
(length target)
|
||||
2))
|
||||
(skip-chars-forward " \t\r\n")
|
||||
(point))
|
||||
(+ xmltok-start 2))
|
||||
(point)))
|
||||
(setq xmltok-type 'processing-instruction))))
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 3)))
|
||||
((not (and (= (length target) 3)
|
||||
(let ((case-fold-search t))
|
||||
(string-match "xml" target)))))
|
||||
((= xmltok-start 1)
|
||||
(xmltok-add-error "Invalid XML declaration"
|
||||
xmltok-start
|
||||
(point)))
|
||||
((save-excursion
|
||||
(goto-char xmltok-start)
|
||||
(looking-at (xmltok-xml-declaration regexp)))
|
||||
(xmltok-add-error "XML declaration not at beginning of file"
|
||||
xmltok-start
|
||||
(point)))
|
||||
(t
|
||||
(xmltok-add-error "Processing instruction has target of xml"
|
||||
(+ xmltok-start 2)
|
||||
(+ xmltok-start 5))))
|
||||
(xmltok-add-prolog-region 'processing-instruction-left
|
||||
xmltok-start
|
||||
(+ xmltok-start
|
||||
2
|
||||
(if target
|
||||
(length target)
|
||||
0)))
|
||||
(xmltok-add-prolog-region 'processing-instruction-right
|
||||
(if target
|
||||
(save-excursion
|
||||
(goto-char (+ xmltok-start
|
||||
(length target)
|
||||
2))
|
||||
(skip-chars-forward " \t\r\n")
|
||||
(point))
|
||||
(+ xmltok-start 2))
|
||||
(point)))
|
||||
(setq xmltok-type 'processing-instruction))
|
||||
|
||||
(defun xmltok-parse-entities ()
|
||||
(let ((todo xmltok-dtd))
|
||||
|
|
Loading…
Add table
Reference in a new issue