summaryrefslogtreecommitdiff
path: root/lisp/nxml
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-05-18 14:37:51 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-06-04 08:42:50 -0400
commitd414c93b062cc3e245a6db0cb764d354d037bd42 (patch)
treee594558391e8a55800012b8d9642e322685ff355 /lisp/nxml
parente04f93e18a8083d3a4930decc523c4f5d9a97c9e (diff)
downloademacs-d414c93b062cc3e245a6db0cb764d354d037bd42.tar.gz
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.
Diffstat (limited to 'lisp/nxml')
-rw-r--r--lisp/nxml/nxml-mode.el26
1 files changed, 25 insertions, 1 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 232352b26bd..1eb728f23a5 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -424,6 +424,30 @@ reference.")
(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 @@ Many aspects this mode can be customized using
(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