>From d1520ab5b94d0f130955800ea11222a3702a5519 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 20 May 2019 16:29:04 -0400 Subject: [PATCH 2/2] Handle ">" outside SGML/XML tags (Bug#33887) * lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-rules): Check the list of open parens rather than current depth, the latter is not reliable. * test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax): Extend test for this case. --- lisp/textmodes/sgml-mode.el | 4 +++- test/lisp/textmodes/sgml-mode-tests.el | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index b555db7b76..052201e5ee 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -364,7 +364,9 @@ sgml-font-lock-keywords ;; we're going to change, so as not to need to flush the data we ;; just computed. (let ((ppss (syntax-ppss (match-beginning 0)))) - (if (prog1 (zerop (car ppss)) ; Outside tag. + ;; Can't rely on depth (nth 0 ppss), because we don't + ;; mark ">" outside of tags. + (if (prog1 (null (nth 9 ppss)) ; Outside tag. (goto-char (1- (match-end 0))) ;; If we're in a comment, don't skip over comment ;; ender. diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 09941fe6f1..d6913863d6 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -138,13 +138,16 @@ sgml-with-content "\"a'\"" "'a\"'" "" - "")) + "" + ;; Yes, ">" is technically valid outside tags! + ">'" + )) (ert-info (str :prefix "Test string: ") (sgml-with-content 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))))))))) + (should (= 1 (- (car (syntax-ppss (1- (point-max)))) + (car (syntax-ppss (point-max)))))))))) (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here -- 2.11.0