diff options
Diffstat (limited to 'lisp/textmodes/sgml-mode.el')
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 9e3be99af14..6dc1b9e727e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -96,24 +96,20 @@ a DOCTYPE or an XML declaration." `text-mode-hook' is run first." :type 'hook) -;; As long as Emacs's syntax can't be complemented with predicates to context -;; sensitively confirm the syntax of characters, we have to live with this -;; kludgy kind of tradeoff. -(defvar sgml-specials '(?\") +;; The official handling of "--" is complicated in SGML, and +;; historically not well supported by browser HTML parsers. +;; Recommendations for writing HTML comments is to use <!--...--> +;; (where ... doesn't contain "--") to avoid the complications +;; altogether (XML goes even further by requiring this in the spec). +;; So there is probably no need to handle it "correctly". +(defvar sgml-specials '(?\" ?\') "List of characters that have a special meaning for SGML mode. This list is used when first loading the `sgml-mode' library. -The supported characters and potential disadvantages are: +The supported characters are ?\\\", ?\\=', and ?-. - ?\\\" Makes \" in text start a string. - ?\\=' Makes \\=' in text start a string. - ?- Makes -- in text start a comment. - -When only one of ?\\\" or ?\\=' are included, \"\\='\" or \\='\"\\=', as can be found in -DTDs, start a string. To partially avoid this problem this also makes these -self insert as named entities depending on `sgml-quick-keys'. - -Including ?- has the problem of affecting dashes that have nothing to do -with comments, so we normally turn it off.") +Including ?- makes double dashes into comment delimiters, but +they are really only supposed to delimit comments within DTD +definitions. So we normally turn it off.") (defvar sgml-quick-keys nil "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. @@ -343,21 +339,12 @@ Any terminating `>' or `/' is not matched.") ("--[ \t\n]*\\(>\\)" (1 "> b")) ("\\(<\\)[?!]" (1 (prog1 "|>" (sgml-syntax-propertize-inside end)))) - ;; Double quotes outside of tags should not introduce strings which end up - ;; hiding tags. We used to test every double quote and mark it as "." - ;; if it's outside of tags, but there are too many double quotes and - ;; the resulting number of calls to syntax-ppss made it too slow - ;; (bug#33887), so we're now careful to leave alone any pair - ;; of quotes that doesn't hold a < or > char, which is the vast majority. - ("\\(\"\\)[^\"<>]*[<>\"]" - (1 (unless (eq ?\" (char-before)) - ;; Be careful to call `syntax-ppss' on a position before the one - ;; we're going to change, so as not to need to flush the data we - ;; just computed. - (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) - (goto-char (1- (match-end 0)))) - (string-to-syntax "."))))) - ))) + ;; Quotes outside of tags should not introduce strings. + ;; Be careful to call `syntax-ppss' on a position before the one we're + ;; going to change, so as not to need to flush the data we just computed. + ("[\"']" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) + (goto-char (match-end 0))) + (string-to-syntax "."))))))) (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." |