]> code.delx.au - gnu-emacs/commitdiff
* xmltok.el: Mark the "sole --" rather than the comment opener
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 15 Jan 2016 21:59:21 +0000 (16:59 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 15 Jan 2016 21:59:21 +0000 (16:59 -0500)
* lisp/nxml/xmltok.el (xmltok-scan-after-comment-open): Put the error
marker on the "sole --" rather than on the comment opener.

lisp/nxml/xmltok.el

index 8fc66c99a454f3af332fecd3e25e2a455b0f8ac2..93d47c195c0d3d7360d773d11bd53eb7a77e5ce7 100644 (file)
@@ -262,11 +262,10 @@ and VALUE-END, otherwise a STRING giving the value."
   (vector message start end))
 
 (defun xmltok-add-error (message &optional start end)
-  (setq xmltok-errors
-       (cons (xmltok-make-error message
-                                (or start xmltok-start)
-                                (or end (point)))
-             xmltok-errors)))
+  (push (xmltok-make-error message
+                           (or start xmltok-start)
+                           (or end (point)))
+        xmltok-errors))
 
 (defun xmltok-forward ()
   (setq xmltok-start (point))
@@ -739,19 +738,11 @@ Return the type of the token."
   (setq xmltok-type 'processing-instruction))
 
 (defun xmltok-scan-after-comment-open ()
-  (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 `>'")
-                 (goto-char (point-max))
-                 'comment)))))
+  (let (found--)
+    (while (and (setq found-- (re-search-forward "--\\(>\\)?" nil 'move))
+                (not (match-end 1)))
+      (xmltok-add-error "`--' not followed by `>'" (match-beginning 0)))
+    (setq xmltok-type 'comment)))
 
 (defun xmltok-scan-attributes ()
   (let ((recovering nil)