From 58203d918e68faba80433f12c86a36642dad9a42 Mon Sep 17 00:00:00 2001 From: Sam Steingold Date: Fri, 26 Oct 2001 20:29:10 +0000 Subject: [PATCH] (html-mode): Set `html-xhtml' from the DOCTYPE. (html-tag-alist): Use `html-xhtml' for "li", "dt" and "dd". (sgml-tag): Close empty tags in XHTML. --- lisp/ChangeLog | 7 +++++++ lisp/textmodes/sgml-mode.el | 28 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 64387f5f766..cb0ffae62a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2001-10-26 Sam Steingold + + * textmodes/sgml-mode.el (html-mode): Set `html-xhtml' from the + DOCTYPE. + (html-tag-alist): Use `html-xhtml' for "li", "dt" and "dd". + (sgml-tag): Close empty tags in XHTML. + 2001-10-26 Jason Rumney * w32-fns.el: (w32-charset-info-alist): Use ANSI for iso10646-1 diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 5b7baa5ffaa..8822bdb132f 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -516,14 +516,15 @@ skeleton-transformation RET upcase RET, or put this in your `.emacs': (completing-read "Tag: " sgml-tag-alist)) ?< str | (("") -1 '(undo-boundary) (identity "<")) | ; see comment above - `(("") '(setq v2 (sgml-attributes ,str t)) ?> + `(("") '(setq v2 (sgml-attributes ,str t)) + (if (and (eq major-mode html-mode) html-xhtml (eq v2 t)) "/>" ">") (if (string= "![" ,str) (prog1 '(("") " [ " _ " ]]") (backward-char)) - (unless (or (sgml-skip-close-p v2) ; (eq v2 t) + (unless (or (eq v2 t) (string-match "^[/!?]" ,str)) (if (symbolp v2) - ;; We go use `identity' to prevent skeleton from passing + ;; We use `identity' to prevent skeleton from passing ;; `str' through skeleton-transformation a second time. '(("") v2 _ v2 ") (if (eq (car v2) t) @@ -970,7 +971,10 @@ This takes effect when first loading the library.") (defcustom html-xhtml nil - "*When non-nil, tag insertion functions will be XHTML-compliant." + "*When non-nil, tag insertion functions will be XHTML-compliant. +If this variable is customized, the custom value is used always. +Otherwise, it is set to be buffer-local when the file has + a DOCTYPE declaration." :type 'boolean :version "21.2" :group 'sgml) @@ -1059,7 +1063,7 @@ This takes effect when first loading the library.") ("center" \n) ("cite") ("code" \n) - ("dd" t) + ("dd" ,(not html-xhtml)) ("del") ("dfn") ("div") @@ -1067,7 +1071,8 @@ This takes effect when first loading the library.") ( "Term: " "
" str (if html-xhtml "
") "
" _ (if html-xhtml "
") \n))) - ("dt" (t _ "
")) + ("dt" (t _ (if html-xhtml "") + "
" (if html-xhtml "
") \n)) ("em") ;("fn" "id" "fn") ; ??? ("head" \n) @@ -1086,7 +1091,7 @@ This takes effect when first loading the library.") ("isindex" t ("action") ("prompt")) ("kbd") ("lang") - ("li" t) + ("li" ,(not html-xhtml)) ("math" \n) ("nobr") ("option" t ("value") ("label") ("selected" t)) @@ -1269,6 +1274,15 @@ To work around that, do: outline-level (lambda () (char-after (1- (match-end 0))))) (setq imenu-create-index-function 'html-imenu-index) + (unless (get 'html-xhtml 'saved-value) + ;; not customized -- set from the DocType + (save-excursion + (goto-char (point-min)) + (when (re-search-forward + "