aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/sgml-mode.el42
1 files changed, 31 insertions, 11 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index e148b06aa7b..97a11443984 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -341,20 +341,40 @@ Any terminating `>' or `/' is not matched.")
341(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1 341(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
342 "Rules for highlighting SGML code. See also `sgml-tag-face-alist'.") 342 "Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
343 343
344(defconst sgml-syntax-propertize-function 344(defun sgml-syntax-propertize (start end)
345 "Syntactic keywords for `sgml-mode'."
346 (goto-char start)
347 (sgml-syntax-propertize-inside end)
348 (funcall
345 (syntax-propertize-rules 349 (syntax-propertize-rules
346 ;; Use the `b' style of comments to avoid interference with the -- ... -- 350 ;; Use the `b' style of comments to avoid interference with the -- ... --
347 ;; comments recognized when `sgml-specials' includes ?-. 351 ;; comments recognized when `sgml-specials' includes ?-.
348 ;; FIXME: beware of <!--> blabla <!--> !! 352 ;; FIXME: beware of <!--> blabla <!--> !!
349 ("\\(<\\)!--" (1 "< b")) 353 ("\\(<\\)!--" (1 "< b"))
350 ("--[ \t\n]*\\(>\\)" (1 "> b")) 354 ("--[ \t\n]*\\(>\\)" (1 "> b"))
351 ;; Double quotes outside of tags should not introduce strings. 355 ("\\(<\\)[?!]" (1 (prog1 "|>"
352 ;; Be careful to call `syntax-ppss' on a position before the one we're 356 (sgml-syntax-propertize-inside end))))
353 ;; going to change, so as not to need to flush the data we just computed. 357 ;; Double quotes outside of tags should not introduce strings.
354 ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) 358 ;; Be careful to call `syntax-ppss' on a position before the one we're
355 (goto-char (match-end 0))) 359 ;; going to change, so as not to need to flush the data we just computed.
356 (string-to-syntax "."))))) 360 ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
357 "Syntactic keywords for `sgml-mode'.") 361 (goto-char (match-end 0)))
362 (string-to-syntax ".")))))
363 start end))
364
365(defun sgml-syntax-propertize-inside (end)
366 (let ((ppss (syntax-ppss)))
367 (cond
368 ((eq (nth 3 ppss) t)
369 (let ((endre (save-excursion
370 (goto-char (nth 8 ppss))
371 (cond
372 ((looking-at-p "<!\\[CDATA\\[") "]]>")
373 ((looking-at-p "<\\?") (if sgml-xml-mode "\\?>" ">"))
374 (t ">")))))
375 (when (re-search-forward endre end 'move)
376 (put-text-property (1- (point)) (point)
377 'syntax-table (string-to-syntax "|<"))))))))
358 378
359;; internal 379;; internal
360(defvar sgml-face-tag-alist () 380(defvar sgml-face-tag-alist ()
@@ -547,7 +567,7 @@ Do \\[describe-key] on the following bindings to discover what they do.
547 sgml-font-lock-keywords-1 567 sgml-font-lock-keywords-1
548 sgml-font-lock-keywords-2) 568 sgml-font-lock-keywords-2)
549 nil t)) 569 nil t))
550 (setq-local syntax-propertize-function sgml-syntax-propertize-function) 570 (setq-local syntax-propertize-function #'sgml-syntax-propertize)
551 (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) 571 (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function)
552 (setq-local sgml-xml-mode (sgml-xml-guess)) 572 (setq-local sgml-xml-mode (sgml-xml-guess))
553 (unless sgml-xml-mode 573 (unless sgml-xml-mode