GNU bug report logs -
#33887
26.1; Emacs hangs for several seconds when going to the end of an XML file in nXML mode
Previous Next
Reported by: Vincent Lefevre <vincent <at> vinc17.net>
Date: Thu, 27 Dec 2018 10:14:02 UTC
Severity: normal
Tags: fixed
Merged with 25176
Found in versions 26.0.50, 26.1
Fixed in version 27.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #58 received at 33887 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Vincent Lefevre <vincent <at> vinc17.net> writes:
> I've tried the combination of
>
> ca14dd1d4628094dd33d5d94694dcf5f29e843b8
> 7dab3ee7ab54b3c2e7bc24170376054786c01d6f
>
> and this patch against Debian's current source package.
>
> Emacs no longer hangs, but I get incorrect highlighting,
> for instance on the following XML file.
>
> <root>
> <!-- comment -->
> <a>"a'</a>
> <!-- comment -->
> </root>
>
> Highlighting starts to be wrong at the single-quote character.
> I've attached a screenshot obtained with the -Q option.
>
> Did I miss anything?
Ah, I didn't get the mixed quote handling right. Here's the fix for master:
[0001-Fix-Bug-33887-for-mixed-quote-usage.patch (text/x-diff, inline)]
From 4677edd8dd65b5d956732821e78794f35b275418 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 18 May 2019 00:04:01 -0400
Subject: [PATCH] Fix Bug#33887 for mixed quote usage
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-rules): Only
skip syntax-ppss for matched quotes.
* test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax):
Expand test.
---
lisp/textmodes/sgml-mode.el | 4 ++--
test/lisp/textmodes/sgml-mode-tests.el | 17 ++++++++++++-----
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 1b064fb825..e3cf56aa0e 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -345,8 +345,8 @@ sgml-font-lock-keywords
;; the resulting number of calls to syntax-ppss made it too slow
;; (bug#33887), so we're now careful to leave alone any pair
;; of quotes that doesn't hold a < or > char, which is the vast majority.
- ("\\(?:\\(?1:\"\\)[^\"<>]*[<>\"]\\|\\(?1:'\\)[^'<>]*[<>']\\)"
- (1 (unless (memq (char-before) '(?\' ?\"))
+ ("\\([\"']\\)[^<>\"']*[<>\"']"
+ (1 (unless (eq (char-after (match-beginning 1)) (char-before))
;; Be careful to call `syntax-ppss' on a position before the one
;; we're going to change, so as not to need to flush the data we
;; just computed.
diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el
index a900e8dcf2..ffcc2cd840 100644
--- a/test/lisp/textmodes/sgml-mode-tests.el
+++ b/test/lisp/textmodes/sgml-mode-tests.el
@@ -161,11 +161,18 @@ sgml-with-content
(should (string= "&&" (buffer-string))))))
(ert-deftest sgml-tests--quotes-syntax ()
- (with-temp-buffer
- (sgml-mode)
- (insert "a\"b <tag>c'd</tag>")
- (should (= 1 (car (syntax-ppss (1- (point-max))))))
- (should (= 0 (car (syntax-ppss (point-max)))))))
+ (dolist (str '("a\"b <t>c'd</t>"
+ "a'b <t>c\"d</t>"
+ "<t>\"a'</t>"
+ "<t>'a\"</t>"
+ "<t>\"a'\"</t>"
+ "<t>'a\"'</t>"))
+ (with-temp-buffer
+ (sgml-mode)
+ (insert str)
+ ;; Check that last tag is parsed as a tag.
+ (should (= 1 (car (syntax-ppss (1- (point-max))))))
+ (should (= 0 (car (syntax-ppss (point-max))))))))
(provide 'sgml-mode-tests)
;;; sgml-mode-tests.el ends here
--
2.11.0
[Message part 3 (text/plain, inline)]
And the correponding patch against emacs-26:
[0001-Backport-sgml-syntax-propertize-rules-speedup-Bug-33.patch (text/plain, attachment)]
This bug report was last modified 5 years and 353 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.