diff options
| author | Noam Postavsky | 2019-05-26 17:41:22 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2019-06-04 08:42:50 -0400 |
| commit | e04f93e18a8083d3a4930decc523c4f5d9a97c9e (patch) | |
| tree | 722f68d42f709333db9cd0cec46fe71a78bdaeac /lisp | |
| parent | 438e4804d107720f526d0c7c367cbd029f264676 (diff) | |
| download | emacs-e04f93e18a8083d3a4930decc523c4f5d9a97c9e.tar.gz emacs-e04f93e18a8083d3a4930decc523c4f5d9a97c9e.zip | |
Don't fontify text outside of SGML/XML tags (Bug#33887)
* lisp/textmodes/sgml-mode.el (sgml-font-lock-syntactic-face): New
function.
(sgml-mode):
* lisp/nxml/nxml-mode.el (nxml-mode): Use it as
font-lock-syntactic-face-function value.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/nxml/nxml-mode.el | 4 | ||||
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 8da9f5ca287..232352b26bd 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el | |||
| @@ -540,7 +540,9 @@ Many aspects this mode can be customized using | |||
| 540 | nil ; no special syntax table | 540 | nil ; no special syntax table |
| 541 | (font-lock-extend-region-functions . (nxml-extend-region)) | 541 | (font-lock-extend-region-functions . (nxml-extend-region)) |
| 542 | (jit-lock-contextually . t) | 542 | (jit-lock-contextually . t) |
| 543 | (font-lock-unfontify-region-function . nxml-unfontify-region))) | 543 | (font-lock-unfontify-region-function . nxml-unfontify-region) |
| 544 | (font-lock-syntactic-face-function | ||
| 545 | . sgml-font-lock-syntactic-face))) | ||
| 544 | 546 | ||
| 545 | (with-demoted-errors (rng-nxml-mode-init))) | 547 | (with-demoted-errors (rng-nxml-mode-init))) |
| 546 | 548 | ||
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 1df7e78afc5..da25665e62e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el | |||
| @@ -329,6 +329,12 @@ Any terminating `>' or `/' is not matched.") | |||
| 329 | (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1 | 329 | (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1 |
| 330 | "Rules for highlighting SGML code. See also `sgml-tag-face-alist'.") | 330 | "Rules for highlighting SGML code. See also `sgml-tag-face-alist'.") |
| 331 | 331 | ||
| 332 | (defun sgml-font-lock-syntactic-face (state) | ||
| 333 | "`font-lock-syntactic-face-function' for `sgml-mode'." | ||
| 334 | ;; Don't use string face outside of tags. | ||
| 335 | (cond ((and (nth 9 state) (nth 3 state)) font-lock-string-face) | ||
| 336 | ((nth 4 state) font-lock-comment-face))) | ||
| 337 | |||
| 332 | (defvar-local sgml--syntax-propertize-ppss nil) | 338 | (defvar-local sgml--syntax-propertize-ppss nil) |
| 333 | 339 | ||
| 334 | (defun sgml--syntax-propertize-ppss (pos) | 340 | (defun sgml--syntax-propertize-ppss (pos) |
| @@ -573,7 +579,7 @@ Do \\[describe-key] on the following bindings to discover what they do. | |||
| 573 | ;; This is desirable because SGML discards a newline that appears | 579 | ;; This is desirable because SGML discards a newline that appears |
| 574 | ;; immediately after a start tag or immediately before an end tag. | 580 | ;; immediately after a start tag or immediately before an end tag. |
| 575 | (setq-local paragraph-start (concat "[ \t]*$\\|\ | 581 | (setq-local paragraph-start (concat "[ \t]*$\\|\ |
| 576 | [ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) | 582 | \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) |
| 577 | (setq-local paragraph-separate (concat paragraph-start "$")) | 583 | (setq-local paragraph-separate (concat paragraph-start "$")) |
| 578 | (setq-local adaptive-fill-regexp "[ \t]*") | 584 | (setq-local adaptive-fill-regexp "[ \t]*") |
| 579 | (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) | 585 | (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) |
| @@ -591,7 +597,9 @@ Do \\[describe-key] on the following bindings to discover what they do. | |||
| 591 | (setq font-lock-defaults '((sgml-font-lock-keywords | 597 | (setq font-lock-defaults '((sgml-font-lock-keywords |
| 592 | sgml-font-lock-keywords-1 | 598 | sgml-font-lock-keywords-1 |
| 593 | sgml-font-lock-keywords-2) | 599 | sgml-font-lock-keywords-2) |
| 594 | nil t)) | 600 | nil t nil |
| 601 | (font-lock-syntactic-face-function | ||
| 602 | . sgml-font-lock-syntactic-face))) | ||
| 595 | (setq-local syntax-propertize-function #'sgml-syntax-propertize) | 603 | (setq-local syntax-propertize-function #'sgml-syntax-propertize) |
| 596 | (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) | 604 | (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) |
| 597 | (setq-local sgml-xml-mode (sgml-xml-guess)) | 605 | (setq-local sgml-xml-mode (sgml-xml-guess)) |