aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorNoam Postavsky2019-05-18 14:37:51 -0400
committerNoam Postavsky2019-06-04 08:42:50 -0400
commitd414c93b062cc3e245a6db0cb764d354d037bd42 (patch)
treee594558391e8a55800012b8d9642e322685ff355 /lisp
parente04f93e18a8083d3a4930decc523c4f5d9a97c9e (diff)
downloademacs-d414c93b062cc3e245a6db0cb764d354d037bd42.tar.gz
emacs-d414c93b062cc3e245a6db0cb764d354d037bd42.zip
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')
-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.")
424 (when rng-validate-mode 424 (when rng-validate-mode
425 (rng-validate-while-idle (current-buffer))))) 425 (rng-validate-while-idle (current-buffer)))))
426 426
427(defvar nxml-prolog-end) ;; nxml-rap.el
428
429(defun nxml-syntax-propertize (start end)
430 "Syntactic keywords for `nxml-mode'."
431 ;; Like `sgml-syntax-propertize', but handle `nxml-prolog-regions'.
432 (when (< start nxml-prolog-end)
433 (catch 'done-prolog
434 (dolist (prolog-elem nxml-prolog-regions)
435 (let ((type (aref prolog-elem 0))
436 (pbeg (aref prolog-elem 1))
437 (pend (aref prolog-elem 2)))
438 (when (eq type 'comment)
439 (put-text-property pbeg (1+ pbeg)
440 'syntax-table (string-to-syntax "< b"))
441 (put-text-property (1- pend) pend
442 'syntax-table (string-to-syntax "> b")))
443 (when (> pend end)
444 (throw 'done-prolog t)))))
445 (setq start nxml-prolog-end))
446 (if (>= start end)
447 (goto-char end)
448 (goto-char start)
449 (sgml-syntax-propertize start end)))
450
427(defvar tildify-space-string) 451(defvar tildify-space-string)
428(defvar tildify-foreach-region-function) 452(defvar tildify-foreach-region-function)
429 453
@@ -518,7 +542,7 @@ Many aspects this mode can be customized using
518 (nxml-with-invisible-motion 542 (nxml-with-invisible-motion
519 (nxml-scan-prolog))))) 543 (nxml-scan-prolog)))))
520 (setq-local syntax-ppss-table sgml-tag-syntax-table) 544 (setq-local syntax-ppss-table sgml-tag-syntax-table)
521 (setq-local syntax-propertize-function #'sgml-syntax-propertize) 545 (setq-local syntax-propertize-function #'nxml-syntax-propertize)
522 (add-hook 'change-major-mode-hook #'nxml-cleanup nil t) 546 (add-hook 'change-major-mode-hook #'nxml-cleanup nil t)
523 547
524 ;; Emacs 23 handles the encoding attribute on the xml declaration 548 ;; Emacs 23 handles the encoding attribute on the xml declaration