[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36092: 27.0.50; incorrect highlighting in nXML mode with ' and raw >
From: |
Noam Postavsky |
Subject: |
bug#36092: 27.0.50; incorrect highlighting in nXML mode with ' and raw > characters |
Date: |
Tue, 04 Jun 2019 21:14:33 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Vincent Lefevre <vincent@vinc17.net> writes:
> On the following file, lines 26 and below are not highlighted
> (i.e. they get the normal color). This is reproducible with
> and without the -Q option.
It's hitting an assertion failure during syntax-propertizing. The
problem seems to be that the parse-partial-sexp call in
sgml--syntax-propertize-ppss isn't using the right syntax table. I
wonder why it doesn't happen for sgml-mode though (as far I can tell).
Stefan, any thoughts about that?
Patch below fixes it, but it might just be papering over another
problem.
>From ed59843b7fa456e0614c2c63e1479458642671ea Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Tue, 4 Jun 2019 21:08:26 -0400
Subject: [PATCH] Fix nxml syntax propertizing assertion failure (Bug#36092)
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize): Use the
syntax-ppss-table syntax-table.
* test/lisp/nxml/nxml-mode-tests.el (nxml-mode->-after-quote): New
test.
---
lisp/textmodes/sgml-mode.el | 17 +++++++++--------
test/lisp/nxml/nxml-mode-tests.el | 15 +++++++++++++++
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 0c5d5e56a6..09211e1661 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -399,14 +399,15 @@ (eval-and-compile
(defun sgml-syntax-propertize (start end)
"Syntactic keywords for `sgml-mode'."
- (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start)))
- (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0))
- (sgml-syntax-propertize-inside end)
- (funcall
- (syntax-propertize-rules sgml-syntax-propertize-rules)
- start end)
- ;; Catch any '>' after the last quote.
- (sgml--syntax-propertize-ppss end))
+ (with-syntax-table syntax-ppss-table
+ (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start)))
+ (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0))
+ (sgml-syntax-propertize-inside end)
+ (funcall
+ (syntax-propertize-rules sgml-syntax-propertize-rules)
+ start end)
+ ;; Catch any '>' after the last quote.
+ (sgml--syntax-propertize-ppss end)))
(defun sgml-syntax-propertize-inside (end)
(let ((ppss (syntax-ppss)))
diff --git a/test/lisp/nxml/nxml-mode-tests.el
b/test/lisp/nxml/nxml-mode-tests.el
index 70816bb9de..53416b4280 100644
--- a/test/lisp/nxml/nxml-mode-tests.el
+++ b/test/lisp/nxml/nxml-mode-tests.el
@@ -99,5 +99,20 @@ (ert-deftest nxml-mode-prolog-comment ()
(should (nth 4 (syntax-ppss)))
(search-forward "comment3")))
+(ert-deftest nxml-mode->-after-quote ()
+ "Reduction from Bug#36092."
+ (with-temp-buffer
+ (insert "<root>\n"
+ (make-string 1794 ?a) "\n"
+ "'>"
+ (make-string 196 ?a) "\n"
+ "</root>")
+ (nxml-mode)
+ (syntax-propertize 2001)
+ (syntax-propertize (point-max)) ; Triggered an assert failure.
+ ;; Check that last tag is parsed as a tag.
+ (should (= 1 (- (car (syntax-ppss (1- (point-max))))
+ (car (syntax-ppss (point-max))))))))
+
(provide 'nxml-mode-tests)
;;; nxml-mode-tests.el ends here
--
2.11.0