]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/sgml-mode.el
(ispell-get-word): No error if can't find a word to check.
[gnu-emacs] / lisp / textmodes / sgml-mode.el
index b71e0a2f1290fdb6135a7a7b750ec30ac5bacdd3..eff08965f219119c1af5e8998d3a75c5e6d3c548 100644 (file)
@@ -1,9 +1,10 @@
 ;;; sgml-mode.el --- SGML- and HTML-editing modes
 
-;; Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1995, 1996, 1998 Free Software Foundation, Inc.
 
-;; Author: James Clark <jjc@clark.com>
+;; Author: James Clark <jjc@jclark.com>
 ;; Adapted-By: ESR; Daniel.Pfeiffer@Informatik.START.dbp.de
+;;             F.Potorti@cnuce.cnr.it
 ;; Keywords: wp, hypermedia, comm, languages
 
 ;; This file is part of GNU Emacs.
 
 ;;; Code:
 
+(defgroup sgml nil
+  "SGML editing mode"
+  :group 'languages)
+
+(defcustom sgml-transformation 'identity
+  "*Default value for `skeleton-transformation' (which see) in SGML mode."
+  :type 'function
+  :group 'sgml)
+
+(put 'sgml-transformation 'variable-interactive
+     "aTransformation function: ")
+
 ;; As long as Emacs' 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 '(?\" ?-)
-  "List of characters that have a special meaning for sgml-mode.
+(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:
 
@@ -45,13 +58,14 @@ The supported characters and potential disadvantages are:
 
 When only one of ?\\\" or ?' are included, \"'\" or '\"' as it 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'.  <!----> must
-contain an even multiple of two (4, 8, ...) minuses, or Emacs' syntax
-mechanism won't recognize a comment.")
+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.")
 
 (defvar sgml-quick-keys nil
-  "Use <, >, &, SPC and `sgml-specials' keys ``electrically'' when non-nil.
-This takes effect when first loading the library.")
+  "Use <, >, &, SPC and `sgml-specials' keys \"electrically\" when non-nil.
+This takes effect when first loading the sgml-mode library.")
 
 
 (defvar sgml-mode-map
@@ -121,15 +135,17 @@ This takes effect when first loading the library.")
   "Syntax table used in SGML mode.  See also `sgml-specials'.")
 
 
-(defvar sgml-name-8bit-mode nil
-  "*When non-`nil' insert 8 bit characters with their names.")
+(defcustom sgml-name-8bit-mode nil
+  "*When non-nil, insert 8 bit characters with their names."
+  :type 'boolean
+  :group 'sgml)
 
 (defvar sgml-char-names
   [nil nil nil nil nil nil nil nil
    nil nil nil nil nil nil nil nil
    nil nil nil nil nil nil nil nil
    nil nil nil nil nil nil nil nil
-   "ensp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
+   "nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
    "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
    nil nil nil nil nil nil nil nil
    nil nil "colon" "semi" "lt" "eq" "gt" "quest"
@@ -165,10 +181,12 @@ This takes effect when first loading the library.")
 ;; Its error messages can be parsed by next-error.
 ;; The -s option suppresses output.
 
-(defvar sgml-validate-command "sgmls -s"
+(defcustom sgml-validate-command "sgmls -s"
   "*The command to validate an SGML document.
 The file name of current buffer file name will be appended to this,
-separated by a space.")
+separated by a space."
+  :type 'string
+  :group 'sgml)
 
 (defvar sgml-saved-validate-command nil
   "The command last used to validate in this buffer.")
@@ -176,19 +194,22 @@ separated by a space.")
 
 ;;; I doubt that null end tags are used much for large elements,
 ;;; so use a small distance here.
-(defconst sgml-slash-distance 1000
-  "*If non-nil, is the maximum distance to search for matching /.")
+(defcustom sgml-slash-distance 1000
+  "*If non-nil, is the maximum distance to search for matching `/'."
+  :type '(choice (const nil) integer)
+  :group 'sgml)
 
 (defconst sgml-start-tag-regex
   "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
   "Regular expression that matches a non-empty start tag.
-Any terminating > or / is not matched.")
+Any terminating `>' or `/' is not matched.")
 
 
 (defvar sgml-font-lock-keywords
   '(("<\\([!?][a-z0-9]+\\)" 1 font-lock-keyword-face)
     ("<\\(/?[a-z0-9]+\\)" 1 font-lock-function-name-face)
-    ("[&%][-.A-Za-z0-9]+;?" . font-lock-variable-name-face))
+    ("[&%][-.A-Za-z0-9]+;?" . font-lock-variable-name-face)
+    ("<!--[^<>]*-->" . font-lock-comment-face))
   "*Rules for highlighting SGML code.  See also `sgml-tag-face-alist'.")
 
 ;; internal
@@ -210,7 +231,7 @@ When more these are fontified together with `sgml-font-lock-keywords'.")
 (defvar sgml-tags-invisible nil)
 
 
-(defvar sgml-tag-alist
+(defcustom sgml-tag-alist
   '(("![" ("ignore" t) ("include" t))
     ("!attlist")
     ("!doctype")
@@ -233,28 +254,22 @@ The attribute alist is made up as
    ...)
 
 ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by
-an optional alist of possible values.")
+an optional alist of possible values."
+  :type '(repeat (cons (string :tag "Tag Name")
+                      (repeat :tag "Tag Rule" sexp)))
+  :group 'sgml)
 
-(defvar sgml-tag-help
+(defcustom sgml-tag-help
   '(("!" . "Empty declaration for comment")
     ("![" . "Embed declarations with parser directive")
     ("!attlist" . "Tag attributes declaration")
     ("!doctype" . "Document type (DTD) declaration")
     ("!element" . "Tag declaration")
     ("!entity" . "Entity (macro) declaration"))
-  "*Alist of tag name and short description.")
-
-
-;; put read-only last to enable setting this even when read-only enabled
-(or (get 'sgml-tag 'invisible)
-    (setplist 'sgml-tag
-             (append '(invisible t
-                       rear-nonsticky t
-                       point-entered sgml-point-entered
-                       read-only t)
-                     (symbol-plist 'sgml-tag))))
-
-
+  "*Alist of tag name and short description."
+  :type '(repeat (cons (string :tag "Tag Name")
+                      (string :tag "Description")))
+  :group 'sgml)
 
 (defun sgml-mode-common (sgml-tag-face-alist sgml-display-text)
   "Common code for setting up `sgml-mode' and derived modes.
@@ -288,22 +303,24 @@ varables of same name)."
              `((1 (,(concat "<\\("
                             (mapconcat 'car sgml-tag-face-alist "\\|")
                             "\\)\\([ \t].+\\)?>\\(.+\\)</\\1>")
-                   3 (cdr (assoc (match-string 1) ',sgml-tag-face-alist)))))))
+                   3 (cdr (assoc (downcase (match-string 1))
+                                  ',sgml-tag-face-alist)))))))
   (setq indent-line-function 'indent-relative-maybe
        ;; A start or end tag by itself on a line separates a paragraph.
        ;; This is desirable because SGML discards a newline that appears
        ;; immediately after a start tag or immediately before an end tag.
-       paragraph-start "^[ \t\n]\\|\
-\\(</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$\\)"
-       paragraph-separate "^[ \t\n]*$\\|\
-^</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$"
+       paragraph-separate "[ \t]*$\\|\
+\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$"
+       paragraph-start "[ \t]*$\\|\
+\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$"
+       adaptive-fill-regexp "[ \t]*"
        comment-start "<!-- "
        comment-end " -->"
        comment-indent-function 'sgml-comment-indent
        ;; This will allow existing comments within declarations to be
        ;; recognized.
        comment-start-skip "--[ \t]*"
-       skeleton-transformation 'identity
+       skeleton-transformation sgml-transformation
        skeleton-further-elements '((completion-ignore-case t))
        skeleton-end-hook (lambda ()
                            (or (eolp)
@@ -315,13 +332,7 @@ varables of same name)."
                              sgml-font-lock-keywords-1)
                             nil
                             t)
-       facemenu-add-face-function
-         (lambda (face end)
-           (if (setq face (cdr (assq face sgml-face-tag-alist)))
-               (progn
-                 (setq facemenu-end-add-face (concat "</" face ">"))
-                 (concat "<" face ">"))
-             (error "Face not configured for %s mode." mode-name))))
+       facemenu-add-face-function 'sgml-mode-facemenu-add-face-function)
   (while sgml-display-text
     (put (car (car sgml-display-text)) 'before-string
         (cdr (car sgml-display-text)))
@@ -329,6 +340,15 @@ varables of same name)."
   (run-hooks 'text-mode-hook 'sgml-mode-hook))
 
 
+(defun sgml-mode-facemenu-add-face-function (face end)
+  (if (setq face (cdr (assq face sgml-face-tag-alist)))
+      (progn
+       (setq face (funcall skeleton-transformation face))
+       (setq facemenu-end-add-face (concat "</" face ">"))
+       (concat "<" face ">"))
+    (error "Face not configured for %s mode." mode-name)))
+
+
 ;;;###autoload
 (defun sgml-mode (&optional function)
   "Major mode for editing SGML documents.
@@ -336,12 +356,25 @@ Makes > match <.  Makes / blink matching /.
 Keys <, &, SPC within <>, \" and ' can be electric depending on
 `sgml-quick-keys'.
 
-Do \\[describe-variable] sgml- SPC to see available variables.
+An argument of N to a tag-inserting command means to wrap it around
+the next N words.  In Transient Mark mode, when the mark is active,
+N defaults to -1, which means to wrap it around the current region.
+
+If you like upcased tags, put (setq sgml-transformation 'upcase) in
+your `.emacs' file.
 
 Use \\[sgml-validate] to validate your document with an SGML parser.
+
+Do \\[describe-variable] sgml- SPC to see available variables.
+Do \\[describe-key] on the following bindings to discover what they do.
 \\{sgml-mode-map}"
   (interactive)
   (sgml-mode-common sgml-tag-face-alist sgml-display-text)
+  ;; Set imenu-generic-expression here, rather than in sgml-mode-common,
+  ;; because this definition probably is not useful in HTML mode.
+  (make-local-variable 'imenu-generic-expression)
+  (setq imenu-generic-expression
+       "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)")
   (use-local-map sgml-mode-map)
   (setq mode-name "SGML"
        major-mode 'sgml-mode))
@@ -360,9 +393,9 @@ Use \\[sgml-validate] to validate your document with an SGML parser.
 
 
 (defun sgml-slash (arg)
-  "Insert / and display any previous matching /.
-Two /s are treated as matching if the first / ends a net-enabling
-start tag, and the second / is the corresponding null end tag."
+  "Insert `/' and display any previous matching `/'.
+Two `/'s are treated as matching if the first `/' ends a net-enabling
+start tag, and the second `/' is the corresponding null end tag."
   (interactive "p")
   (insert-char ?/ arg)
   (if (> arg 0)
@@ -410,7 +443,7 @@ or M-- for a soft hyphen."
   (interactive "*")
   (insert ?&)
   (or char
-      (setq char (read-quoted-char)))
+      (setq char (read-quoted-char "Enter char or octal number")))
   (delete-backward-char 1)
   (insert char)
   (undo-boundary)
@@ -438,19 +471,26 @@ or M-- for a soft hyphen."
 (defun sgml-name-8bit-mode ()
   "Toggle insertion of 8 bit characters."
   (interactive)
-  (setq sgml-name-8bit-mode (not sgml-name-8bit-mode)))
+  (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
+  (message "sgml name 8 bit mode  is now %"
+          (if sgml-name-8bit-mode "ON" "OFF")))
 
 
+;; When an element of a skeleton is a string "str", it is passed
+;; through skeleton-transformation and inserted.  If "str" is to be
+;; inserted literally, one should obtain it as the return value of a
+;; function, e.g. (identity "str").
 
 (define-skeleton sgml-tag
-  "Insert a tag you are prompted for, optionally with attributes.
-Completion and configuration is according to `sgml-tag-alist'.
-If you like tags and attributes in uppercase set `skeleton-transformation'
-to `upcase'."
+  "Prompt for a tag and insert it, optionally with attributes.
+Completion and configuration are done according to `sgml-tag-alist'.
+If you like tags and attributes in uppercase do \\[set-variable]
+skeleton-transformation RET upcase RET, or put this in your `.emacs':
+  (setq sgml-transformation 'upcase)"
   (funcall skeleton-transformation
           (completing-read "Tag: " sgml-tag-alist))
   ?< (setq v1 (eval str)) |
-  (("") -1 '(undo-boundary) "&lt;") |
+  (("") -1 '(undo-boundary) (identity "&lt;")) |       ; see comment above
   (("") '(setq v2 (sgml-attributes v1 t)) ?>
    (if (string= "![" v1)
        (prog1 '(("") " [ " _ " ]]")
@@ -468,14 +508,17 @@ to `upcase'."
 
 (autoload 'skeleton-read "skeleton")
 
-(defun sgml-attributes (alist &optional quiet)
-  "When at toplevel of a tag, interactively insert attributes."
+(defun sgml-attributes (tag &optional quiet)
+  "When at top level of a tag, interactively insert attributes.
+
+Completion and configuration of TAG are done according to `sgml-tag-alist'.
+If QUIET, do not print a message when there are no attributes for TAG."
   (interactive (list (save-excursion (sgml-beginning-of-tag t))))
-  (or (stringp alist) (error "Wrong context for adding attribute"))
-  (if alist
+  (or (stringp tag) (error "Wrong context for adding attribute"))
+  (if tag
       (let ((completion-ignore-case t)
+           (alist (cdr (assoc (downcase tag) sgml-tag-alist)))
            car attribute i)
-       (setq alist (cdr (assoc (downcase alist) sgml-tag-alist)))
        (if (or (symbolp (car alist))
                (symbolp (car (car alist))))
            (setq car (car alist)
@@ -484,7 +527,8 @@ to `upcase'."
            (message "No attributes configured."))
        (if (stringp (car alist))
            (progn
-             (insert (if (eq (preceding-char) ? ) "" ? ) (car alist))
+             (insert (if (eq (preceding-char) ? ) "" ? )
+                     (funcall skeleton-transformation (car alist)))
              (sgml-value alist))
          (setq i (length alist))
          (while (> i 0)
@@ -492,19 +536,19 @@ to `upcase'."
            (insert (funcall skeleton-transformation
                             (setq attribute
                                   (skeleton-read '(completing-read
-                                                   "[Attribute]: "
+                                                   "Attribute: "
                                                    alist)))))
            (if (string= "" attribute)
                (setq i 0)
-             (sgml-value (assoc attribute alist))
+             (sgml-value (assoc (downcase attribute) alist))
              (setq i (1- i))))
          (if (eq (preceding-char) ? )
              (delete-backward-char 1)))
        car)))
 
 (defun sgml-auto-attributes (arg)
-  "Self insert, except, when at top level of tag, prompt for attributes.
-With prefix ARG only self insert."
+  "Self insert the character typed; at top level of tag, prompt for attributes.
+With prefix argument, only self insert."
   (interactive "*P")
   (let ((point (point))
        tag)
@@ -520,7 +564,7 @@ With prefix ARG only self insert."
 
 
 (defun sgml-tag-help (&optional tag)
-  "Display description of optional TAG or tag at point."
+  "Display description of tag TAG.  If TAG is omitted, use the tag at point."
   (interactive)
   (or tag
       (save-excursion
@@ -531,9 +575,9 @@ With prefix ARG only self insert."
       (error "No tag selected"))
   (setq tag (downcase tag))
   (message "%s"
-          (or (cdr (assoc tag sgml-tag-help))
+          (or (cdr (assoc (downcase tag) sgml-tag-help))
               (and (eq (aref tag 0) ?/)
-                   (cdr (assoc (substring tag 1) sgml-tag-help)))
+                   (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
               "No description available")))
 
 
@@ -554,7 +598,7 @@ With prefix ARG only self insert."
 
 (defun sgml-skip-tag-backward (arg)
   "Skip to beginning of tag or matching opening tag if present.
-With prefix ARG, repeat that many times."
+With prefix argument ARG, repeat this ARG times."
   (interactive "p")
   (while (>= arg 1)
     (search-backward "<" nil t)
@@ -570,7 +614,7 @@ With prefix ARG, repeat that many times."
 
 (defun sgml-skip-tag-forward (arg &optional return)
   "Skip to end of tag or matching closing tag if present.
-With prefix ARG, repeat that many times.
+With prefix argument ARG, repeat this ARG times.
 Return t iff after a closing tag."
   (interactive "p")
   (setq return t)
@@ -601,7 +645,7 @@ Return t iff after a closing tag."
 
 (defun sgml-delete-tag (arg)
   "Delete tag on or after cursor, and matching closing or opening tag.
-With prefix ARG, repeat that many times."
+With prefix argument ARG, repeat this ARG times."
   (interactive "p")
   (while (>= arg 1)
     (save-excursion
@@ -641,18 +685,28 @@ With prefix ARG, repeat that many times."
        (goto-char open)
        (kill-sexp 1)))
     (setq arg (1- arg))))
-
-
+\f
+;; Put read-only last to enable setting this even when read-only enabled.
+(or (get 'sgml-tag 'invisible)
+    (setplist 'sgml-tag
+             (append '(invisible t
+                       intangible t
+                       point-entered sgml-point-entered
+                       rear-nonsticky t
+                       read-only t)
+                     (symbol-plist 'sgml-tag))))
 
 (defun sgml-tags-invisible (arg)
   "Toggle visibility of existing tags."
   (interactive "P")
   (let ((modified (buffer-modified-p))
        (inhibit-read-only t)
-       (point (point-min))
+       ;; This is needed in case font lock gets called,
+       ;; since it moves point and might call sgml-point-entered.
+       (inhibit-point-motion-hooks t)
        symbol)
     (save-excursion
-      (goto-char point)
+      (goto-char (point-min))
       (if (setq sgml-tags-invisible
                (if arg
                    (>= (prefix-numeric-value arg) 0)
@@ -666,12 +720,12 @@ With prefix ARG, repeat that many times."
                 (overlay-put (make-overlay (point)
                                            (match-beginning 1))
                              'category symbol))
-           (put-text-property (setq point (point)) (forward-list)
-                              'intangible (point))                     
-           (put-text-property point (point)
+           (put-text-property (point)
+                              (progn (forward-list) (point))
                               'category 'sgml-tag))
-       (while (< (setq point (next-overlay-change point)) (point-max))
-         (delete-overlay (car (overlays-at point))))
+       (let ((pos (point)))
+         (while (< (setq pos (next-overlay-change pos)) (point-max))
+           (delete-overlay (car (overlays-at pos)))))
        (remove-text-properties (point-min) (point-max)
                                '(category sgml-tag intangible t))))
     (set-buffer-modified-p modified)
@@ -691,14 +745,13 @@ With prefix ARG, repeat that many times."
                             (eq (preceding-char) ?>)))
                    (backward-list)
                  (forward-list)))))))
-
-
+\f
 (autoload 'compile-internal "compile")
 
 (defun sgml-validate (command)
   "Validate an SGML document.
 Runs COMMAND, a shell command, in a separate process asynchronously
-with output going to the buffer *compilation*.
+with output going to the buffer `*compilation*'.
 You can then use the command \\[next-error] to find the next error message
 and move to the line in the SGML document that caused it."
   (interactive
@@ -710,12 +763,15 @@ and move to the line in the SGML document that caused it."
                                    (and name
                                         (file-name-nondirectory name))))))))
   (setq sgml-saved-validate-command command)
+  (if (or (not compilation-ask-about-save)
+         (y-or-n-p (message "Save buffer %s? " (buffer-name))))
+      (save-buffer))
   (compile-internal command "No more errors"))
 
 
 (defun sgml-beginning-of-tag (&optional top-level)
   "Skip to beginning of tag and return its name.
-Else `t'."
+If this can't be done, return t."
   (or (if top-level
          (condition-case nil
              (up-list -1)
@@ -733,6 +789,8 @@ Else `t'."
        t)))
 
 (defun sgml-value (alist)
+  "Interactively insert value taken from attributerule ALIST.
+See `sgml-tag-alist' for info about attributerules.."
   (setq alist (cdr alist))
   (if (stringp (car alist))
       (insert "=\"" (car alist) ?\")
@@ -741,37 +799,36 @@ Else `t'."
            (progn
              (insert "=\"")
              (setq alist (skeleton-read '(completing-read
-                                          "[Value]: " (cdr alist))))
+                                          "Value: " (cdr alist))))
              (if (string< "" alist)
-                 (insert (funcall skeleton-transformation alist) ?\")
+                 (insert alist ?\")
                (delete-backward-char 2))))
       (insert "=\"")
       (if alist
-         (insert (funcall skeleton-transformation
-                          (skeleton-read '(completing-read "Value: " alist)))))
+         (insert (skeleton-read '(completing-read "Value: " alist))))
       (insert ?\"))))
 
 (provide 'sgml-mode)
 \f
 (defvar html-quick-keys sgml-quick-keys
-    "Use C-c X combinations for quick insertion of frequent tags when non-nil.
+  "Use C-c X combinations for quick insertion of frequent tags when non-nil.
 This defaults to `sgml-quick-keys'.
 This takes effect when first loading the library.")
 
 (defvar html-mode-map
   (let ((map (nconc (make-sparse-keymap) sgml-mode-map))
        (menu-map (make-sparse-keymap "HTML")))
-    (define-key map "\C-c6" 'html-headline)
-    (define-key map "\C-c5" 'html-headline)
-    (define-key map "\C-c4" 'html-headline)
-    (define-key map "\C-c3" 'html-headline)
-    (define-key map "\C-c2" 'html-headline)
-    (define-key map "\C-c1" 'html-headline)
+    (define-key map "\C-c6" 'html-headline-6)
+    (define-key map "\C-c5" 'html-headline-5)
+    (define-key map "\C-c4" 'html-headline-4)
+    (define-key map "\C-c3" 'html-headline-3)
+    (define-key map "\C-c2" 'html-headline-2)
+    (define-key map "\C-c1" 'html-headline-1)
     (define-key map "\C-c\r" 'html-paragraph)
     (define-key map "\C-c\n" 'html-line)
     (define-key map "\C-c\C-c-" 'html-horizontal-rule)
-    (define-key map "\C-c\C-co" 'html-list)
-    (define-key map "\C-c\C-cu" 'html-list)
+    (define-key map "\C-c\C-co" 'html-ordered-list)
+    (define-key map "\C-c\C-cu" 'html-unordered-list)
     (define-key map "\C-c\C-cr" 'html-radio-buttons)
     (define-key map "\C-c\C-cc" 'html-checkboxes)
     (define-key map "\C-c\C-cl" 'html-list-item)
@@ -781,8 +838,8 @@ This takes effect when first loading the library.")
     (if html-quick-keys
        (progn
          (define-key map "\C-c-" 'html-horizontal-rule)
-         (define-key map "\C-co" 'html-list)
-         (define-key map "\C-cu" 'html-list)
+         (define-key map "\C-co" 'html-ordered-list)
+         (define-key map "\C-cu" 'html-unordered-list)
          (define-key map "\C-cr" 'html-radio-buttons)
          (define-key map "\C-cc" 'html-checkboxes)
          (define-key map "\C-cl" 'html-list-item)
@@ -797,17 +854,17 @@ This takes effect when first loading the library.")
     (define-key menu-map [browse-url-of-buffer]
       '("View Buffer Contents" . browse-url-of-buffer))
     (define-key menu-map [nil] '("--"))
-    ;;(define-key menu-map "6" '("Heading 6" . html-headline))
-    ;;(define-key menu-map "5" '("Heading 5" . html-headline))
-    ;;(define-key menu-map "4" '("Heading 4" . html-headline))
-    (define-key menu-map "3" '("Heading 3" . html-headline))
-    (define-key menu-map "2" '("Heading 2" . html-headline))
-    (define-key menu-map "1" '("Heading 1" . html-headline))
+    ;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
+    ;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
+    ;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
+    (define-key menu-map "3" '("Heading 3" . html-headline-3))
+    (define-key menu-map "2" '("Heading 2" . html-headline-2))
+    (define-key menu-map "1" '("Heading 1" . html-headline-1))
     (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
     (define-key menu-map "c" '("Checkboxes" . html-checkboxes))
     (define-key menu-map "l" '("List Item" . html-list-item))
-    (define-key menu-map "u" '("Unordered List" . html-list))
-    (define-key menu-map "o" '("Ordered List" . html-list))
+    (define-key menu-map "u" '("Unordered List" . html-unordered-list))
+    (define-key menu-map "o" '("Ordered List" . html-ordered-list))
     (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
     (define-key menu-map "\n" '("Line Break" . html-line))
     (define-key menu-map "\r" '("Paragraph" . html-paragraph))
@@ -858,8 +915,8 @@ This takes effect when first loading the library.")
 
 ; should code exactly HTML 3 here when that is finished
 (defvar html-tag-alist
-  (let* ((1-9 '(("8") ("9")
-               ("1") ("2") ("3") ("4") ("5") ("6") ("7")))
+  (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
+        (1-9 '(,@1-7 ("8") ("9")))
         (align '(("align" ("left") ("center") ("right"))))
         (valign '(("top") ("middle") ("bottom") ("baseline")))
         (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
@@ -871,10 +928,8 @@ This takes effect when first loading the library.")
                 ("rel" ,@rel)
                 ("rev" ,@rel)
                 ("title")))
-        (list '((nil \n
-                     ( "List item: "
-                       "<li>" str \n))
-                ("type" ("A") ("a") ("I") ("i") ("1"))))
+        (list '((nil \n ( "List item: "
+                          "<li>" str \n))))
         (cell `(t
                 ,align
                 ("valign" ,@valign)
@@ -886,7 +941,7 @@ This takes effect when first loading the library.")
     `(("a" ,name ,@link)
       ("base" t ,@href)
       ("dir" ,@list)
-      ("font" "size" ("-1") ("+1") ("-2") ("+2") ,@(cdr (cdr 1-9)))
+      ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
       ("form" (\n _ \n "<input type=\"submit\" value=\"\">")
        ("action" ,@(cdr href)) ("method" ("get") ("post")))
       ("h1" ,@align)
@@ -905,7 +960,7 @@ This takes effect when first loading the library.")
        ("value"))
       ("link" t ,@link)
       ("menu" ,@list)
-      ("ol" ,@list)
+      ("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1")))
       ("p" t ,@align)
       ("select" (nil \n
                     ("Text: "
@@ -919,7 +974,7 @@ This takes effect when first loading the library.")
       ("td" ,@cell)
       ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
       ("th" ,@cell)
-      ("ul" ,@list)
+      ("ul" ,@list ("type" ("disc") ("circle") ("square")))
 
       ,@sgml-tag-alist
 
@@ -950,14 +1005,14 @@ This takes effect when first loading the library.")
                   "<dt>" str "<dd>" _ \n)))
       ("dt" (t _ "<dd>"))
       ("em")
-      ("fn" "id" "fn")
+      ;("fn" "id" "fn")  ; ???
       ("head" \n)
       ("html" (\n
               "<head>\n"
               "<title>" (setq str (read-input "Title: ")) "</title>\n"
               "<body>\n<h1>" str "</h1>\n" _
               "\n<address>\n<a href=\"mailto:"
-              (user-login-name) ?@ (system-name)
+              user-mail-address
               "\">" (user-full-name) "</a>\n</address>"))
       ("i")
       ("ins")
@@ -1020,7 +1075,7 @@ This takes effect when first loading the library.")
     ("figa" . "Figure anchor")
     ("figd" . "Figure description")
     ("figt" . "Figure text")
-    ("fn" . "?")
+    ;("fn" . "?")  ; ???
     ("font" . "Font size")
     ("form" . "Form with input fields")
     ("group" . "Document grouping")
@@ -1107,15 +1162,15 @@ Edit/Text Properties/Face commands.
 Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
 to them with <a href=\"#SOMENAME\">see also somename</a>.  In the same way <a
 href=\"URL\">see also URL</a> where URL is a filename relative to current
-directory or something like http://www.cs.indiana.edu/elisp/w3/docs.html.
+directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'.
 
 Images in many formats can be inlined with <img src=\"URL\">.
 
-If you mainly create your own documents, `sgml-specials' might be interesting.
-But note that some HTML 2 browsers can't handle &apos;.  To work around that
-do:
+If you mainly create your own documents, `sgml-specials' might be
+interesting.  But note that some HTML 2 browsers can't handle `&apos;'.
+To work around that, do:
+   (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
 
-\(eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
 \\{html-mode-map}"
   (interactive)
   (sgml-mode-common html-tag-face-alist html-display-text)
@@ -1126,6 +1181,9 @@ do:
   (make-local-variable 'outline-regexp)
   (make-local-variable 'outline-heading-end-regexp)
   (make-local-variable 'outline-level)
+  (make-local-variable 'sentence-end)
+  (setq sentence-end
+       "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\|  \\)[ \t\n]*")
   (setq mode-name "HTML"
         major-mode 'html-mode
        sgml-tag-alist html-tag-alist
@@ -1140,18 +1198,44 @@ do:
 
 (define-skeleton html-href-anchor
   "HTML anchor tag with href attribute."
-  nil
-  "<a href=\"http:" _ "\"></a>")
+  "URL: "
+  '(setq input "http:")
+  "<a href=\"" str "\">" _ "</a>")
 
 (define-skeleton html-name-anchor
   "HTML anchor tag with name attribute."
+  "Name: "
+  "<a name=\"" str "\">" _ "</a>")
+
+(define-skeleton html-headline-1
+  "HTML level 1 headline tags."
   nil
-  "<a name=\"" _ "\"></a>")
+  "<h1>" _ "</h1>")
 
-(define-skeleton html-headline
-  "HTML headline tags."
-  last-command-char
-  "<h" str ?> _ "</h" str ?>)
+(define-skeleton html-headline-2
+  "HTML level 2 headline tags."
+  nil
+  "<h2>" _ "</h2>")
+
+(define-skeleton html-headline-3
+  "HTML level 3 headline tags."
+  nil
+  "<h3>" _ "</h3>")
+
+(define-skeleton html-headline-4
+  "HTML level 4 headline tags."
+  nil
+  "<h4>" _ "</h4>")
+
+(define-skeleton html-headline-5
+  "HTML level 5 headline tags."
+  nil
+  "<h5>" _ "</h5>")
+
+(define-skeleton html-headline-6
+  "HTML level 6 headline tags."
+  nil
+  "<h6>" _ "</h6>")
 
 (define-skeleton html-horizontal-rule
   "HTML horizontal rule tag."
@@ -1161,19 +1245,26 @@ do:
 (define-skeleton html-image
   "HTML image tag."
   nil
-  "<img src=\"http:" _ "\">")
+  "<img src=\"" _ "\">")
 
 (define-skeleton html-line
   "HTML line break tag."
   nil
   "<br>" \n)
 
-(define-skeleton html-list
-  "HTML unordered/ordered list tags."
-  last-command-char
-  ?< str "l>" \n
+(define-skeleton html-ordered-list
+  "HTML ordered list tags."
+  nil
+  "<ol>" \n
+  "<li>" _ \n
+  "</ol>")
+
+(define-skeleton html-unordered-list
+  "HTML unordered list tags."
+  nil
+  "<ul>" \n
   "<li>" _ \n
-  "</" str "l>")
+  "</ul>")
 
 (define-skeleton html-list-item
   "HTML list item tag."
@@ -1190,24 +1281,36 @@ do:
 (define-skeleton html-checkboxes
   "Group of connected checkbox inputs."
   nil
-  '(setq v1 (eval str))                        ; allow passing name as argument
-  ("Value & Text: "
-   "<input type=\"checkbox\" name=\""
-   (or v1 (setq v1 (skeleton-read "Name: ")))
+  '(setq v1 nil
+        v2 nil)
+  ("Value: "
+   "<input type=\"" (identity "checkbox") ; see comment above about identity
+   "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
    "\" value=\"" str ?\"
-   (if v2 "" " checked") ?> str
-   (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n))
+   (if (y-or-n-p "Set \"checked\" attribute? ")
+        (funcall skeleton-transformation " checked")) ">"
+   (skeleton-read "Text: " (capitalize str))
+   (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
+                      (funcall skeleton-transformation "<br>")
+                    "")))
+   \n))
 
 (define-skeleton html-radio-buttons
   "Group of connected radio button inputs."
   nil
-  '(setq v1 (eval str))                        ; allow passing name as argument
-  ("Value & Text: "
-   "<input type=\"radio\" name=\""
-   (or v1 (setq v1 (skeleton-read "Name: ")))
+  '(setq v1 nil
+        v2 (cons nil nil))
+  ("Value: "
+   "<input type=\"" (identity "radio") ; see comment above about identity
+   "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
    "\" value=\"" str ?\"
-   (if v2 "" " checked") ?> str
-   (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n))
+   (if (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
+       (funcall skeleton-transformation " checked") ">")
+   (skeleton-read "Text: " (capitalize str))
+   (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
+                              (funcall skeleton-transformation "<br>")
+                            "")))
+   \n))
 
 
 (defun html-autoview-mode (&optional arg)