]> git.eshelyaron.com Git - emacs.git/commitdiff
(html-mode): Set `html-xhtml' from the DOCTYPE.
authorSam Steingold <sds@gnu.org>
Fri, 26 Oct 2001 20:29:10 +0000 (20:29 +0000)
committerSam Steingold <sds@gnu.org>
Fri, 26 Oct 2001 20:29:10 +0000 (20:29 +0000)
(html-tag-alist): Use `html-xhtml' for "li", "dt" and "dd".
(sgml-tag): Close empty tags in XHTML.

lisp/ChangeLog
lisp/textmodes/sgml-mode.el

index 64387f5f76607ba6c4091efd6ce5dc2ad2b655ac..cb0ffae62a7a784b1dc82ccfcbb944b948787e90 100644 (file)
@@ -1,3 +1,10 @@
+2001-10-26  Sam Steingold  <sds@gnu.org>
+
+       * 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  <jasonr@gnu.org>
 
        * w32-fns.el: (w32-charset-info-alist): Use ANSI for iso10646-1
index 5b7baa5ffaa2791ac6c62854ef017807c2d1a78d..8822bdb132ff321963e9137ca03c2e9bb75c3241 100644 (file)
@@ -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 "&lt;")) |       ; 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 "</" (identity ',str) ?>)
          (if (eq (car v2) t)
@@ -970,7 +971,10 @@ This takes effect when first loading the library.")
 \f
 
 (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: "
                   "<dt>" str (if html-xhtml "</dt>")
                    "<dd>" _ (if html-xhtml "</dd>") \n)))
-      ("dt" (t _ "<dd>"))
+      ("dt" (t _ (if html-xhtml "</dt>")
+             "<dd>" (if html-xhtml "</dd>") \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
+             "<!DOCTYPE\\s-+html\\s-+PUBLIC\\s-+\"-//W3C//DTD \\(X?\\)HTML"
+             nil t)
+        (set (make-local-variable 'html-xhtml)
+             (string= "X" (match-string 1))))))
   ;; It's for the user to decide if it defeats it or not  -stef
   ;; (make-local-variable 'imenu-sort-function)
   ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose