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)))
108 (define-key map (vector (encode-char (+ i 32) 'latin-iso8859-1))
109 'sgml-maybe-name-self))
112 (while (< (setq c (1+ c)) 256)
113 (aset map c 'sgml-maybe-name-self)))
114 (define-key map [menu-bar sgml] (cons "SGML" menu-map))
115 (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
116 (define-key menu-map [sgml-name-8bit-mode]
117 '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
118 (define-key menu-map [sgml-tags-invisible]
119 '("Toggle Tag Visibility" . sgml-tags-invisible))
120 (define-key menu-map [sgml-tag-help]
121 '("Describe Tag" . sgml-tag-help))
122 (define-key menu-map [sgml-delete-tag]
123 '("Delete Tag" . sgml-delete-tag))
124 (define-key menu-map [sgml-skip-tag-forward]
125 '("Forward Tag" . sgml-skip-tag-forward))
126 (define-key menu-map [sgml-skip-tag-backward]
127 '("Backward Tag" . sgml-skip-tag-backward))
128 (define-key menu-map [sgml-attributes]
129 '("Insert Attributes" . sgml-attributes))
130 (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
132 "Keymap for SGML mode. See also `sgml-specials'.")
135 (defvar sgml-mode-syntax-table
136 (let ((table (copy-syntax-table text-mode-syntax-table)))
137 (modify-syntax-entry ?< "(>" table)
138 (modify-syntax-entry ?> ")<" table)
139 (if (memq ?- sgml-specials)
140 (modify-syntax-entry ?- "_ 1234" table))
141 (if (memq ?\" sgml-specials)
142 (modify-syntax-entry ?\" "\"\"" table))
143 (if (memq ?' sgml-specials)
144 (modify-syntax-entry ?\' "\"'" table))
146 "Syntax table used in SGML mode. See also `sgml-specials'.")
149 (defcustom sgml-name-8bit-mode nil
150 "*When non-nil, insert non-ASCII characters as named entities."
154 (defvar sgml-char-names
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 nil nil nil nil nil nil nil nil
159 "nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
160 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
161 nil nil nil nil nil nil nil nil
162 nil nil "colon" "semi" "lt" "eq" "gt" "quest"
163 "commat" nil nil nil nil nil nil nil
164 nil nil nil nil nil nil nil nil
165 nil nil nil nil nil nil nil nil
166 nil nil nil "lsqb" nil "rsqb" "uarr" "lowbar"
167 "lsquo" nil nil nil nil nil nil nil
168 nil nil nil nil nil nil nil nil
169 nil nil nil nil nil nil nil nil
170 nil nil nil "lcub" "verbar" "rcub" "tilde" 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 nil nil nil nil nil nil nil nil
175 "nbsp" "iexcl" "cent" "pound" "curren" "yen" "brvbar" "sect"
176 "uml" "copy" "ordf" "laquo" "not" "shy" "reg" "macr"
177 "ring" "plusmn" "sup2" "sup3" "acute" "micro" "para" "middot"
178 "cedil" "sup1" "ordm" "raquo" "frac14" "frac12" "frac34" "iquest"
179 "Agrave" "Aacute" "Acirc" "Atilde" "Auml" "Aring" "AElig" "Ccedil"
180 "Egrave" "Eacute" "Ecirc" "Euml" "Igrave" "Iacute" "Icirc" "Iuml"
181 "ETH" "Ntilde" "Ograve" "Oacute" "Ocirc" "Otilde" "Ouml" nil
182 "Oslash" "Ugrave" "Uacute" "Ucirc" "Uuml" "Yacute" "THORN" "szlig"
183 "agrave" "aacute" "acirc" "atilde" "auml" "aring" "aelig" "ccedil"
184 "egrave" "eacute" "ecirc" "euml" "igrave" "iacute" "icirc" "iuml"
185 "eth" "ntilde" "ograve" "oacute" "ocirc" "otilde" "ouml" "divide"
186 "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"]
187 "Vector of symbolic character names without `&' and `;'.")
189 (put 'sgml-table 'char-table-extra-slots 0)
191 (defvar sgml-char-names-table
192 (let ((table (make-char-table 'sgml-table))
196 (setq elt (aref sgml-char-names i))
197 (if elt (aset table (make-char 'latin-iso8859-1 i) elt))
200 "A table for mapping non-ASCII characters into SGML entity names.
201 Currently, only Latin-1 characters are supported.")
204 ;; nsgmls is a free SGML parser in the SP suite available from
205 ;; ftp.jclark.com and otherwise packaged for GNU systems.
206 ;; Its error messages can be parsed by next-error.
207 ;; The -s option suppresses output.
209 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
210 "*The command to validate an SGML document.
211 The file name of current buffer file name will be appended to this,
212 separated by a space."
217 (defvar sgml-saved-validate-command nil
218 "The command last used to validate in this buffer.")
221 ;; I doubt that null end tags are used much for large elements,
222 ;; so use a small distance here.
223 (defcustom sgml-slash-distance 1000
224 "*If non-nil, is the maximum distance to search for matching `/'."
225 :type '(choice (const nil) integer)
228 (defconst sgml-start-tag-regex
229 "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
230 "Regular expression that matches a non-empty start tag.
231 Any terminating `>' or `/' is not matched.")
235 (defconst sgml-font-lock-keywords-1
236 '(("<\\([!?][a-z][-.a-z0-9]*\\)" 1 font-lock-keyword-face)
237 ("<\\(/?[a-z][-.a-z0-9]*\\)" 1 font-lock-function-name-face)
238 ("[&%][a-z][-.a-z0-9]*;?" . font-lock-variable-name-face)))
240 (defconst sgml-font-lock-keywords-2
242 sgml-font-lock-keywords-1
245 (regexp-opt (mapcar 'car sgml-tag-face-alist) t)
246 "\\([ \t][^>]*\\)?>\\([^<]+\\)</\\1>")
247 '(3 (cdr (assoc (downcase (match-string 1))
248 sgml-tag-face-alist))))))))
250 ;; for font-lock, but must be defvar'ed after
251 ;; sgml-font-lock-keywords-1 and sgml-font-lock-keywords-2 above
252 (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
253 "*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
255 (defvar sgml-font-lock-syntactic-keywords
256 ;; Use the `b' style of comments to avoid interference with the -- ... --
257 ;; comments recognized when `sgml-specials' includes ?-.
258 ;; FIXME: beware of <!--> blabla <!--> !!
259 '(("\\(<\\)!--" (1 "< b"))
260 ("--[ \t\n]*\\(>\\)" (1 "> b")))
261 "Syntactic keywords for `sgml-mode'.")
264 (defvar sgml-face-tag-alist ()
265 "Alist of face and tag name for facemenu.")
267 (defvar sgml-tag-face-alist ()
268 "Tag names and face or list of faces to fontify with when invisible.
269 When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
270 When more these are fontified together with `sgml-font-lock-keywords'.")
273 (defvar sgml-display-text ()
274 "Tag names as lowercase symbols, and display string when invisible.")
277 (defvar sgml-tags-invisible nil)
280 (defcustom sgml-tag-alist
281 '(("![" ("ignore" t) ("include" t))
286 "*Alist of tag names for completing read and insertion rules.
287 This alist is made up as
292 TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by
293 newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor
294 followed by an ATTRIBUTERULE (for an always present attribute) or an
297 The attribute alist is made up as
299 ((\"attribute\" . ATTRIBUTERULE)
302 ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by
303 an optional alist of possible values."
304 :type '(repeat (cons (string :tag "Tag Name")
305 (repeat :tag "Tag Rule" sexp)))
308 (defcustom sgml-tag-help
309 '(("!" . "Empty declaration for comment")
310 ("![" . "Embed declarations with parser directive")
311 ("!attlist" . "Tag attributes declaration")
312 ("!doctype" . "Document type (DTD) declaration")
313 ("!element" . "Tag declaration")
314 ("!entity" . "Entity (macro) declaration"))
315 "*Alist of tag name and short description."
316 :type '(repeat (cons (string :tag "Tag Name")
317 (string :tag "Description")))
320 (defcustom sgml-xml nil
321 "*When non-nil, tag insertion functions will be XML-compliant.
322 If this variable is customized, the custom value is used always.
323 Otherwise, it is set to be buffer-local when the file has
324 a DOCTYPE or an XML declaration."
329 (defvar sgml-empty-tags nil
330 "List of tags whose !ELEMENT definition says EMPTY.")
332 (defun sgml-xml-guess ()
333 "Guess whether the current buffer is XML."
335 (goto-char (point-min))
336 (cond ((or (string= "xml" (file-name-extension (or buffer-file-name "")))
337 (looking-at "\\s-*<\\?xml"))
338 (set (make-local-variable 'sgml-xml) t))
342 '("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
343 "\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"")
346 (let ((name (match-string 1))
347 (pub (match-string 2))
348 (id (match-string 3))
349 (url (match-string 4)))
350 (cond ((string= name "html")
351 (set (make-local-variable 'sgml-xml)
352 (not (null (string-match "XHTML" id)))))
353 ((string-match "XML" id)
354 (set (make-local-variable 'sgml-xml) t))))))))
356 (defvar v2) ; free for skeleton
358 (defun sgml-mode-common ()
359 "Common code for setting up `sgml-mode' and derived modes."
360 (make-local-variable 'sgml-saved-validate-command)
361 (make-local-variable 'facemenu-end-add-face)
362 ;;(make-local-variable 'facemenu-remove-face-function)
363 (set (make-local-variable 'indent-line-function) 'indent-relative-maybe)
364 ;; A start or end tag by itself on a line separates a paragraph.
365 ;; This is desirable because SGML discards a newline that appears
366 ;; immediately after a start tag or immediately before an end tag.
367 (set (make-local-variable 'paragraph-separate) "[ \t]*$\\|\
368 \[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$")
369 (set (make-local-variable 'paragraph-start) "[ \t]*$\\|\
370 \[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>")
371 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
372 (set (make-local-variable 'comment-start) "<!-- ")
373 (set (make-local-variable 'comment-end) " -->")
374 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
375 (set (make-local-variable 'skeleton-transformation) sgml-transformation)
376 (set (make-local-variable 'skeleton-further-elements)
377 '((completion-ignore-case t)))
378 (set (make-local-variable 'skeleton-end-hook)
381 (not (or (eq v2 '\n) (eq (car-safe v2) '\n)))
382 (newline-and-indent))))
383 (set (make-local-variable 'font-lock-defaults)
384 '((sgml-font-lock-keywords
385 sgml-font-lock-keywords-1
386 sgml-font-lock-keywords-2)
388 (font-lock-syntactic-keywords
389 . sgml-font-lock-syntactic-keywords)))
390 (set (make-local-variable 'facemenu-add-face-function)
391 'sgml-mode-facemenu-add-face-function)
392 ;; `sgml-xml' not customized -- guess
393 (unless (get 'sgml-xml 'saved-value) (sgml-xml-guess))
394 ;; This will allow existing comments within declarations to be
396 (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
397 (set (make-local-variable 'comment-end-skip) "[ \t]*--\\([ \t\n]*>\\)?"))
400 (defun sgml-mode-facemenu-add-face-function (face end)
401 (if (setq face (cdr (assq face sgml-face-tag-alist)))
403 (setq face (funcall skeleton-transformation face))
404 (setq facemenu-end-add-face (concat "</" face ">"))
405 (concat "<" face ">"))
406 (error "Face not configured for %s mode" mode-name)))
410 (define-derived-mode sgml-mode text-mode "SGML"
411 "Major mode for editing SGML documents.
412 Makes > match <. Makes / blink matching /.
413 Keys <, &, SPC within <>, \" and ' can be electric depending on
416 An argument of N to a tag-inserting command means to wrap it around
417 the next N words. In Transient Mark mode, when the mark is active,
418 N defaults to -1, which means to wrap it around the current region.
420 If you like upcased tags, put (setq sgml-transformation 'upcase) in
423 Use \\[sgml-validate] to validate your document with an SGML parser.
425 Do \\[describe-variable] sgml- SPC to see available variables.
426 Do \\[describe-key] on the following bindings to discover what they do.
429 (when sgml-xml (setq mode-name "XML"))
430 ;; Set `imenu-generic-expression' here, rather than in `sgml-mode-common',
431 ;; because this definition probably is not useful in HTML mode.
432 (set (make-local-variable 'imenu-generic-expression)
433 "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)"))
436 (defun sgml-comment-indent ()
437 (if (looking-at "--") comment-column 0))
441 (defun sgml-slash (arg)
442 "Insert `/' and display any previous matching `/'.
443 Two `/'s are treated as matching if the first `/' ends a net-enabling
444 start tag, and the second `/' is the corresponding null end tag."
448 (let ((oldpos (point))
453 (if sgml-slash-distance
454 (narrow-to-region (max (point-min)
455 (- (point) sgml-slash-distance))
457 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
458 (eq (match-end 0) (1- oldpos)))
460 (goto-char (1- oldpos))
461 (while (and (not blinkpos)
462 (search-backward "/" (point-min) t))
463 (let ((tagend (save-excursion
464 (if (re-search-backward sgml-start-tag-regex
468 (if (eq tagend (point))
470 (setq blinkpos (point))
471 (setq level (1- level)))
472 (setq level (1+ level)))))))
475 (if (pos-visible-in-window-p)
477 (message "Matches %s"
478 (buffer-substring (line-beginning-position)
479 (1+ blinkpos)))))))))
482 (defun sgml-name-char (&optional char)
483 "Insert a symbolic character name according to `sgml-char-names'.
484 Non-ASCII chars may be inserted either with the meta key, as in M-SPC for
485 no-break space or M-- for a soft hyphen; or via an input method or
486 encoded keyboard operation."
490 (setq char (read-quoted-char "Enter char or octal number")))
491 (delete-backward-char 1)
494 (delete-backward-char 1)
498 (or (aref sgml-char-names char)
501 ((aref sgml-char-names-table char)
502 (insert ?& (aref sgml-char-names-table char) ?\;))
503 ((memq (char-charset char) '(mule-unicode-0100-24ff
504 mule-unicode-2500-33ff
505 mule-unicode-e000-ffff))
506 (insert (format "&#%d;" (encode-char char 'ucs))))
510 (defun sgml-name-self ()
511 "Insert a symbolic character name according to `sgml-char-names'."
513 (sgml-name-char last-command-char))
515 (defun sgml-maybe-name-self ()
516 "Insert a symbolic character name according to `sgml-char-names'."
518 (if sgml-name-8bit-mode
519 (let ((mc last-command-char))
521 (setq mc (unibyte-char-to-multibyte mc)))
522 (or mc (setq mc last-command-char))
524 (self-insert-command 1)))
526 (defun sgml-name-8bit-mode ()
527 "Toggle whether to insert named entities instead of non-ASCII characters."
529 (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
530 (message "sgml name entity mode is now %s"
531 (if sgml-name-8bit-mode "ON" "OFF")))
533 ;; When an element of a skeleton is a string "str", it is passed
534 ;; through skeleton-transformation and inserted. If "str" is to be
535 ;; inserted literally, one should obtain it as the return value of a
536 ;; function, e.g. (identity "str").
538 (define-skeleton sgml-tag
539 "Prompt for a tag and insert it, optionally with attributes.
540 Completion and configuration are done according to `sgml-tag-alist'.
541 If you like tags and attributes in uppercase do \\[set-variable]
542 skeleton-transformation RET upcase RET, or put this in your `.emacs':
543 (setq sgml-transformation 'upcase)"
544 (funcall skeleton-transformation
545 (completing-read "Tag: " sgml-tag-alist))
547 (("") -1 '(undo-boundary) (identity "<")) | ; see comment above
548 `(("") '(setq v2 (sgml-attributes ,str t)) ?>
552 '(("") " [ " _ " ]]"))
553 ((and (eq v2 t) sgml-xml (member ,str sgml-empty-tags))
555 ((or (and (eq v2 t) (not sgml-xml)) (string-match "^[/!?]" ,str))
558 ;; Make sure we don't fall into an infinite loop.
559 ;; For xhtml's `tr' tag, we should maybe use \n instead.
560 (if (eq v2 t) (setq v2 nil))
561 ;; We use `identity' to prevent skeleton from passing
562 ;; `str' through skeleton-transformation a second time.
563 '(("") v2 _ v2 "</" (identity ',str) ?>))
565 (cons '("") (cdr v2)))
567 (append '(("") (car v2))
569 '(resume: (car v2) _ "</" (identity ',str) ?>))))))
571 (autoload 'skeleton-read "skeleton")
573 (defun sgml-attributes (tag &optional quiet)
574 "When at top level of a tag, interactively insert attributes.
576 Completion and configuration of TAG are done according to `sgml-tag-alist'.
577 If QUIET, do not print a message when there are no attributes for TAG."
578 (interactive (list (save-excursion (sgml-beginning-of-tag t))))
579 (or (stringp tag) (error "Wrong context for adding attribute"))
581 (let ((completion-ignore-case t)
582 (alist (cdr (assoc (downcase tag) sgml-tag-alist)))
584 (if (or (symbolp (car alist))
585 (symbolp (car (car alist))))
586 (setq car (car alist)
589 (message "No attributes configured."))
590 (if (stringp (car alist))
592 (insert (if (eq (preceding-char) ? ) "" ? )
593 (funcall skeleton-transformation (car alist)))
595 (setq i (length alist))
598 (insert (funcall skeleton-transformation
600 (skeleton-read '(completing-read
603 (if (string= "" attribute)
605 (sgml-value (assoc (downcase attribute) alist))
607 (if (eq (preceding-char) ? )
608 (delete-backward-char 1)))
611 (defun sgml-auto-attributes (arg)
612 "Self insert the character typed; at top level of tag, prompt for attributes.
613 With prefix argument, only self insert."
615 (let ((point (point))
618 (not sgml-tag-alist) ; no message when nothing configured
619 (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
620 (eq (aref tag 0) ?/))
621 (self-insert-command (prefix-numeric-value arg))
622 (sgml-attributes tag)
623 (setq last-command-char ? )
624 (or (> (point) point)
625 (self-insert-command 1)))))
628 (defun sgml-tag-help (&optional tag)
629 "Display description of tag TAG. If TAG is omitted, use the tag at point."
633 (if (eq (following-char) ?<)
635 (setq tag (sgml-beginning-of-tag))))
637 (error "No tag selected"))
638 (setq tag (downcase tag))
640 (or (cdr (assoc (downcase tag) sgml-tag-help))
641 (and (eq (aref tag 0) ?/)
642 (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
643 "No description available")))
646 (defun sgml-maybe-end-tag ()
647 "Name self unless in position to end a tag."
649 (or (condition-case nil
650 (save-excursion (up-list -1))
656 (save-excursion (up-list 1))
658 (error (self-insert-command 1)))))
661 (defun sgml-skip-tag-backward (arg)
662 "Skip to beginning of tag or matching opening tag if present.
663 With prefix argument ARG, repeat this ARG times."
666 (search-backward "<" nil t)
667 (if (looking-at "</\\([^ \n\t>]+\\)")
668 ;; end tag, skip any nested pairs
669 (let ((case-fold-search t)
670 (re (concat "</?" (regexp-quote (match-string 1)))))
671 (while (and (re-search-backward re nil t)
672 (eq (char-after (1+ (point))) ?/))
674 (sgml-skip-tag-backward 1))))
675 (setq arg (1- arg))))
677 (defun sgml-skip-tag-forward (arg &optional return)
678 "Skip to end of tag or matching closing tag if present.
679 With prefix argument ARG, repeat this ARG times.
680 Return t iff after a closing tag."
684 (skip-chars-forward "^<>")
685 (if (eq (following-char) ?>)
687 (if (looking-at "<\\([^/ \n\t>]+\\)")
688 ;; start tag, skip any nested same pairs _and_ closing tag
689 (let ((case-fold-search t)
690 (re (concat "</?" (regexp-quote (match-string 1))))
694 (while (and (re-search-forward re nil t)
696 (eq (char-after (1+ (match-beginning 0))) ?/)))
698 (sgml-skip-tag-forward 1))
708 (defun sgml-delete-tag (arg)
709 "Delete tag on or after cursor, and matching closing or opening tag.
710 With prefix argument ARG, repeat this ARG times."
715 (if (looking-at "[ \t\n]*<")
717 (if (eq (char-after (match-end 0)) ?/)
721 (goto-char (match-end 0))))
723 (or (save-excursion (setq close (sgml-beginning-of-tag)
724 close (and (stringp close)
725 (eq (aref close 0) ?/)
727 ;; not on closing tag
728 (let ((point (point)))
729 (sgml-skip-tag-backward 1)
730 (if (or (not (eq (following-char) ?<))
734 (error "Not on or before tag")))))
737 (sgml-skip-tag-backward 1)
742 (sgml-skip-tag-forward 1)
745 (if (eq (aref (sgml-beginning-of-tag) 0) ?/)
749 (setq arg (1- arg))))
751 ;; Put read-only last to enable setting this even when read-only enabled.
752 (or (get 'sgml-tag 'invisible)
754 (append '(invisible t
756 point-entered sgml-point-entered
759 (symbol-plist 'sgml-tag))))
761 (defun sgml-tags-invisible (arg)
762 "Toggle visibility of existing tags."
764 (let ((modified (buffer-modified-p))
765 (inhibit-read-only t)
766 (inhibit-modification-hooks t)
767 ;; Avoid spurious the `file-locked' checks.
768 (buffer-file-name nil)
769 ;; This is needed in case font lock gets called,
770 ;; since it moves point and might call sgml-point-entered.
771 ;; How could it get called? -stef
772 (inhibit-point-motion-hooks t)
776 (goto-char (point-min))
777 (if (set (make-local-variable 'sgml-tags-invisible)
779 (>= (prefix-numeric-value arg) 0)
780 (not sgml-tags-invisible)))
781 (while (re-search-forward "<\\([!/?A-Za-z][-A-Za-z0-9]*\\)"
784 (cdr (assq (intern-soft (downcase (match-string 1)))
786 (goto-char (match-beginning 0))
787 (and (stringp string)
788 (not (overlays-at (point)))
789 (let ((ol (make-overlay (point) (match-beginning 1))))
790 (overlay-put ol 'before-string string)
791 (overlay-put ol 'sgml-tag t)))
792 (put-text-property (point)
793 (progn (forward-list) (point))
794 'category 'sgml-tag))
795 (let ((pos (point-min)))
796 (while (< (setq pos (next-overlay-change pos)) (point-max))
797 (dolist (ol (overlays-at pos))
798 (if (overlay-get ol 'sgml-tag)
799 (delete-overlay ol)))))
800 (remove-text-properties (point-min) (point-max) '(category nil))))
801 (restore-buffer-modified-p modified))
802 (run-hooks 'sgml-tags-invisible-hook)
805 (defun sgml-point-entered (x y)
806 ;; Show preceding or following hidden tag, depending of cursor direction.
807 (let ((inhibit-point-motion-hooks t))
809 (message "Invisible tag: %s"
810 ;; Strip properties, otherwise, the text is invisible.
811 (buffer-substring-no-properties
814 (not (eq (following-char) ?<)))
816 (eq (preceding-char) ?>)))
820 (autoload 'compile-internal "compile")
822 (defun sgml-validate (command)
823 "Validate an SGML document.
824 Runs COMMAND, a shell command, in a separate process asynchronously
825 with output going to the buffer `*compilation*'.
826 You can then use the command \\[next-error] to find the next error message
827 and move to the line in the SGML document that caused it."
829 (list (read-string "Validate command: "
830 (or sgml-saved-validate-command
831 (concat sgml-validate-command
833 (let ((name (buffer-file-name)))
835 (file-name-nondirectory name))))))))
836 (setq sgml-saved-validate-command command)
837 (save-some-buffers (not compilation-ask-about-save) nil)
838 (compile-internal command "No more errors"))
841 (defun sgml-beginning-of-tag (&optional top-level)
842 "Skip to beginning of tag and return its name.
843 If this can't be done, return t."
849 (if (search-backward "<" nil t)
854 (if (looking-at "<[!?/]?[[A-Za-z][A-Za-z0-9]*")
855 (buffer-substring-no-properties
860 (defun sgml-value (alist)
861 "Interactively insert value taken from attributerule ALIST.
862 See `sgml-tag-alist' for info about attribute rules."
863 (setq alist (cdr alist))
864 (if (stringp (car alist))
865 (insert "=\"" (car alist) ?\")
866 (if (and (eq (car alist) t) (not sgml-xml))
869 (setq alist (skeleton-read '(completing-read "Value: " (cdr alist))))
870 (if (string< "" alist)
872 (delete-backward-char 2)))
875 (insert (skeleton-read '(completing-read "Value: " alist))))
878 (defun sgml-quote (start end &optional unquotep)
879 "Quote SGML text in region.
880 With prefix argument, unquote the region."
887 (while (re-search-forward "&\\(amp\\|\\(l\\|\\(g\\)\\)t\\);" end t)
888 (replace-match (if (match-end 3) ">" (if (match-end 2) "<" "&"))))
889 (while (re-search-forward "[&<>]" end t)
890 (replace-match (cdr (assq (char-before) '((?& . "&")
897 (defcustom html-mode-hook nil
898 "Hook run by command `html-mode'.
899 `text-mode-hook' and `sgml-mode-hook' are run first."
902 :options '(html-autoview-mode))
904 (defvar html-quick-keys sgml-quick-keys
905 "Use C-c X combinations for quick insertion of frequent tags when non-nil.
906 This defaults to `sgml-quick-keys'.
907 This takes effect when first loading the library.")
909 (defvar html-mode-map
910 (let ((map (make-sparse-keymap))
911 (menu-map (make-sparse-keymap "HTML")))
912 (set-keymap-parent map sgml-mode-map)
913 (define-key map "\C-c6" 'html-headline-6)
914 (define-key map "\C-c5" 'html-headline-5)
915 (define-key map "\C-c4" 'html-headline-4)
916 (define-key map "\C-c3" 'html-headline-3)
917 (define-key map "\C-c2" 'html-headline-2)
918 (define-key map "\C-c1" 'html-headline-1)
919 (define-key map "\C-c\r" 'html-paragraph)
920 (define-key map "\C-c\n" 'html-line)
921 (define-key map "\C-c\C-c-" 'html-horizontal-rule)
922 (define-key map "\C-c\C-co" 'html-ordered-list)
923 (define-key map "\C-c\C-cu" 'html-unordered-list)
924 (define-key map "\C-c\C-cr" 'html-radio-buttons)
925 (define-key map "\C-c\C-cc" 'html-checkboxes)
926 (define-key map "\C-c\C-cl" 'html-list-item)
927 (define-key map "\C-c\C-ch" 'html-href-anchor)
928 (define-key map "\C-c\C-cn" 'html-name-anchor)
929 (define-key map "\C-c\C-ci" 'html-image)
930 (when html-quick-keys
931 (define-key map "\C-c-" 'html-horizontal-rule)
932 (define-key map "\C-co" 'html-ordered-list)
933 (define-key map "\C-cu" 'html-unordered-list)
934 (define-key map "\C-cr" 'html-radio-buttons)
935 (define-key map "\C-cc" 'html-checkboxes)
936 (define-key map "\C-cl" 'html-list-item)
937 (define-key map "\C-ch" 'html-href-anchor)
938 (define-key map "\C-cn" 'html-name-anchor)
939 (define-key map "\C-ci" 'html-image))
940 (define-key map "\C-c\C-s" 'html-autoview-mode)
941 (define-key map "\C-c\C-v" 'browse-url-of-buffer)
942 (define-key map [menu-bar html] (cons "HTML" menu-map))
943 (define-key menu-map [html-autoview-mode]
944 '("Toggle Autoviewing" . html-autoview-mode))
945 (define-key menu-map [browse-url-of-buffer]
946 '("View Buffer Contents" . browse-url-of-buffer))
947 (define-key menu-map [nil] '("--"))
948 ;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
949 ;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
950 ;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
951 (define-key menu-map "3" '("Heading 3" . html-headline-3))
952 (define-key menu-map "2" '("Heading 2" . html-headline-2))
953 (define-key menu-map "1" '("Heading 1" . html-headline-1))
954 (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
955 (define-key menu-map "c" '("Checkboxes" . html-checkboxes))
956 (define-key menu-map "l" '("List Item" . html-list-item))
957 (define-key menu-map "u" '("Unordered List" . html-unordered-list))
958 (define-key menu-map "o" '("Ordered List" . html-ordered-list))
959 (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
960 (define-key menu-map "\n" '("Line Break" . html-line))
961 (define-key menu-map "\r" '("Paragraph" . html-paragraph))
962 (define-key menu-map "i" '("Image" . html-image))
963 (define-key menu-map "h" '("Href Anchor" . html-href-anchor))
964 (define-key menu-map "n" '("Name Anchor" . html-name-anchor))
966 "Keymap for commands for use in HTML mode.")
969 (defvar html-face-tag-alist
974 "Value of `sgml-face-tag-alist' for HTML mode.")
976 (defvar html-tag-face-alist
979 ("blink" . highlight)
982 ("h1" bold underline)
983 ("h2" bold-italic underline)
984 ("h3" italic underline)
993 ("title" bold underline)
997 "Value of `sgml-tag-face-alist' for HTML mode.")
1000 (defvar html-display-text
1004 "Value of `sgml-display-text' for HTML mode.")
1007 ;; should code exactly HTML 3 here when that is finished
1008 (defvar html-tag-alist
1009 (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
1010 (1-9 `(,@1-7 ("8") ("9")))
1011 (align '(("align" ("left") ("center") ("right"))))
1012 (valign '(("top") ("middle") ("bottom") ("baseline")))
1013 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
1014 (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
1015 ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:")
1016 ("wais:") ("/cgi-bin/")))
1022 (list '((nil \n ("List item: " "<li>" str
1023 (if sgml-xml "</li>") \n))))
1030 ;; put ,-expressions first, else byte-compile chokes (as of V19.29)
1031 ;; and like this it's more efficient anyway
1032 `(("a" ,name ,@link)
1035 ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
1036 ("form" (\n _ \n "<input type=\"submit\" value=\"\""
1037 (if sgml-xml "/>" ">"))
1038 ("action" ,@(cdr href)) ("method" ("get") ("post")))
1045 ("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
1046 ("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
1047 ("src") ("alt") ("width" "1") ("height" "1")
1048 ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
1049 ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name
1050 ("type" ("text") ("password") ("checkbox") ("radio")
1051 ("submit") ("reset"))
1055 ("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1")))
1059 "<option>" str (if sgml-xml "</option>") \n))
1060 ,name ("size" ,@1-9) ("multiple" t))
1062 ((completing-read "Cell kind: " '(("td") ("th"))
1065 (if sgml-xml (concat "<" str "></tr>")) \n))
1066 ("border" t ,@1-9) ("width" "10") ("cellpadding"))
1068 ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
1070 ("ul" ,@list ("type" ("disc") ("circle") ("square")))
1078 ("Item: " "<item>" str (if sgml-xml "</item>") \n))
1085 ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
1086 ("link" "#") ("alink" "#") ("vlink" "#"))
1087 ("box" (nil _ "<over>" _ (if sgml-xml "</over>")))
1088 ("br" t ("clear" ("left") ("right")))
1089 ("caption" ("valign" ("top") ("bottom")))
1093 ("dd" ,(not sgml-xml))
1099 "<dt>" str (if sgml-xml "</dt>")
1100 "<dd>" _ (if sgml-xml "</dd>") \n)))
1101 ("dt" (t _ (if sgml-xml "</dt>")
1102 "<dd>" (if sgml-xml "</dd>") \n))
1104 ;("fn" "id" "fn") ; ???
1108 "<title>" (setq str (read-input "Title: ")) "</title>\n"
1110 "<body>\n<h1>" str "</h1>\n" _
1111 "\n<address>\n<a href=\"mailto:"
1113 "\">" (user-full-name) "</a>\n</address>\n"
1118 ("isindex" t ("action") ("prompt"))
1121 ("li" ,(not sgml-xml))
1124 ("option" t ("value") ("label") ("selected" t))
1153 "*Value of `sgml-tag-alist' for HTML mode.")
1155 (defvar html-tag-help
1157 ("a" . "Anchor of point or link elsewhere")
1160 ("address" . "Formatted mail address")
1161 ("array" . "Math array")
1164 ("base" . "Base address for URLs")
1165 ("big" . "Font size")
1166 ("blink" . "Blinking text")
1167 ("blockquote" . "Indented quotation")
1168 ("body" . "Document body")
1169 ("box" . "Math fraction")
1170 ("br" . "Line break")
1171 ("caption" . "Table caption")
1172 ("center" . "Centered text")
1173 ("changed" . "Change bars")
1174 ("cite" . "Citation of a document")
1175 ("code" . "Formatted source code")
1176 ("dd" . "Definition of term")
1179 ("dir" . "Directory list (obsolete)")
1180 ("dl" . "Definition list")
1181 ("dt" . "Term to be definined")
1182 ("em" . "Emphasised")
1183 ("embed" . "Embedded data in foreign format")
1185 ("figa" . "Figure anchor")
1186 ("figd" . "Figure description")
1187 ("figt" . "Figure text")
1189 ("font" . "Font size")
1190 ("form" . "Form with input fields")
1191 ("group" . "Document grouping")
1192 ("h1" . "Most important section headline")
1193 ("h2" . "Important section headline")
1194 ("h3" . "Section headline")
1195 ("h4" . "Minor section headline")
1196 ("h5" . "Unimportant section headline")
1197 ("h6" . "Least important section headline")
1198 ("head" . "Document header")
1199 ("hr" . "Horizontal rule")
1200 ("html" . "HTML Document")
1201 ("i" . "Italic face")
1202 ("img" . "Graphic image")
1203 ("input" . "Form input field")
1205 ("isindex" . "Input field for index search")
1206 ("kbd" . "Keybard example face")
1207 ("lang" . "Natural language")
1208 ("li" . "List item")
1209 ("link" . "Link relationship")
1210 ("math" . "Math formula")
1211 ("menu" . "Menu list (obsolete)")
1212 ("mh" . "Form mail header")
1213 ("nextid" . "Allocate new id")
1214 ("nobr" . "Text without line break")
1215 ("ol" . "Ordered list")
1216 ("option" . "Selection list item")
1217 ("over" . "Math fraction rule")
1218 ("p" . "Paragraph start")
1219 ("panel" . "Floating panel")
1221 ("pre" . "Preformatted fixed width text")
1223 ("rev" . "Reverse video")
1225 ("samp" . "Sample text")
1226 ("select" . "Selection list")
1227 ("small" . "Font size")
1228 ("sp" . "Nobreak space")
1229 ("strong" . "Standout text")
1230 ("sub" . "Subscript")
1231 ("sup" . "Superscript")
1232 ("table" . "Table with rows and columns")
1233 ("tb" . "Table vertical break")
1234 ("td" . "Table data cell")
1235 ("textarea" . "Form multiline edit area")
1236 ("th" . "Table header cell")
1237 ("title" . "Document title")
1238 ("tr" . "Table row separator")
1239 ("tt" . "Typewriter face")
1240 ("u" . "Underlined text")
1241 ("ul" . "Unordered list")
1242 ("var" . "Math variable face")
1243 ("wbr" . "Enable <br> within <nobr>"))
1244 "*Value of `sgml-tag-help' for HTML mode.")
1247 (define-derived-mode html-mode sgml-mode "HTML"
1248 "Major mode based on SGML mode for editing HTML documents.
1249 This allows inserting skeleton constructs used in hypertext documents with
1250 completion. See below for an introduction to HTML. Use
1251 \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
1252 which this is based.
1254 Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
1256 To write fairly well formatted pages you only need to know few things. Most
1257 browsers have a function to read the source code of the page being seen, so
1258 you can imitate various tricks. Here's a very short HTML primer which you
1259 can also view with a browser to see what happens:
1261 <title>A Title Describing Contents</title> should be on every page. Pages can
1262 have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6>
1263 <hr> Parts can be separated with horizontal rules.
1265 <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
1266 ignored unless the text is <pre>preformatted.</pre> Text can be marked as
1267 <b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-g or
1268 Edit/Text Properties/Face commands.
1270 Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
1271 to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a
1272 href=\"URL\">see also URL</a> where URL is a filename relative to current
1273 directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'.
1275 Images in many formats can be inlined with <img src=\"URL\">.
1277 If you mainly create your own documents, `sgml-specials' might be
1278 interesting. But note that some HTML 2 browsers can't handle `''.
1279 To work around that, do:
1280 (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
1283 (set (make-local-variable 'sgml-display-text) html-display-text)
1284 (set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist)
1285 (make-local-variable 'sgml-tag-alist)
1286 (make-local-variable 'sgml-face-tag-alist)
1287 (make-local-variable 'sgml-tag-help)
1288 (make-local-variable 'outline-regexp)
1289 (make-local-variable 'outline-heading-end-regexp)
1290 (make-local-variable 'outline-level)
1291 (make-local-variable 'sentence-end)
1293 (if sentence-end-double-space
1294 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\| \\)[ \t\n]*"
1295 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\|[ \t]\\)[ \t\n]*"))
1296 (setq sgml-tag-alist html-tag-alist
1297 sgml-face-tag-alist html-face-tag-alist
1298 sgml-tag-help html-tag-help
1299 outline-regexp "^.*<[Hh][1-6]\\>"
1300 outline-heading-end-regexp "</[Hh][1-6]>"
1301 outline-level (lambda ()
1302 (char-after (1- (match-end 0)))))
1303 (setq imenu-create-index-function 'html-imenu-index)
1304 (when sgml-xml (setq mode-name "XHTML"))
1305 (set (make-local-variable 'sgml-empty-tags)
1306 '("br" "hr" "img" "input" "area" "link" "param" "col"
1307 "base" "meta" "basefont" "frame" "isindex" "wbr"))
1308 ;; It's for the user to decide if it defeats it or not -stef
1309 ;; (make-local-variable 'imenu-sort-function)
1310 ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
1313 (defvar html-imenu-regexp
1314 "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
1315 "*A regular expression matching a head line to be added to the menu.
1316 The first `match-string' should be a number from 1-9.
1317 The second `match-string' matches extra tags and is ignored.
1318 The third `match-string' will be the used in the menu.")
1320 (defun html-imenu-index ()
1321 "Return an table of contents for an HTML buffer for use with Imenu."
1324 (goto-char (point-min))
1325 (while (re-search-forward html-imenu-regexp nil t)
1327 (cons (cons (concat (make-string
1328 (* 2 (1- (string-to-number (match-string 1))))
1331 (line-beginning-position))
1333 (nreverse toc-index)))
1335 (defun html-autoview-mode (&optional arg)
1336 "Toggle automatic viewing via `browse-url-of-buffer' upon saving buffer.
1337 With positive prefix ARG always turns viewing on, with negative ARG always off.
1338 Can be used as a value for `html-mode-hook'."
1340 (if (setq arg (if arg
1341 (< (prefix-numeric-value arg) 0)
1342 (and (boundp 'after-save-hook)
1343 (memq 'browse-url-of-buffer after-save-hook))))
1344 (setq after-save-hook (delq 'browse-url-of-buffer after-save-hook))
1345 (add-hook 'after-save-hook 'browse-url-of-buffer nil t))
1346 (message "Autoviewing turned %s."
1347 (if arg "off" "on")))
1349 (define-skeleton html-href-anchor
1350 "HTML anchor tag with href attribute."
1352 '(setq input "http:")
1353 "<a href=\"" str "\">" _ "</a>")
1355 (define-skeleton html-name-anchor
1356 "HTML anchor tag with name attribute."
1358 "<a name=\"" str "\">" _ "</a>")
1360 (define-skeleton html-headline-1
1361 "HTML level 1 headline tags."
1365 (define-skeleton html-headline-2
1366 "HTML level 2 headline tags."
1370 (define-skeleton html-headline-3
1371 "HTML level 3 headline tags."
1375 (define-skeleton html-headline-4
1376 "HTML level 4 headline tags."
1380 (define-skeleton html-headline-5
1381 "HTML level 5 headline tags."
1385 (define-skeleton html-headline-6
1386 "HTML level 6 headline tags."
1390 (define-skeleton html-horizontal-rule
1391 "HTML horizontal rule tag."
1393 (if sgml-xml "<hr/>" "<hr>") \n)
1395 (define-skeleton html-image
1398 "<img src=\"" _ "\""
1399 (if sgml-xml "/>" ">"))
1401 (define-skeleton html-line
1402 "HTML line break tag."
1404 (if sgml-xml "<br/>" "<br>") \n)
1406 (define-skeleton html-ordered-list
1407 "HTML ordered list tags."
1410 "<li>" _ (if sgml-xml "</li>") \n
1413 (define-skeleton html-unordered-list
1414 "HTML unordered list tags."
1417 "<li>" _ (if sgml-xml "</li>") \n
1420 (define-skeleton html-list-item
1421 "HTML list item tag."
1424 "<li>" _ (if sgml-xml "</li>"))
1426 (define-skeleton html-paragraph
1427 "HTML paragraph tag."
1430 \n "<p>" _ (if sgml-xml "</p>"))
1432 (define-skeleton html-checkboxes
1433 "Group of connected checkbox inputs."
1438 "<input type=\"" (identity "checkbox") ; see comment above about identity
1439 "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
1440 "\" value=\"" str ?\"
1441 (when (y-or-n-p "Set \"checked\" attribute? ")
1442 (funcall skeleton-transformation " checked"))
1443 (if sgml-xml "/>" ">")
1444 (skeleton-read "Text: " (capitalize str))
1445 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
1446 (funcall skeleton-transformation
1447 (if sgml-xml "<br/>" "<br>"))
1451 (define-skeleton html-radio-buttons
1452 "Group of connected radio button inputs."
1457 "<input type=\"" (identity "radio") ; see comment above about identity
1458 "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
1459 "\" value=\"" str ?\"
1460 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
1461 (funcall skeleton-transformation " checked"))
1462 (if sgml-xml "/>" ">")
1463 (skeleton-read "Text: " (capitalize str))
1464 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
1465 (funcall skeleton-transformation
1466 (if sgml-xml "<br/>" "<br>"))
1470 (provide 'sgml-mode)
1472 ;;; sgml-mode.el ends here