unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Moritz Bunkus <moritz@bunkus.org>
Cc: Vincent Lefevre <vincent@vinc17.net>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	32823@debbugs.gnu.org
Subject: bug#32823: 26.1; nxml-mode: "no matching start-tag" with long entity definition list
Date: Wed, 29 May 2019 19:40:40 -0400	[thread overview]
Message-ID: <87d0k07rt3.fsf@gmail.com> (raw)
In-Reply-To: <87k1eak2q6.fsf@bunkus.org> (Moritz Bunkus's message of "Tue, 28 May 2019 17:39:29 +0200")

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

Moritz Bunkus <moritz@bunkus.org> writes:

>> Ah, you're right, it's not like #18871.  But I think it's the same as
>> one of the edge cases Vincent brought up during Bug#33887, and the
>> second patch in https://debbugs.gnu.org/33887#73 should fix it:
>
> That patch does indeed fix the issue for me. Thanks a lot!

Updated patch for another edge case (https://debbugs.gnu.org/33887#127).


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3664 bytes --]

From 290bbf4341c58339dafe46ed87b1979115306556 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 18 May 2019 14:37:51 -0400
Subject: [PATCH] Don't sgml-syntax-propertize-inside XML prolog (Bug#32823)

* lisp/nxml/nxml-mode.el (nxml-syntax-propertize): New function.
(nxml-mode): Use it as the syntax-propertize-function.
* test/lisp/nxml/nxml-mode-tests.el (nxml-mode-doctype-and-quote-syntax)
(nxml-mode-prolog-comment): New tests.
---
 lisp/nxml/nxml-mode.el            | 26 +++++++++++++++++++++++++-
 test/lisp/nxml/nxml-mode-tests.el | 21 +++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 8da9f5ca28..113b8bb104 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -424,6 +424,30 @@ (defun nxml-parent-document-set (parent-document)
     (when rng-validate-mode
       (rng-validate-while-idle (current-buffer)))))
 
+(defvar nxml-prolog-end) ;; nxml-rap.el
+
+(defun nxml-syntax-propertize (start end)
+  "Syntactic keywords for `nxml-mode'."
+  ;; Like `sgml-syntax-propertize', but handle `nxml-prolog-regions'.
+  (when (< start nxml-prolog-end)
+    (catch 'done-prolog
+      (dolist (prolog-elem nxml-prolog-regions)
+        (let ((type (aref prolog-elem 0))
+              (pbeg (aref prolog-elem 1))
+              (pend (aref prolog-elem 2)))
+          (when (eq type 'comment)
+            (put-text-property pbeg (1+ pbeg)
+                               'syntax-table (string-to-syntax "< b"))
+            (put-text-property (1- pend) pend
+                               'syntax-table (string-to-syntax "> b")))
+          (when (> pend end)
+            (throw 'done-prolog t)))))
+    (setq start nxml-prolog-end))
+  (if (>= start end)
+      (goto-char end)
+    (goto-char start)
+    (sgml-syntax-propertize start end)))
+
 (defvar tildify-space-string)
 (defvar tildify-foreach-region-function)
 
@@ -518,7 +542,7 @@ (define-derived-mode nxml-mode text-mode "nXML"
 	(nxml-with-invisible-motion
 	  (nxml-scan-prolog)))))
   (setq-local syntax-ppss-table sgml-tag-syntax-table)
-  (setq-local syntax-propertize-function #'sgml-syntax-propertize)
+  (setq-local syntax-propertize-function #'nxml-syntax-propertize)
   (add-hook 'change-major-mode-hook #'nxml-cleanup nil t)
 
   ;; Emacs 23 handles the encoding attribute on the xml declaration
diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el
index 92744be619..70816bb9de 100644
--- a/test/lisp/nxml/nxml-mode-tests.el
+++ b/test/lisp/nxml/nxml-mode-tests.el
@@ -78,5 +78,26 @@ (ert-deftest nxml-mode-font-lock-quotes ()
       (should-not (equal (get-text-property squote-txt-pos 'face)
                          (get-text-property dquote-att-pos 'face))))))
 
+(ert-deftest nxml-mode-doctype-and-quote-syntax ()
+  (with-temp-buffer
+    (insert "<!DOCTYPE t [\n<!ENTITY f SYSTEM \"f.xml\">\n]>\n<t>'</t>")
+    (nxml-mode)
+    ;; Check that last tag is parsed as a tag.
+    (should (= 1 (car (syntax-ppss (1- (point-max))))))
+    (should (= 0 (car (syntax-ppss (point-max)))))))
+
+(ert-deftest nxml-mode-prolog-comment ()
+  (with-temp-buffer
+    (insert "<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- comment1 -->
+<t><!-- comment2 --></t><!-- comment3 -->")
+    (nxml-mode)
+    ;; Check that all comments are parsed as comments
+    (goto-char (point-min))
+    (search-forward "comment1")
+    (should (nth 4 (syntax-ppss)))
+    (search-forward "comment2")
+    (should (nth 4 (syntax-ppss)))
+    (search-forward "comment3")))
+
 (provide 'nxml-mode-tests)
 ;;; nxml-mode-tests.el ends here
-- 
2.11.0


  reply	other threads:[~2019-05-29 23:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 12:50 bug#32823: 26.1; nxml-mode: "no matching start-tag" with long entity definition list Moritz, Bunkus <moritz
2018-09-24 16:25 ` Eli Zaretskii
2018-09-24 17:12   ` Moritz Bunkus
2018-09-24 17:26     ` Eli Zaretskii
2018-09-24 17:51       ` Moritz Bunkus
2018-09-25  6:56         ` Eli Zaretskii
2019-05-27 19:22           ` npostavs
2019-05-27 20:01             ` Moritz Bunkus
2019-05-27 20:35               ` npostavs
2019-05-28 15:39                 ` Moritz Bunkus
2019-05-29 23:40                   ` Noam Postavsky [this message]
2019-05-30 13:22                     ` Moritz Bunkus
2019-05-30 22:08                     ` Vincent Lefevre
2019-06-02 17:50                       ` Vincent Lefevre
2019-06-04 12:59                         ` Noam Postavsky
2019-06-04 14:29                           ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d0k07rt3.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=32823@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=moritz@bunkus.org \
    --cc=vincent@vinc17.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).