Subject: [PATCH] Add HTML4 tags to HTML mode
From: Simen Heggestøyl <[email-masked]>
To: [email-masked]
Cc: Stefan Monnier <[email-masked]>
Date: Mon, 28 Mar 2016 13:59:15 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

The attached patch adds a bunch of HTML4 tags to `html-tag-alist' and
descriptions of those to `html-tag-help'.

This will benefit CSS mode in the future, since I'm planning to let it
use `html-tag-alist' to provide completion candidates for HTML tags in
CSS selectors.

-- Simen

From 17865a7df25d8482dcfd2f763386bb786c5b7a06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <[email-masked]>
Date: Sun, 27 Mar 2016 14:56:21 +0200
Subject: [PATCH] Add HTML4 tags to HTML mode

* lisp/textmodes/sgml-mode.el (html-tag-alist): Add HTML4 tags.
(html-tag-help): Add short descriptions of those tags.
---
 lisp/textmodes/sgml-mode.el | 82 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 74 insertions(+), 8 deletions(-)

diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index e6eb060..0937c00 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1779,11 +1779,12 @@ html-display-text
   "Value of `sgml-display-text' for HTML mode.")
 
 
-;; should code exactly HTML 3 here when that is finished
 (defvar html-tag-alist
   (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
 	 (1-9 `(,@1-7 ("8") ("9")))
 	 (align '(("align" ("left") ("center") ("right"))))
+         (ialign '(("align" ("top") ("middle") ("bottom") ("left")
+                    ("right"))))
 	 (valign '(("top") ("middle") ("bottom") ("baseline")))
 	 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
 	 (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
@@ -1796,16 +1797,26 @@ html-tag-alist
 		 ("title")))
 	 (list '((nil \n ("List item: " "<li>" str
                           (if sgml-xml-mode "</li>") \n))))
+         (shape '(("shape" ("rect") ("circle") ("poly") ("default"))))
 	 (cell `(t
 		 ,@align
 		 ("valign" ,@valign)
 		 ("colspan" ,@1-9)
 		 ("rowspan" ,@1-9)
-		 ("nowrap" t))))
+		 ("nowrap" t)))
+         (cellhalign '(("align" ("left") ("center") ("right")
+                        ("justify") ("char"))
+                       ("char") ("charoff")))
+         (cellvalign '(("valign" ("top") ("middle") ("bottom")
+                        ("baseline")))))
     ;; put ,-expressions first, else byte-compile chokes (as of V19.29)
     ;; and like this it's more efficient anyway
     `(("a" ,name ,@link)
+      ("area" t ,@shape ("coords") ("href") ("nohref" "nohref") ("alt")
+       ("tabindex") ("accesskey") ("onfocus") ("onblur"))
       ("base" t ,@href)
+      ("col" t ,@cellhalign ,@cellvalign ("span") ("width"))
+      ("colgroup" \n ,@cellhalign ,@cellvalign ("span") ("width"))
       ("dir" ,@list)
       ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
       ("form" (\n _ \n "<input type=\"submit\" value=\"\""
@@ -1818,6 +1829,9 @@ html-tag-alist
       ("h5" ,@align)
       ("h6" ,@align)
       ("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
+      ("iframe" \n ,@ialign ("longdesc") ("name") ("src")
+       ("frameborder" ("1") ("0")) ("marginwidth") ("marginheight")
+       ("scrolling" ("yes") ("no") ("auto")) ("height") ("width"))
       ("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
        ("src") ("alt") ("width" "1") ("height" "1")
        ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
@@ -1839,14 +1853,17 @@ html-tag-alist
 		     "<tr><" str ?> _
 		     (if sgml-xml-mode (concat "<" str "></tr>")) \n))
        ("border" t ,@1-9) ("width" "10") ("cellpadding"))
+      ("tbody" \n ,@cellhalign ,@cellvalign)
       ("td" ,@cell)
       ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
+      ("tfoot" \n ,@cellhalign ,@cellvalign)
       ("th" ,@cell)
+      ("thead" \n ,@cellhalign ,@cellvalign)
       ("ul" ,@list ("type" ("disc") ("circle") ("square")))
 
       ,@sgml-tag-alist
 
-      ("abbrev")
+      ("abbr")
       ("acronym")
       ("address")
       ("array" (nil \n
@@ -1856,19 +1873,24 @@ html-tag-alist
       ("aside" \n)
       ("au")
       ("b")
+      ("bdo" nil ("lang") ("dir" ("ltr") ("rtl")))
       ("big")
       ("blink")
-      ("blockquote" \n)
+      ("blockquote" \n ("cite"))
       ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
        ("link" "#") ("alink" "#") ("vlink" "#"))
       ("box" (nil _ "<over>" _ (if sgml-xml-mode "</over>")))
       ("br" t ("clear" ("left") ("right")))
+      ("button" nil ("name") ("value")
+       ("type" ("submit") ("reset") ("button"))
+       ("disabled" "disabled")
+       ("tabindex") ("accesskey") ("onfocus") ("onblur"))
       ("caption" ("valign" ("top") ("bottom")))
       ("center" \n)
       ("cite")
       ("code" \n)
       ("dd" ,(not sgml-xml-mode))
-      ("del")
+      ("del" nil ("cite") ("datetime"))
       ("dfn")
       ("div")
       ("dl" (nil \n
@@ -1878,8 +1900,13 @@ html-tag-alist
       ("dt" (t _ (if sgml-xml-mode "</dt>")
              "<dd>" (if sgml-xml-mode "</dd>") \n))
       ("em")
+      ("fieldset" \n)
       ("fn" "id" "fn")  ;; Footnotes were deprecated in HTML 3.2
       ("footer" \n)
+      ("frame" t ("longdesc") ("name") ("src")
+       ("frameborder" ("1") ("0")) ("marginwidth") ("marginheight")
+       ("noresize" "noresize") ("scrolling" ("yes") ("no") ("auto")))
+      ("frameset" \n ("rows") ("cols") ("onload") ("onunload"))
       ("head" \n)
       ("header" \n)
       ("hgroup" \n)
@@ -1894,22 +1921,37 @@ html-tag-alist
 	       "</body>"
 		))
       ("i")
-      ("ins")
+      ("ins" nil ("cite") ("datetime"))
       ("isindex" t ("action") ("prompt"))
       ("kbd")
+      ("label" nil ("for") ("accesskey") ("onfocus") ("onblur"))
       ("lang")
+      ("legend" nil ("accesskey"))
       ("li" ,(not sgml-xml-mode))
+      ("map" \n ("name"))
       ("math" \n)
+      ("meta" t ("http-equiv") ("name") ("content") ("scheme"))
       ("nav" \n)
       ("nobr")
+      ("noframes" \n)
+      ("noscript" \n)
+      ("object" \n ("declare" "declare") ("classid") ("codebase")
+       ("data") ("type") ("codetype") ("archive") ("standby")
+       ("height") ("width") ("usemap") ("name") ("tabindex"))
+      ("optgroup" \n ("name") ("size") ("multiple" "multiple")
+       ("disabled" "disabled") ("tabindex") ("onfocus") ("onblur")
+       ("onchange"))
       ("option" t ("value") ("label") ("selected" t))
       ("over" t)
+      ("param" t ("name") ("value")
+       ("valuetype" ("data") ("ref") ("object")) ("type"))
       ("person") ;; Tag for person's name tag deprecated in HTML 3.2
       ("pre" \n)
-      ("q")
+      ("q" nil ("cite"))
       ("rev")
       ("s")
       ("samp")
+      ("script" nil ("charset") ("type") ("src") ("defer" "defer"))
       ("section" \n)
       ("small")
       ("span" nil
@@ -1924,6 +1966,7 @@ html-tag-alist
 	 ("variable-name")
 	 ("warning")))
       ("strong")
+      ("style" \n ("type") ("media") ("title"))
       ("sub")
       ("sup")
       ("title")
@@ -1937,26 +1980,31 @@ html-tag-alist
 (defvar html-tag-help
   `(,@sgml-tag-help
     ("a" . "Anchor of point or link elsewhere")
-    ("abbrev" . "Abbreviation")
+    ("abbr" . "Abbreviation")
     ("acronym" . "Acronym")
     ("address" . "Formatted mail address")
+    ("area" . "Region of an image map")
     ("array" . "Math array")
     ("article" . "An independent part of document or site")
     ("aside" . "Secondary content related to surrounding content (e.g. page or article)")
     ("au" . "Author")
     ("b" . "Bold face")
     ("base" . "Base address for URLs")
+    ("bdo" . "Override text directionality")
     ("big" . "Font size")
     ("blink" . "Blinking text")
     ("blockquote" . "Indented quotation")
     ("body" . "Document body")
     ("box" . "Math fraction")
     ("br" . "Line break")
+    ("button" . "Clickable button")
     ("caption" . "Table caption")
     ("center" . "Centered text")
     ("changed" . "Change bars")
     ("cite" . "Citation of a document")
     ("code" . "Formatted source code")
+    ("col" . "Group of attribute specifications for table columns")
+    ("colgroup" . "Group of columns")
     ("dd" . "Definition of term")
     ("del" . "Deleted text")
     ("dfn" . "Defining instance of a term")
@@ -1966,6 +2014,7 @@ html-tag-help
     ("dt" . "Term to be defined")
     ("em" . "Emphasized")
     ("embed" . "Embedded data in foreign format")
+    ("fieldset" . "Group of related controls and labels")
     ("fig" . "Figure")
     ("figa" . "Figure anchor")
     ("figd" . "Figure description")
@@ -1974,6 +2023,8 @@ html-tag-help
     ("font" . "Font size")
     ("footer" . "Footer of a section")
     ("form" . "Form with input fields")
+    ("frame" . "Frame in which another HTML document can be displayed")
+    ("frameset" . "Container for frames")
     ("group" . "Document grouping")
     ("h1" . "Most important section headline")
     ("h2" . "Important section headline")
@@ -1987,44 +2038,59 @@ html-tag-help
     ("hr" . "Horizontal rule")
     ("html" . "HTML Document")
     ("i" . "Italic face")
+    ("iframe" . "Inline frame with a nested browsing context")
     ("img" . "Graphic image")
     ("input" . "Form input field")
     ("ins" . "Inserted text")
     ("isindex" . "Input field for index search")
     ("kbd" . "Keyboard example face")
+    ("label" . "Caption for a user interface item")
     ("lang" . "Natural language")
+    ("legend" . "Caption for a fieldset")
     ("li" . "List item")
     ("link" . "Link relationship")
+    ("map" . "Image map (a clickable link area")
     ("math" . "Math formula")
     ("menu" . "List of commands")
+    ("meta" . "Document properties")
     ("mh" . "Form mail header")
     ("nav" . "Group of navigational links")
     ("nextid" . "Allocate new id")
     ("nobr" . "Text without line break")
+    ("noframes" . "Content for user agents that don't support frames")
+    ("noscript" . "Alternate content for when a script isn't executed")
+    ("object" . "External resource")
     ("ol" . "Ordered list")
+    ("optgroup" . "Group of options")
     ("option" . "Selection list item")
     ("over" . "Math fraction rule")
     ("p" . "Paragraph start")
     ("panel" . "Floating panel")
+    ("param" . "Parameters for an object")
     ("person" . "Person's name")
     ("pre" . "Preformatted fixed width text")
     ("q" . "Quotation")
     ("rev" . "Reverse video")
     ("s" . "Strikeout")
     ("samp" . "Sample text")
+    ("script" . "Executable script within a document")
     ("section" . "Section of a document")
     ("select" . "Selection list")
     ("small" . "Font size")
     ("sp" . "Nobreak space")
     ("span" . "Generic inline container")
     ("strong" . "Standout text")
+    ("style" . "Style information")
     ("sub" . "Subscript")
     ("sup" . "Superscript")
     ("table" . "Table with rows and columns")
     ("tb" . "Table vertical break")
+    ("tbody" . "Table body")
     ("td" . "Table data cell")
     ("textarea" . "Form multiline edit area")
+    ("tfoot" . "Table foot")
     ("th" . "Table header cell")
+    ("thead" . "Table head")
     ("title" . "Document title")
     ("tr" . "Table row separator")
     ("tt" . "Typewriter face")
-- 
2.8.0.rc3