summaryrefslogtreecommitdiff
path: root/lisp/textmodes/sgml-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/sgml-mode.el')
-rw-r--r--lisp/textmodes/sgml-mode.el175
1 files changed, 156 insertions, 19 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 98a01e8d83f..990c09bfda7 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -842,6 +842,25 @@ Return non-nil if we skipped over matched tags."
(setq arg (1- arg)))
return))
+(defun sgml-forward-sexp (n)
+ ;; This function is needed in major-modes such as nxml-mode where
+ ;; forward-sexp-function is used to give a more dwimish behavior to
+ ;; the `forward-sexp' command.
+ ;; Without it, we can end up with backtraces like:
+ ;; "get-text-property" (0xffffc0f0)
+ ;; "nxml-token-after" (0xffffc2ac)
+ ;; "nxml-forward-single-balanced-item" (0xffffc46c)
+ ;; "nxml-forward-balanced-item" (0xffffc61c)
+ ;; "forward-sexp" (0xffffc7f8)
+ ;; "sgml-parse-tag-backward" (0xffffc9c8)
+ ;; "sgml-lexical-context" (0xffffcba8)
+ ;; "sgml-mode-flyspell-verify" (0xffffcd74)
+ ;; "flyspell-word" (0xffffcf3c)
+ ;; "flyspell-post-command-hook" (0xffffd108)
+ ;; FIXME: should we also set the sgml-tag-syntax-table?
+ (let ((forward-sexp-function nil))
+ (forward-sexp n)))
+
(defvar sgml-electric-tag-pair-overlays nil)
(defvar sgml-electric-tag-pair-timer nil)
@@ -862,11 +881,12 @@ Return non-nil if we skipped over matched tags."
(if endp
(when (sgml-skip-tag-backward 1) (forward-char 1) t)
(with-syntax-table sgml-tag-syntax-table
- (up-list -1)
- (when (sgml-skip-tag-forward 1)
- (backward-sexp 1)
- (forward-char 2)
- t))))
+ (let ((forward-sexp-function nil))
+ (up-list -1)
+ (when (sgml-skip-tag-forward 1)
+ (backward-sexp 1)
+ (forward-char 2)
+ t)))))
(clones (get-char-property (point) 'text-clones)))
(when (and match
(/= cl-end cl-start)
@@ -1066,9 +1086,9 @@ With prefix argument ARG, repeat this ARG times."
((and (eq (char-before) ?>)
(or (not (eq (char-after) ?<))
(> x y)))
- (backward-sexp))
+ (sgml-forward-sexp -1))
((eq (char-after y) ?<)
- (forward-sexp)))
+ (sgml-forward-sexp 1)))
(point))))
(message "Invisible tag: %s"
;; Strip properties, otherwise, the text is invisible.
@@ -1235,7 +1255,7 @@ You might want to turn on `auto-fill-mode' to get better results."
(unless (or ;;(looking-at "</")
(progn (skip-chars-backward " \t") (bolp)))
(reindent-then-newline-and-indent))
- (forward-sexp 1)))
+ (sgml-forward-sexp 1)))
;; (indent-region beg end)
))
@@ -1281,7 +1301,7 @@ Leave point at the beginning of the tag."
(let ((pos (point)))
(condition-case nil
;; FIXME: This does not correctly skip over PI an CDATA tags.
- (forward-sexp)
+ (sgml-forward-sexp 1)
(scan-error
;; This < seems to be just a spurious one, let's ignore it.
(goto-char pos)
@@ -1315,7 +1335,7 @@ Leave point at the beginning of the tag."
(with-syntax-table sgml-tag-syntax-table
(goto-char tag-end)
(condition-case nil
- (backward-sexp)
+ (sgml-forward-sexp -1)
(scan-error
;; This > isn't really the end of a tag. Skip it.
(goto-char (1- tag-end))
@@ -1540,7 +1560,7 @@ LCON is the lexical context, if any."
(`text
(while (looking-at "</")
- (forward-sexp 1)
+ (sgml-forward-sexp 1)
(skip-chars-forward " \t"))
(let* ((here (point))
(unclosed (and ;; (not sgml-xml-mode)
@@ -1759,11 +1779,12 @@ This takes effect when first loading the library.")
"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:")
@@ -1776,17 +1797,29 @@ This takes effect when first loading the library.")
("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)
+ ("figcaption")
+ ("figure" \n)
("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
("form" (\n _ \n "<input type=\"submit\" value=\"\""
(if sgml-xml-mode " />" ">"))
@@ -1798,6 +1831,9 @@ This takes effect when first loading the library.")
("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))
@@ -1819,14 +1855,17 @@ This takes effect when first loading the library.")
"<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
@@ -1835,20 +1874,33 @@ This takes effect when first loading the library.")
("article" \n)
("aside" \n)
("au")
+ ("audio" \n
+ ("src") ("crossorigin" ("anonymous") ("use-credentials"))
+ ("preload" ("none") ("metadata") ("auto"))
+ ("autoplay" "autoplay") ("mediagroup") ("loop" "loop")
+ ("muted" "muted") ("controls" "controls"))
("b")
+ ("bdi")
+ ("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"))
+ ("canvas" \n ("width") ("height"))
("caption" ("valign" ("top") ("bottom")))
("center" \n)
("cite")
("code" \n)
+ ("datalist" \n)
("dd" ,(not sgml-xml-mode))
- ("del")
+ ("del" nil ("cite") ("datetime"))
("dfn")
("div")
("dl" (nil \n
@@ -1858,8 +1910,14 @@ This takes effect when first loading the library.")
("dt" (t _ (if sgml-xml-mode "</dt>")
"<dd>" (if sgml-xml-mode "</dd>") \n))
("em")
+ ("embed" t ("src") ("type") ("width") ("height"))
+ ("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)
@@ -1874,24 +1932,49 @@ This takes effect when first loading the library.")
"</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))
+ ("main" \n)
+ ("map" \n ("name"))
+ ("mark")
("math" \n)
+ ("meta" t ("http-equiv") ("name") ("content") ("scheme"))
+ ("meter" nil ("value") ("min") ("max") ("low") ("high")
+ ("optimum"))
("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))
+ ("output" nil ("for") ("form") ("name"))
("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")
+ ("progress" nil ("value") ("max"))
+ ("q" nil ("cite"))
("rev")
+ ("rp" t)
+ ("rt" t)
+ ("ruby")
("s")
("samp")
+ ("script" nil ("charset") ("type") ("src") ("defer" "defer"))
("section" \n)
("small")
+ ("source" t ("src") ("type") ("media"))
("span" nil
("class"
("builtin")
@@ -1904,39 +1987,60 @@ This takes effect when first loading the library.")
("variable-name")
("warning")))
("strong")
+ ("style" \n ("type") ("media") ("title"))
("sub")
+ ("summary")
("sup")
+ ("time" nil ("datetime"))
("title")
("tr" t)
+ ("track" t
+ ("kind" ("subtitles") ("captions") ("descriptions")
+ ("chapters") ("metadata"))
+ ("src") ("srclang") ("label") ("default"))
("tt")
("u")
("var")
+ ("video" \n
+ ("src") ("crossorigin" ("anonymous") ("use-credentials"))
+ ("poster") ("preload" ("none") ("metadata") ("auto"))
+ ("autoplay" "autoplay") ("mediagroup") ("loop" "loop")
+ ("muted" "muted") ("controls" "controls") ("width") ("height"))
("wbr" t)))
"Value of `sgml-tag-alist' for HTML mode.")
(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")
+ ("audio" . "Sound or audio stream")
("b" . "Bold face")
("base" . "Base address for URLs")
+ ("bdi" . "Text isolated for bidirectional formatting")
+ ("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")
+ ("canvas" . "Script generated graphics canvas")
("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")
+ ("datalist" . "A set of predefined options")
("dd" . "Definition of term")
("del" . "Deleted text")
("dfn" . "Defining instance of a term")
@@ -1946,14 +2050,19 @@ This takes effect when first loading the library.")
("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")
+ ("figcaption" . "Caption for a figure")
("figd" . "Figure description")
("figt" . "Figure text")
+ ("figure" . "Self-contained content, often with a caption")
("fn" . "Footnote") ;; No one supports special footnote rendering.
("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")
@@ -1967,50 +2076,78 @@ This takes effect when first loading the library.")
("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")
+ ("main" . "Main content of the document body")
+ ("map" . "Image map (a clickable link area")
+ ("mark" . "Highlighted text")
("math" . "Math formula")
("menu" . "List of commands")
+ ("meta" . "Document properties")
+ ("meter" . "Scalar measurement within a known range")
("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")
+ ("output" . "Result of a calculation or user action")
("over" . "Math fraction rule")
("p" . "Paragraph start")
("panel" . "Floating panel")
+ ("param" . "Parameters for an object")
("person" . "Person's name")
("pre" . "Preformatted fixed width text")
+ ("progress" . "Completion progress of a task")
("q" . "Quotation")
("rev" . "Reverse video")
+ ("rp" . "Fallback text for when ruby annotations aren't supported")
+ ("rt" . "Ruby text component of a ruby annotation")
+ ("ruby" . "Ruby annotation")
("s" . "Strikeout")
("samp" . "Sample text")
+ ("script" . "Executable script within a document")
("section" . "Section of a document")
("select" . "Selection list")
("small" . "Font size")
+ ("source" . "Media resource for media elements")
("sp" . "Nobreak space")
("span" . "Generic inline container")
("strong" . "Standout text")
+ ("style" . "Style information")
("sub" . "Subscript")
+ ("summary" . "Summary, caption, or legend")
("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")
+ ("time" . "Content with optional machine-readable timestamp")
("title" . "Document title")
("tr" . "Table row separator")
+ ("track" . "Timed text track for media elements")
("tt" . "Typewriter face")
("u" . "Underlined text")
("ul" . "Unordered list")
("var" . "Math variable face")
+ ("video" . "Video or movie")
("wbr" . "Enable <br> within <nobr>"))
"Value of variable `sgml-tag-help' for HTML mode.")