1 ;;; sgml-mode.el --- SGML- and HTML-editing modes
3 ;; Copyright (C) 1992,95,96,98,2001 Free Software Foundation, Inc.
5 ;; Author: James Clark <jjc@jclark.com>
6 ;; Adapted-By: ESR, Daniel Pfeiffer <occitan@esperanto.org>,
7 ;; F.Potorti@cnuce.cnr.it
8 ;; Keywords: wp, hypermedia, comm, languages
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
29 ;; Configurable major mode for editing document in the SGML standard general
30 ;; markup language. As an example contains a mode for editing the derived
31 ;; HTML hypertext markup language.
43 (defcustom sgml-transformation 'identity
44 "*Default value for `skeleton-transformation' (which see) in SGML mode."
48 (put 'sgml-transformation 'variable-interactive
49 "aTransformation function: ")
51 (defcustom sgml-mode-hook nil
52 "Hook run by command `sgml-mode'.
53 `text-mode-hook' is run first."
57 ;; As long as Emacs' syntax can't be complemented with predicates to context
58 ;; sensitively confirm the syntax of characters, we have to live with this
59 ;; kludgy kind of tradeoff.
60 (defvar sgml-specials '(?\")
61 "List of characters that have a special meaning for SGML mode.
62 This list is used when first loading the sgml-mode library.
63 The supported characters and potential disadvantages are:
65 ?\\\" Makes \" in text start a string.
66 ?' Makes ' in text start a string.
67 ?- Makes -- in text start a comment.
69 When only one of ?\\\" or ?' are included, \"'\" or '\"', as can be found in
70 DTDs, start a string. To partially avoid this problem this also makes these
71 self insert as named entities depending on `sgml-quick-keys'.
73 Including ?- has the problem of affecting dashes that have nothing to do
74 with comments, so we normally turn it off.")
76 (defvar sgml-quick-keys nil
77 "Use <, >, &, SPC and `sgml-specials' keys \"electrically\" when non-nil.
78 This takes effect when first loading the sgml-mode library.")
82 (let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets.
83 (menu-map (make-sparse-keymap "SGML")))
84 (define-key map "\C-c\C-i" 'sgml-tags-invisible)
85 (define-key map "/" 'sgml-slash)
86 (define-key map "\C-c\C-n" 'sgml-name-char)
87 (define-key map "\C-c\C-t" 'sgml-tag)
88 (define-key map "\C-c\C-a" 'sgml-attributes)
89 (define-key map "\C-c\C-b" 'sgml-skip-tag-backward)
90 (define-key map [?\C-c left] 'sgml-skip-tag-backward)
91 (define-key map "\C-c\C-f" 'sgml-skip-tag-forward)
92 (define-key map [?\C-c right] 'sgml-skip-tag-forward)
93 (define-key map "\C-c\C-d" 'sgml-delete-tag)
94 (define-key map "\C-c\^?" 'sgml-delete-tag)
95 (define-key map "\C-c?" 'sgml-tag-help)
96 (define-key map "\C-c8" 'sgml-name-8bit-mode)
97 (define-key map "\C-c\C-v" 'sgml-validate)
99 (define-key map "&" 'sgml-name-char)
100 (define-key map "<" 'sgml-tag)
101 (define-key map " " 'sgml-auto-attributes)
102 (define-key map ">" 'sgml-maybe-end-tag)
103 (when (memq ?\" sgml-specials)
104 (define-key map "\"" 'sgml-name-self))
105 (when (memq ?' sgml-specials)
106 (define-key map "'" 'sgml-name-self)))
107 (define-key map (vector (make-char 'latin-iso8859-1))
108 'sgml-maybe-name-self)
111 (while (< (setq c (1+ c)) 256)
112 (aset map c 'sgml-maybe-name-self)))
113 (define-key map [menu-bar sgml] (cons "SGML" menu-map))
114 (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
115 (define-key menu-map [sgml-name-8bit-mode]
116 '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
117 (define-key menu-map [sgml-tags-invisible]
118 '("Toggle Tag Visibility" . sgml-tags-invisible))
119 (define-key menu-map [sgml-tag-help]
120 '("Describe Tag" . sgml-tag-help))
121 (define-key menu-map [sgml-delete-tag]
122 '("Delete Tag" . sgml-delete-tag))
123 (define-key menu-map [sgml-skip-tag-forward]
124 '("Forward Tag" . sgml-skip-tag-forward))
125 (define-key menu-map [sgml-skip-tag-backward]
126 '("Backward Tag" . sgml-skip-tag-backward))
127 (define-key menu-map [sgml-attributes]
128 '("Insert Attributes" . sgml-attributes))
129 (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
131 "Keymap for SGML mode. See also `sgml-specials'.")
134 (defvar sgml-mode-syntax-table
135 (let ((table (copy-syntax-table text-mode-syntax-table)))
136 (modify-syntax-entry ?< "(>" table)
137 (modify-syntax-entry ?> ")<" table)
138 (if (memq ?- sgml-specials)
139 (modify-syntax-entry ?- "_ 1234" table))
140 (if (memq ?\" sgml-specials)
141 (modify-syntax-entry ?\" "\"\"" table))
142 (if (memq ?' sgml-specials)
143 (modify-syntax-entry ?\' "\"'" table))
145 "Syntax table used in SGML mode. See also `sgml-specials'.")
148 (defcustom sgml-name-8bit-mode nil
149 "*When non-nil, insert non-ASCII characters as named entities."
153 (defvar sgml-char-names
154 [nil nil nil nil nil nil nil nil
155 nil nil nil nil nil nil nil nil
156 nil nil nil nil nil nil nil nil
157 nil nil nil nil nil nil nil nil
158 "nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
159 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
160 nil nil nil nil nil nil nil nil
161 nil nil "colon" "semi" "lt" "eq" "gt" "quest"
162 "commat" nil nil nil nil nil nil nil
163 nil nil nil nil nil nil nil nil
164 nil nil nil nil nil nil nil nil
165 nil nil nil "lsqb" nil "rsqb" "uarr" "lowbar"
166 "lsquo" nil nil nil nil nil nil nil
167 nil nil nil nil nil nil nil nil
168 nil nil nil nil nil nil nil nil
169 nil nil nil "lcub" "verbar" "rcub" "tilde" nil
170 nil nil nil nil nil nil nil nil
171 nil nil nil nil nil nil nil nil
172 nil nil nil nil nil nil nil nil
173 nil nil nil nil nil nil nil nil
174 "nbsp" "iexcl" "cent" "pound" "curren" "yen" "brvbar" "sect"
175 "uml" "copy" "ordf" "laquo" "not" "shy" "reg" "macr"
176 "ring" "plusmn" "sup2" "sup3" "acute" "micro" "para" "middot"
177 "cedil" "sup1" "ordm" "raquo" "frac14" "frac12" "frac34" "iquest"
178 "Agrave" "Aacute" "Acirc" "Atilde" "Auml" "Aring" "AElig" "Ccedil"
179 "Egrave" "Eacute" "Ecirc" "Euml" "Igrave" "Iacute" "Icirc" "Iuml"
180 "ETH" "Ntilde" "Ograve" "Oacute" "Ocirc" "Otilde" "Ouml" nil
181 "Oslash" "Ugrave" "Uacute" "Ucirc" "Uuml" "Yacute" "THORN" "szlig"
182 "agrave" "aacute" "acirc" "atilde" "auml" "aring" "aelig" "ccedil"
183 "egrave" "eacute" "ecirc" "euml" "igrave" "iacute" "icirc" "iuml"
184 "eth" "ntilde" "ograve" "oacute" "ocirc" "otilde" "ouml" "divide"
185 "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"]
186 "Vector of symbolic character names without `&' and `;'.")
188 (put 'sgml-table 'char-table-extra-slots 0)
190 (defvar sgml-char-names-table
191 (let ((table (make-char-table 'sgml-table))
195 (setq elt (aref sgml-char-names i))
196 (if elt (aset table (make-char 'latin-iso8859-1 i) elt))
199 "A table for mapping non-ASCII characters into SGML entity names.
200 Currently, only Latin-1 characters are supported.")
203 ;; nsgmls is a free SGML parser in the SP suite available from
204 ;; ftp.jclark.com and otherwise packaged for GNU systems.
205 ;; Its error messages can be parsed by next-error.
206 ;; The -s option suppresses output.
208 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
209 "*The command to validate an SGML document.
210 The file name of current buffer file name will be appended to this,
211 separated by a space."
216 (defvar sgml-saved-validate-command nil
217 "The command last used to validate in this buffer.")
220 ;; I doubt that null end tags are used much for large elements,
221 ;; so use a small distance here.
222 (defcustom sgml-slash-distance 1000
223 "*If non-nil, is the maximum distance to search for matching `/'."
224 :type '(choice (const nil) integer)
227 (defconst sgml-start-tag-regex
228 "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
229 "Regular expression that matches a non-empty start tag.
230 Any terminating `>' or `/' is not matched.")
234 (defconst sgml-font-lock-keywords-1
235 '(("<\\([!?][a-z][-.a-z0-9]*\\)" 1 font-lock-keyword-face)
236 ("<\\(/?[a-z][-.a-z0-9]*\\)" 1 font-lock-function-name-face)
237 ("[&%][a-z][-.a-z0-9]*;?" . font-lock-variable-name-face)))
239 (defconst sgml-font-lock-keywords-2
241 sgml-font-lock-keywords-1
244 (regexp-opt (mapcar 'car sgml-tag-face-alist) t)
245 "\\([ \t][^>]*\\)?>\\([^<]+\\)</\\1>")
246 '(3 (cdr (assoc (downcase (match-string 1))
247 sgml-tag-face-alist))))))))
249 ;; for font-lock, but must be defvar'ed after
250 ;; sgml-font-lock-keywords-1 and sgml-font-lock-keywords-2 above
251 (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
252 "*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
254 (defvar sgml-font-lock-syntactic-keywords
255 ;; Use the `b' style of comments to avoid interference with the -- ... --
256 ;; comments recognized when `sgml-specials' includes ?-.
257 ;; FIXME: beware of <!--> blabla <!--> !!
258 '(("\\(<\\)!--" (1 "< b"))
259 ("--[ \t\n]*\\(>\\)" (1 "> b")))
260 "Syntactic keywords for `sgml-mode'.")
263 (defvar sgml-face-tag-alist ()
264 "Alist of face and tag name for facemenu.")
266 (defvar sgml-tag-face-alist ()
267 "Tag names and face or list of faces to fontify with when invisible.
268 When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
269 When more these are fontified together with `sgml-font-lock-keywords'.")
272 (defvar sgml-display-text ()
273 "Tag names as lowercase symbols, and display string when invisible.")
276 (defvar sgml-tags-invisible nil)
279 (defcustom sgml-tag-alist
280 '(("![" ("ignore" t) ("include" t))
285 "*Alist of tag names for completing read and insertion rules.
286 This alist is made up as
291 TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by
292 newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor
293 followed by an ATTRIBUTERULE (for an always present attribute) or an
296 The attribute alist is made up as
298 ((\"attribute\" . ATTRIBUTERULE)
301 ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by
302 an optional alist of possible values."
303 :type '(repeat (cons (string :tag "Tag Name")
304 (repeat :tag "Tag Rule" sexp)))
307 (defcustom sgml-tag-help
308 '(("!" . "Empty declaration for comment")
309 ("![" . "Embed declarations with parser directive")
310 ("!attlist" . "Tag attributes declaration")
311 ("!doctype" . "Document type (DTD) declaration")
312 ("!element" . "Tag declaration")
313 ("!entity" . "Entity (macro) declaration"))
314 "*Alist of tag name and short description."
315 :type '(repeat (cons (string :tag "Tag Name")
316 (string :tag "Description")))
319 (defcustom sgml-xml nil
320 "*When non-nil, tag insertion functions will be XML-compliant.
321 If this variable is customized, the custom value is used always.
322 Otherwise, it is set to be buffer-local when the file has
323 a DOCTYPE or an XML declaration."
328 (defvar sgml-empty-tags nil
329 "List of tags whose !ELEMENT definition says EMPTY.")
331 (defun sgml-xml-guess ()
332 "Guess whether the current buffer is XML."
334 (goto-char (point-min))
335 (cond ((or (string= "xml" (file-name-extension (or buffer-file-name "")))
336 (looking-at "\\s-*<\\?xml"))
337 (set (make-local-variable 'sgml-xml) t))
341 '("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
342 "\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"")
345 (let ((name (match-string 1))
346 (pub (match-string 2))
347 (id (match-string 3))
348 (url (match-string 4)))
349 (cond ((string= name "html")
350 (set (make-local-variable 'sgml-xml)
351 (not (null (string-match "XHTML" id)))))
352 ((string-match "XML" id)
353 (set (make-local-variable 'sgml-xml) t))))))))
355 (defvar v2) ; free for skeleton
357 (defun sgml-mode-common ()
358 "Common code for setting up `sgml-mode' and derived modes."
359 (make-local-variable 'sgml-saved-validate-command)
360 (make-local-variable 'facemenu-end-add-face)
361 ;;(make-local-variable 'facemenu-remove-face-function)
362 (set (make-local-variable 'indent-line-function) 'indent-relative-maybe)
363 ;; A start or end tag by itself on a line separates a paragraph.
364 ;; This is desirable because SGML discards a newline that appears
365 ;; immediately after a start tag or immediately before an end tag.
366 (set (make-local-variable 'paragraph-separate) "[ \t]*$\\|\
367 \[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$")
368 (set (make-local-variable 'paragraph-start) "[ \t]*$\\|\
369 \[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>")
370 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
371 (set (make-local-variable 'comment-start) "<!-- ")
372 (set (make-local-variable 'comment-end) " -->")
373 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
374 (set (make-local-variable 'skeleton-transformation) sgml-transformation)
375 (set (make-local-variable 'skeleton-further-elements)
376 '((completion-ignore-case t)))
377 (set (make-local-variable 'skeleton-end-hook)
380 (not (or (eq v2 '\n) (eq (car-safe v2) '\n)))
381 (newline-and-indent))))
382 (set (make-local-variable 'font-lock-defaults)
383 '((sgml-font-lock-keywords
384 sgml-font-lock-keywords-1
385 sgml-font-lock-keywords-2)
387 (font-lock-syntactic-keywords
388 . sgml-font-lock-syntactic-keywords)))
389 (set (make-local-variable 'facemenu-add-face-function)
390 'sgml-mode-facemenu-add-face-function)
391 ;; `sgml-xml' not customized -- guess
392 (unless (get 'sgml-xml 'saved-value) (sgml-xml-guess))
393 ;; This will allow existing comments within declarations to be
395 (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
396 (set (make-local-variable 'comment-end-skip) "[ \t]*--\\([ \t\n]*>\\)?"))
399 (defun sgml-mode-facemenu-add-face-function (face end)
400 (if (setq face (cdr (assq face sgml-face-tag-alist)))
402 (setq face (funcall skeleton-transformation face))
403 (setq facemenu-end-add-face (concat "</" face ">"))
404 (concat "<" face ">"))
405 (error "Face not configured for %s mode" mode-name)))
409 (define-derived-mode sgml-mode text-mode "SGML"
410 "Major mode for editing SGML documents.
411 Makes > match <. Makes / blink matching /.
412 Keys <, &, SPC within <>, \" and ' can be electric depending on
415 An argument of N to a tag-inserting command means to wrap it around
416 the next N words. In Transient Mark mode, when the mark is active,
417 N defaults to -1, which means to wrap it around the current region.
419 If you like upcased tags, put (setq sgml-transformation 'upcase) in
422 Use \\[sgml-validate] to validate your document with an SGML parser.
424 Do \\[describe-variable] sgml- SPC to see available variables.
425 Do \\[describe-key] on the following bindings to discover what they do.
428 (when sgml-xml (setq mode-name "XML"))
429 ;; Set `imenu-generic-expression' here, rather than in `sgml-mode-common',
430 ;; because this definition probably is not useful in HTML mode.
431 (set (make-local-variable 'imenu-generic-expression)
432 "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)"))
435 (defun sgml-comment-indent ()
436 (if (looking-at "--") comment-column 0))
440 (defun sgml-slash (arg)
441 "Insert `/' and display any previous matching `/'.
442 Two `/'s are treated as matching if the first `/' ends a net-enabling
443 start tag, and the second `/' is the corresponding null end tag."
447 (let ((oldpos (point))
452 (if sgml-slash-distance
453 (narrow-to-region (max (point-min)
454 (- (point) sgml-slash-distance))
456 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
457 (eq (match-end 0) (1- oldpos)))
459 (goto-char (1- oldpos))
460 (while (and (not blinkpos)
461 (search-backward "/" (point-min) t))
462 (let ((tagend (save-excursion
463 (if (re-search-backward sgml-start-tag-regex
467 (if (eq tagend (point))
469 (setq blinkpos (point))
470 (setq level (1- level)))
471 (setq level (1+ level)))))))
474 (if (pos-visible-in-window-p)
476 (message "Matches %s"
477 (buffer-substring (line-beginning-position)
478 (1+ blinkpos)))))))))
481 (defun sgml-name-char (&optional char)
482 "Insert a symbolic character name according to `sgml-char-names'.
483 Non-ASCII chars may be inserted either with the meta key, as in M-SPC for
484 no-break space or M-- for a soft hyphen; or via an input method or
485 encoded keyboard operation."
489 (setq char (read-quoted-char "Enter char or octal number")))
490 (delete-backward-char 1)
493 (delete-backward-char 1)
497 (or (aref sgml-char-names char)
500 ((aref sgml-char-names-table char)
501 (insert ?& (aref sgml-char-names-table char) ?\;))
502 ((memq (char-charset char) '(mule-unicode-0100-24ff
503 mule-unicode-2500-33ff
504 mule-unicode-e000-ffff))
505 (insert (format "&#%d;" (encode-char char 'ucs))))
509 (defun sgml-name-self ()
510 "Insert a symbolic character name according to `sgml-char-names'."
512 (sgml-name-char last-command-char))
514 (defun sgml-maybe-name-self ()
515 "Insert a symbolic character name according to `sgml-char-names'."
517 (if sgml-name-8bit-mode
518 (let ((mc last-command-char))
520 (setq mc (unibyte-char-to-multibyte mc)))
521 (or mc (setq mc last-command-char))
523 (self-insert-command 1)))
525 (defun sgml-name-8bit-mode ()
526 "Toggle whether to insert named entities instead of non-ASCII characters."
528 (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
529 (message "sgml name entity mode is now %s"
530 (if sgml-name-8bit-mode "ON" "OFF")))
532 ;; When an element of a skeleton is a string "str", it is passed
533 ;; through skeleton-transformation and inserted. If "str" is to be
534 ;; inserted literally, one should obtain it as the return value of a
535 ;; function, e.g. (identity "str").
537 (define-skeleton sgml-tag
538 "Prompt for a tag and insert it, optionally with attributes.
539 Completion and configuration are done according to `sgml-tag-alist'.
540 If you like tags and attributes in uppercase do \\[set-variable]
541 skeleton-transformation RET upcase RET, or put this in your `.emacs':
542 (setq sgml-transformation 'upcase)"
543 (funcall skeleton-transformation
544 (completing-read "Tag: " sgml-tag-alist))
546 (("") -1 '(undo-boundary) (identity "<")) | ; see comment above
547 `(("") '(setq v2 (sgml-attributes ,str t)) ?>
551 '(("") " [ " _ " ]]"))
552 ((and (eq v2 t) sgml-xml (member ,str sgml-empty-tags))
554 ((or (and (eq v2 t) (not sgml-xml)) (string-match "^[/!?]" ,str))
557 ;; Make sure we don't fall into an infinite loop.
558 ;; For xhtml's `tr' tag, we should maybe use \n instead.
559 (if (eq v2 t) (setq v2 nil))
560 ;; We use `identity' to prevent skeleton from passing
561 ;; `str' through skeleton-transformation a second time.
562 '(("") v2 _ v2 "</" (identity ',str) ?>))
564 (cons '("") (cdr v2)))
566 (append '(("") (car v2))
568 '(resume: (car v2) _ "</" (identity ',str) ?>))))))
570 (autoload 'skeleton-read "skeleton")
572 (defun sgml-attributes (tag &optional quiet)
573 "When at top level of a tag, interactively insert attributes.
575 Completion and configuration of TAG are done according to `sgml-tag-alist'.
576 If QUIET, do not print a message when there are no attributes for TAG."
577 (interactive (list (save-excursion (sgml-beginning-of-tag t))))
578 (or (stringp tag) (error "Wrong context for adding attribute"))
580 (let ((completion-ignore-case t)
581 (alist (cdr (assoc (downcase tag) sgml-tag-alist)))
583 (if (or (symbolp (car alist))
584 (symbolp (car (car alist))))
585 (setq car (car alist)
588 (message "No attributes configured."))
589 (if (stringp (car alist))
591 (insert (if (eq (preceding-char) ? ) "" ? )
592 (funcall skeleton-transformation (car alist)))
594 (setq i (length alist))
597 (insert (funcall skeleton-transformation
599 (skeleton-read '(completing-read
602 (if (string= "" attribute)
604 (sgml-value (assoc (downcase attribute) alist))
606 (if (eq (preceding-char) ? )
607 (delete-backward-char 1)))
610 (defun sgml-auto-attributes (arg)
611 "Self insert the character typed; at top level of tag, prompt for attributes.
612 With prefix argument, only self insert."
614 (let ((point (point))
617 (not sgml-tag-alist) ; no message when nothing configured
618 (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
619 (eq (aref tag 0) ?/))
620 (self-insert-command (prefix-numeric-value arg))
621 (sgml-attributes tag)
622 (setq last-command-char ? )
623 (or (> (point) point)
624 (self-insert-command 1)))))
627 (defun sgml-tag-help (&optional tag)
628 "Display description of tag TAG. If TAG is omitted, use the tag at point."
632 (if (eq (following-char) ?<)
634 (setq tag (sgml-beginning-of-tag))))
636 (error "No tag selected"))
637 (setq tag (downcase tag))
639 (or (cdr (assoc (downcase tag) sgml-tag-help))
640 (and (eq (aref tag 0) ?/)
641 (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
642 "No description available")))
645 (defun sgml-maybe-end-tag ()
646 "Name self unless in position to end a tag."
648 (or (condition-case nil
649 (save-excursion (up-list -1))
655 (save-excursion (up-list 1))
657 (error (self-insert-command 1)))))
660 (defun sgml-skip-tag-backward (arg)
661 "Skip to beginning of tag or matching opening tag if present.
662 With prefix argument ARG, repeat this ARG times."
665 (search-backward "<" nil t)
666 (if (looking-at "</\\([^ \n\t>]+\\)")
667 ;; end tag, skip any nested pairs
668 (let ((case-fold-search t)
669 (re (concat "</?" (regexp-quote (match-string 1)))))
670 (while (and (re-search-backward re nil t)
671 (eq (char-after (1+ (point))) ?/))
673 (sgml-skip-tag-backward 1))))
674 (setq arg (1- arg))))
676 (defun sgml-skip-tag-forward (arg &optional return)
677 "Skip to end of tag or matching closing tag if present.
678 With prefix argument ARG, repeat this ARG times.
679 Return t iff after a closing tag."
683 (skip-chars-forward "^<>")
684 (if (eq (following-char) ?>)
686 (if (looking-at "<\\([^/ \n\t>]+\\)")
687 ;; start tag, skip any nested same pairs _and_ closing tag
688 (let ((case-fold-search t)
689 (re (concat "</?" (regexp-quote (match-string 1))))
693 (while (and (re-search-forward re nil t)
695 (eq (char-after (1+ (match-beginning 0))) ?/)))
697 (sgml-skip-tag-forward 1))
707 (defun sgml-delete-tag (arg)
708 "Delete tag on or after cursor, and matching closing or opening tag.
709 With prefix argument ARG, repeat this ARG times."
714 (if (looking-at "[ \t\n]*<")
716 (if (eq (char-after (match-end 0)) ?/)
720 (goto-char (match-end 0))))
722 (or (save-excursion (setq close (sgml-beginning-of-tag)
723 close (and (stringp close)
724 (eq (aref close 0) ?/)
726 ;; not on closing tag
727 (let ((point (point)))
728 (sgml-skip-tag-backward 1)
729 (if (or (not (eq (following-char) ?<))
733 (error "Not on or before tag")))))
736 (sgml-skip-tag-backward 1)
741 (sgml-skip-tag-forward 1)
744 (if (eq (aref (sgml-beginning-of-tag) 0) ?/)
748 (setq arg (1- arg))))
750 ;; Put read-only last to enable setting this even when read-only enabled.
751 (or (get 'sgml-tag 'invisible)
753 (append '(invisible t
755 point-entered sgml-point-entered
758 (symbol-plist 'sgml-tag))))
760 (defun sgml-tags-invisible (arg)
761 "Toggle visibility of existing tags."
763 (let ((modified (buffer-modified-p))
764 (inhibit-read-only t)
765 (inhibit-modification-hooks t)
766 ;; Avoid spurious the `file-locked' checks.
767 (buffer-file-name nil)
768 ;; This is needed in case font lock gets called,
769 ;; since it moves point and might call sgml-point-entered.
770 ;; How could it get called? -stef
771 (inhibit-point-motion-hooks t)
775 (goto-char (point-min))
776 (if (set (make-local-variable 'sgml-tags-invisible)
778 (>= (prefix-numeric-value arg) 0)
779 (not sgml-tags-invisible)))
780 (while (re-search-forward "<\\([!/?A-Za-z][-A-Za-z0-9]*\\)"
783 (cdr (assq (intern-soft (downcase (match-string 1)))
785 (goto-char (match-beginning 0))
786 (and (stringp string)
787 (not (overlays-at (point)))
788 (let ((ol (make-overlay (point) (match-beginning 1))))
789 (overlay-put ol 'before-string string)
790 (overlay-put ol 'sgml-tag t)))
791 (put-text-property (point)
792 (progn (forward-list) (point))
793 'category 'sgml-tag))
794 (let ((pos (point-min)))
795 (while (< (setq pos (next-overlay-change pos)) (point-max))
796 (dolist (ol (overlays-at pos))
797 (if (overlay-get ol 'sgml-tag)
798 (delete-overlay ol)))))
799 (remove-text-properties (point-min) (point-max) '(category nil))))
800 (restore-buffer-modified-p modified))
801 (run-hooks 'sgml-tags-invisible-hook)
804 (defun sgml-point-entered (x y)
805 ;; Show preceding or following hidden tag, depending of cursor direction.
806 (let ((inhibit-point-motion-hooks t))
808 (message "Invisible tag: %s"
809 ;; Strip properties, otherwise, the text is invisible.
810 (buffer-substring-no-properties
813 (not (eq (following-char) ?<)))
815 (eq (preceding-char) ?>)))
819 (autoload 'compile-internal "compile")
821 (defun sgml-validate (command)
822 "Validate an SGML document.
823 Runs COMMAND, a shell command, in a separate process asynchronously
824 with output going to the buffer `*compilation*'.
825 You can then use the command \\[next-error] to find the next error message
826 and move to the line in the SGML document that caused it."
828 (list (read-string "Validate command: "
829 (or sgml-saved-validate-command
830 (concat sgml-validate-command
832 (let ((name (buffer-file-name)))
834 (file-name-nondirectory name))))))))
835 (setq sgml-saved-validate-command command)
836 (save-some-buffers (not compilation-ask-about-save) nil)
837 (compile-internal command "No more errors"))
840 (defun sgml-beginning-of-tag (&optional top-level)
841 "Skip to beginning of tag and return its name.
842 If this can't be done, return t."
848 (if (search-backward "<" nil t)
853 (if (looking-at "<[!?/]?[[A-Za-z][A-Za-z0-9]*")
854 (buffer-substring-no-properties
859 (defun sgml-value (alist)
860 "Interactively insert value taken from attributerule ALIST.
861 See `sgml-tag-alist' for info about attribute rules."
862 (setq alist (cdr alist))
863 (if (stringp (car alist))
864 (insert "=\"" (car alist) ?\")
865 (if (and (eq (car alist) t) (not sgml-xml))
868 (setq alist (skeleton-read '(completing-read "Value: " (cdr alist))))
869 (if (string< "" alist)
871 (delete-backward-char 2)))
874 (insert (skeleton-read '(completing-read "Value: " alist))))
877 (defun sgml-quote (start end &optional unquotep)
878 "Quote SGML text in region.
879 With prefix argument, unquote the region."
886 (while (re-search-forward "&\\(amp\\|\\(l\\|\\(g\\)\\)t\\);" end t)
887 (replace-match (if (match-end 3) ">" (if (match-end 2) "<" "&"))))
888 (while (re-search-forward "[&<>]" end t)
889 (replace-match (cdr (assq (char-before) '((?& . "&")
896 (defcustom html-mode-hook nil
897 "Hook run by command `html-mode'.
898 `text-mode-hook' and `sgml-mode-hook' are run first."
901 :options '(html-autoview-mode))
903 (defvar html-quick-keys sgml-quick-keys
904 "Use C-c X combinations for quick insertion of frequent tags when non-nil.
905 This defaults to `sgml-quick-keys'.
906 This takes effect when first loading the library.")
908 (defvar html-mode-map
909 (let ((map (make-sparse-keymap))
910 (menu-map (make-sparse-keymap "HTML")))
911 (set-keymap-parent map sgml-mode-map)
912 (define-key map "\C-c6" 'html-headline-6)
913 (define-key map "\C-c5" 'html-headline-5)
914 (define-key map "\C-c4" 'html-headline-4)
915 (define-key map "\C-c3" 'html-headline-3)
916 (define-key map "\C-c2" 'html-headline-2)
917 (define-key map "\C-c1" 'html-headline-1)
918 (define-key map "\C-c\r" 'html-paragraph)
919 (define-key map "\C-c\n" 'html-line)
920 (define-key map "\C-c\C-c-" 'html-horizontal-rule)
921 (define-key map "\C-c\C-co" 'html-ordered-list)
922 (define-key map "\C-c\C-cu" 'html-unordered-list)
923 (define-key map "\C-c\C-cr" 'html-radio-buttons)
924 (define-key map "\C-c\C-cc" 'html-checkboxes)
925 (define-key map "\C-c\C-cl" 'html-list-item)
926 (define-key map "\C-c\C-ch" 'html-href-anchor)
927 (define-key map "\C-c\C-cn" 'html-name-anchor)
928 (define-key map "\C-c\C-ci" 'html-image)
929 (when html-quick-keys
930 (define-key map "\C-c-" 'html-horizontal-rule)
931 (define-key map "\C-co" 'html-ordered-list)
932 (define-key map "\C-cu" 'html-unordered-list)
933 (define-key map "\C-cr" 'html-radio-buttons)
934 (define-key map "\C-cc" 'html-checkboxes)
935 (define-key map "\C-cl" 'html-list-item)
936 (define-key map "\C-ch" 'html-href-anchor)
937 (define-key map "\C-cn" 'html-name-anchor)
938 (define-key map "\C-ci" 'html-image))
939 (define-key map "\C-c\C-s" 'html-autoview-mode)
940 (define-key map "\C-c\C-v" 'browse-url-of-buffer)
941 (define-key map [menu-bar html] (cons "HTML" menu-map))
942 (define-key menu-map [html-autoview-mode]
943 '("Toggle Autoviewing" . html-autoview-mode))
944 (define-key menu-map [browse-url-of-buffer]
945 '("View Buffer Contents" . browse-url-of-buffer))
946 (define-key menu-map [nil] '("--"))
947 ;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
948 ;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
949 ;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
950 (define-key menu-map "3" '("Heading 3" . html-headline-3))
951 (define-key menu-map "2" '("Heading 2" . html-headline-2))
952 (define-key menu-map "1" '("Heading 1" . html-headline-1))
953 (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
954 (define-key menu-map "c" '("Checkboxes" . html-checkboxes))
955 (define-key menu-map "l" '("List Item" . html-list-item))
956 (define-key menu-map "u" '("Unordered List" . html-unordered-list))
957 (define-key menu-map "o" '("Ordered List" . html-ordered-list))
958 (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
959 (define-key menu-map "\n" '("Line Break" . html-line))
960 (define-key menu-map "\r" '("Paragraph" . html-paragraph))
961 (define-key menu-map "i" '("Image" . html-image))
962 (define-key menu-map "h" '("Href Anchor" . html-href-anchor))
963 (define-key menu-map "n" '("Name Anchor" . html-name-anchor))
965 "Keymap for commands for use in HTML mode.")
968 (defvar html-face-tag-alist
973 "Value of `sgml-face-tag-alist' for HTML mode.")
975 (defvar html-tag-face-alist
978 ("blink" . highlight)
981 ("h1" bold underline)
982 ("h2" bold-italic underline)
983 ("h3" italic underline)
992 ("title" bold underline)
996 "Value of `sgml-tag-face-alist' for HTML mode.")
999 (defvar html-display-text
1003 "Value of `sgml-display-text' for HTML mode.")
1006 ;; should code exactly HTML 3 here when that is finished
1007 (defvar html-tag-alist
1008 (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
1009 (1-9 `(,@1-7 ("8") ("9")))
1010 (align '(("align" ("left") ("center") ("right"))))
1011 (valign '(("top") ("middle") ("bottom") ("baseline")))
1012 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
1013 (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
1014 ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:")
1015 ("wais:") ("/cgi-bin/")))
1021 (list '((nil \n ("List item: " "<li>" str
1022 (if sgml-xml "</li>") \n))))
1029 ;; put ,-expressions first, else byte-compile chokes (as of V19.29)
1030 ;; and like this it's more efficient anyway
1031 `(("a" ,name ,@link)
1034 ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
1035 ("form" (\n _ \n "<input type=\"submit\" value=\"\""
1036 (if sgml-xml "/>" ">"))
1037 ("action" ,@(cdr href)) ("method" ("get") ("post")))
1044 ("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
1045 ("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
1046 ("src") ("alt") ("width" "1") ("height" "1")
1047 ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
1048 ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name
1049 ("type" ("text") ("password") ("checkbox") ("radio")
1050 ("submit") ("reset"))
1054 ("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1")))
1058 "<option>" str (if sgml-xml "</option>") \n))
1059 ,name ("size" ,@1-9) ("multiple" t))
1061 ((completing-read "Cell kind: " '(("td") ("th"))
1064 (if sgml-xml (concat "<" str "></tr>")) \n))
1065 ("border" t ,@1-9) ("width" "10") ("cellpadding"))
1067 ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
1069 ("ul" ,@list ("type" ("disc") ("circle") ("square")))
1077 ("Item: " "<item>" str (if sgml-xml "</item>") \n))
1084 ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
1085 ("link" "#") ("alink" "#") ("vlink" "#"))
1086 ("box" (nil _ "<over>" _ (if sgml-xml "</over>")))
1087 ("br" t ("clear" ("left") ("right")))
1088 ("caption" ("valign" ("top") ("bottom")))
1092 ("dd" ,(not sgml-xml))
1098 "<dt>" str (if sgml-xml "</dt>")
1099 "<dd>" _ (if sgml-xml "</dd>") \n)))
1100 ("dt" (t _ (if sgml-xml "</dt>")
1101 "<dd>" (if sgml-xml "</dd>") \n))
1103 ;("fn" "id" "fn") ; ???
1107 "<title>" (setq str (read-input "Title: ")) "</title>\n"
1109 "<body>\n<h1>" str "</h1>\n" _
1110 "\n<address>\n<a href=\"mailto:"
1112 "\">" (user-full-name) "</a>\n</address>\n"
1117 ("isindex" t ("action") ("prompt"))
1120 ("li" ,(not sgml-xml))
1123 ("option" t ("value") ("label") ("selected" t))
1152 "*Value of `sgml-tag-alist' for HTML mode.")
1154 (defvar html-tag-help
1156 ("a" . "Anchor of point or link elsewhere")
1159 ("address" . "Formatted mail address")
1160 ("array" . "Math array")
1163 ("base" . "Base address for URLs")
1164 ("big" . "Font size")
1165 ("blink" . "Blinking text")
1166 ("blockquote" . "Indented quotation")
1167 ("body" . "Document body")
1168 ("box" . "Math fraction")
1169 ("br" . "Line break")
1170 ("caption" . "Table caption")
1171 ("center" . "Centered text")
1172 ("changed" . "Change bars")
1173 ("cite" . "Citation of a document")
1174 ("code" . "Formatted source code")
1175 ("dd" . "Definition of term")
1178 ("dir" . "Directory list (obsolete)")
1179 ("dl" . "Definition list")
1180 ("dt" . "Term to be definined")
1181 ("em" . "Emphasised")
1182 ("embed" . "Embedded data in foreign format")
1184 ("figa" . "Figure anchor")
1185 ("figd" . "Figure description")
1186 ("figt" . "Figure text")
1188 ("font" . "Font size")
1189 ("form" . "Form with input fields")
1190 ("group" . "Document grouping")
1191 ("h1" . "Most important section headline")
1192 ("h2" . "Important section headline")
1193 ("h3" . "Section headline")
1194 ("h4" . "Minor section headline")
1195 ("h5" . "Unimportant section headline")
1196 ("h6" . "Least important section headline")
1197 ("head" . "Document header")
1198 ("hr" . "Horizontal rule")
1199 ("html" . "HTML Document")
1200 ("i" . "Italic face")
1201 ("img" . "Graphic image")
1202 ("input" . "Form input field")
1204 ("isindex" . "Input field for index search")
1205 ("kbd" . "Keybard example face")
1206 ("lang" . "Natural language")
1207 ("li" . "List item")
1208 ("link" . "Link relationship")
1209 ("math" . "Math formula")
1210 ("menu" . "Menu list (obsolete)")
1211 ("mh" . "Form mail header")
1212 ("nextid" . "Allocate new id")
1213 ("nobr" . "Text without line break")
1214 ("ol" . "Ordered list")
1215 ("option" . "Selection list item")
1216 ("over" . "Math fraction rule")
1217 ("p" . "Paragraph start")
1218 ("panel" . "Floating panel")
1220 ("pre" . "Preformatted fixed width text")
1222 ("rev" . "Reverse video")
1224 ("samp" . "Sample text")
1225 ("select" . "Selection list")
1226 ("small" . "Font size")
1227 ("sp" . "Nobreak space")
1228 ("strong" . "Standout text")
1229 ("sub" . "Subscript")
1230 ("sup" . "Superscript")
1231 ("table" . "Table with rows and columns")
1232 ("tb" . "Table vertical break")
1233 ("td" . "Table data cell")
1234 ("textarea" . "Form multiline edit area")
1235 ("th" . "Table header cell")
1236 ("title" . "Document title")
1237 ("tr" . "Table row separator")
1238 ("tt" . "Typewriter face")
1239 ("u" . "Underlined text")
1240 ("ul" . "Unordered list")
1241 ("var" . "Math variable face")
1242 ("wbr" . "Enable <br> within <nobr>"))
1243 "*Value of `sgml-tag-help' for HTML mode.")
1246 (define-derived-mode html-mode sgml-mode "HTML"
1247 "Major mode based on SGML mode for editing HTML documents.
1248 This allows inserting skeleton constructs used in hypertext documents with
1249 completion. See below for an introduction to HTML. Use
1250 \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
1251 which this is based.
1253 Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
1255 To write fairly well formatted pages you only need to know few things. Most
1256 browsers have a function to read the source code of the page being seen, so
1257 you can imitate various tricks. Here's a very short HTML primer which you
1258 can also view with a browser to see what happens:
1260 <title>A Title Describing Contents</title> should be on every page. Pages can
1261 have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6>
1262 <hr> Parts can be separated with horizontal rules.
1264 <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
1265 ignored unless the text is <pre>preformatted.</pre> Text can be marked as
1266 <b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-g or
1267 Edit/Text Properties/Face commands.
1269 Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
1270 to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a
1271 href=\"URL\">see also URL</a> where URL is a filename relative to current
1272 directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'.
1274 Images in many formats can be inlined with <img src=\"URL\">.
1276 If you mainly create your own documents, `sgml-specials' might be
1277 interesting. But note that some HTML 2 browsers can't handle `''.
1278 To work around that, do:
1279 (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
1282 (set (make-local-variable 'sgml-display-text) html-display-text)
1283 (set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist)
1284 (make-local-variable 'sgml-tag-alist)
1285 (make-local-variable 'sgml-face-tag-alist)
1286 (make-local-variable 'sgml-tag-help)
1287 (make-local-variable 'outline-regexp)
1288 (make-local-variable 'outline-heading-end-regexp)
1289 (make-local-variable 'outline-level)
1290 (make-local-variable 'sentence-end)
1292 (if sentence-end-double-space
1293 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\| \\)[ \t\n]*"
1294 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\|[ \t]\\)[ \t\n]*"))
1295 (setq sgml-tag-alist html-tag-alist
1296 sgml-face-tag-alist html-face-tag-alist
1297 sgml-tag-help html-tag-help
1298 outline-regexp "^.*<[Hh][1-6]\\>"
1299 outline-heading-end-regexp "</[Hh][1-6]>"
1300 outline-level (lambda ()
1301 (char-after (1- (match-end 0)))))
1302 (setq imenu-create-index-function 'html-imenu-index)
1303 (when sgml-xml (setq mode-name "XHTML"))
1304 (set (make-local-variable 'sgml-empty-tags)
1305 '("br" "hr" "img" "input" "area" "link" "param" "col"
1306 "base" "meta" "basefont" "frame" "isindex" "wbr"))
1307 ;; It's for the user to decide if it defeats it or not -stef
1308 ;; (make-local-variable 'imenu-sort-function)
1309 ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
1312 (defvar html-imenu-regexp
1313 "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
1314 "*A regular expression matching a head line to be added to the menu.
1315 The first `match-string' should be a number from 1-9.
1316 The second `match-string' matches extra tags and is ignored.
1317 The third `match-string' will be the used in the menu.")
1319 (defun html-imenu-index ()
1320 "Return an table of contents for an HTML buffer for use with Imenu."
1323 (goto-char (point-min))
1324 (while (re-search-forward html-imenu-regexp nil t)
1326 (cons (cons (concat (make-string
1327 (* 2 (1- (string-to-number (match-string 1))))
1330 (line-beginning-position))
1332 (nreverse toc-index)))
1334 (defun html-autoview-mode (&optional arg)
1335 "Toggle automatic viewing via `browse-url-of-buffer' upon saving buffer.
1336 With positive prefix ARG always turns viewing on, with negative ARG always off.
1337 Can be used as a value for `html-mode-hook'."
1339 (if (setq arg (if arg
1340 (< (prefix-numeric-value arg) 0)
1341 (and (boundp 'after-save-hook)
1342 (memq 'browse-url-of-buffer after-save-hook))))
1343 (setq after-save-hook (delq 'browse-url-of-buffer after-save-hook))
1344 (add-hook 'after-save-hook 'browse-url-of-buffer nil t))
1345 (message "Autoviewing turned %s."
1346 (if arg "off" "on")))
1348 (define-skeleton html-href-anchor
1349 "HTML anchor tag with href attribute."
1351 '(setq input "http:")
1352 "<a href=\"" str "\">" _ "</a>")
1354 (define-skeleton html-name-anchor
1355 "HTML anchor tag with name attribute."
1357 "<a name=\"" str "\">" _ "</a>")
1359 (define-skeleton html-headline-1
1360 "HTML level 1 headline tags."
1364 (define-skeleton html-headline-2
1365 "HTML level 2 headline tags."
1369 (define-skeleton html-headline-3
1370 "HTML level 3 headline tags."
1374 (define-skeleton html-headline-4
1375 "HTML level 4 headline tags."
1379 (define-skeleton html-headline-5
1380 "HTML level 5 headline tags."
1384 (define-skeleton html-headline-6
1385 "HTML level 6 headline tags."
1389 (define-skeleton html-horizontal-rule
1390 "HTML horizontal rule tag."
1392 (if sgml-xml "<hr/>" "<hr>") \n)
1394 (define-skeleton html-image
1397 "<img src=\"" _ "\""
1398 (if sgml-xml "/>" ">"))
1400 (define-skeleton html-line
1401 "HTML line break tag."
1403 (if sgml-xml "<br/>" "<br>") \n)
1405 (define-skeleton html-ordered-list
1406 "HTML ordered list tags."
1409 "<li>" _ (if sgml-xml "</li>") \n
1412 (define-skeleton html-unordered-list
1413 "HTML unordered list tags."
1416 "<li>" _ (if sgml-xml "</li>") \n
1419 (define-skeleton html-list-item
1420 "HTML list item tag."
1423 "<li>" _ (if sgml-xml "</li>"))
1425 (define-skeleton html-paragraph
1426 "HTML paragraph tag."
1429 \n "<p>" _ (if sgml-xml "</p>"))
1431 (define-skeleton html-checkboxes
1432 "Group of connected checkbox inputs."
1437 "<input type=\"" (identity "checkbox") ; see comment above about identity
1438 "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
1439 "\" value=\"" str ?\"
1440 (when (y-or-n-p "Set \"checked\" attribute? ")
1441 (funcall skeleton-transformation " checked"))
1442 (if sgml-xml "/>" ">")
1443 (skeleton-read "Text: " (capitalize str))
1444 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
1445 (funcall skeleton-transformation
1446 (if sgml-xml "<br/>" "<br>"))
1450 (define-skeleton html-radio-buttons
1451 "Group of connected radio button inputs."
1456 "<input type=\"" (identity "radio") ; see comment above about identity
1457 "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
1458 "\" value=\"" str ?\"
1459 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
1460 (funcall skeleton-transformation " checked"))
1461 (if sgml-xml "/>" ">")
1462 (skeleton-read "Text: " (capitalize str))
1463 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
1464 (funcall skeleton-transformation
1465 (if sgml-xml "<br/>" "<br>"))
1469 (provide 'sgml-mode)
1471 ;;; sgml-mode.el ends here