Commit e04f93e1 authored by Noam Postavsky's avatar Noam Postavsky

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.
parent 438e4804
...@@ -540,7 +540,9 @@ Many aspects this mode can be customized using ...@@ -540,7 +540,9 @@ Many aspects this mode can be customized using
nil ; no special syntax table nil ; no special syntax table
(font-lock-extend-region-functions . (nxml-extend-region)) (font-lock-extend-region-functions . (nxml-extend-region))
(jit-lock-contextually . t) (jit-lock-contextually . t)
(font-lock-unfontify-region-function . nxml-unfontify-region))) (font-lock-unfontify-region-function . nxml-unfontify-region)
(font-lock-syntactic-face-function
. sgml-font-lock-syntactic-face)))
(with-demoted-errors (rng-nxml-mode-init))) (with-demoted-errors (rng-nxml-mode-init)))
......
...@@ -329,6 +329,12 @@ Any terminating `>' or `/' is not matched.") ...@@ -329,6 +329,12 @@ Any terminating `>' or `/' is not matched.")
(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1 (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
"Rules for highlighting SGML code. See also `sgml-tag-face-alist'.") "Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
(defun sgml-font-lock-syntactic-face (state)
"`font-lock-syntactic-face-function' for `sgml-mode'."
;; Don't use string face outside of tags.
(cond ((and (nth 9 state) (nth 3 state)) font-lock-string-face)
((nth 4 state) font-lock-comment-face)))
(defvar-local sgml--syntax-propertize-ppss nil) (defvar-local sgml--syntax-propertize-ppss nil)
(defun sgml--syntax-propertize-ppss (pos) (defun sgml--syntax-propertize-ppss (pos)
...@@ -573,7 +579,7 @@ Do \\[describe-key] on the following bindings to discover what they do. ...@@ -573,7 +579,7 @@ Do \\[describe-key] on the following bindings to discover what they do.
;; This is desirable because SGML discards a newline that appears ;; This is desirable because SGML discards a newline that appears
;; immediately after a start tag or immediately before an end tag. ;; immediately after a start tag or immediately before an end tag.
(setq-local paragraph-start (concat "[ \t]*$\\|\ (setq-local paragraph-start (concat "[ \t]*$\\|\
[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
(setq-local paragraph-separate (concat paragraph-start "$")) (setq-local paragraph-separate (concat paragraph-start "$"))
(setq-local adaptive-fill-regexp "[ \t]*") (setq-local adaptive-fill-regexp "[ \t]*")
(add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) (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,7 +597,9 @@ Do \\[describe-key] on the following bindings to discover what they do.
(setq font-lock-defaults '((sgml-font-lock-keywords (setq font-lock-defaults '((sgml-font-lock-keywords
sgml-font-lock-keywords-1 sgml-font-lock-keywords-1
sgml-font-lock-keywords-2) sgml-font-lock-keywords-2)
nil t)) nil t nil
(font-lock-syntactic-face-function
. sgml-font-lock-syntactic-face)))
(setq-local syntax-propertize-function #'sgml-syntax-propertize) (setq-local syntax-propertize-function #'sgml-syntax-propertize)
(setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function)
(setq-local sgml-xml-mode (sgml-xml-guess)) (setq-local sgml-xml-mode (sgml-xml-guess))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment