Function: sgml-tag
sgml-tag is an interactive and byte-compiled function defined in
sgml-mode.el.gz.
Signature
(sgml-tag &optional STR ARG)
Documentation
Prompt for a tag and insert it, optionally with attributes.
Completion and configuration are done according to sgml-tag-alist.
If you like tags and attributes in uppercase, customize
sgml-transformation-function to upcase.
This is a skeleton command (see skeleton-insert).
Normally the skeleton text is inserted at point, with nothing "inside".
If there is a highlighted region, the skeleton text is wrapped
around the region text.
A prefix argument ARG says to wrap the skeleton around the next ARG words. A prefix argument of -1 says to wrap around region, even if not highlighted. A prefix argument of zero says to wrap around zero words---that is, nothing. This is a way of overriding the use of a highlighted region.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/sgml-mode.el.gz
(define-skeleton sgml-tag
"Prompt for a tag and insert it, optionally with attributes.
Completion and configuration are done according to `sgml-tag-alist'.
If you like tags and attributes in uppercase, customize
`sgml-transformation-function' to `upcase'."
(funcall (or skeleton-transformation-function 'identity)
(setq sgml-tag-last
(completing-read
(if (> (length sgml-tag-last) 0)
(format-prompt "Tag" sgml-tag-last)
"Tag: ")
sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last)))
?< str |
(("") -1 '(undo-boundary) (identity "<")) | ; see comment above
`(("") '(setq v2 (sgml-attributes ,str t)) ?>
(cond
((string= "![" ,str)
(backward-char)
'(("") " [ " _ " ]]"))
((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags))
'(("") -1 " />"))
((or (and (eq v2 t) (not sgml-xml-mode)) (string-match "^[/!?]" ,str))
nil)
((symbolp v2)
;; Make sure we don't fall into an infinite loop.
;; For xhtml's `tr' tag, we should maybe use \n instead.
(if (eq v2 t) (setq v2 nil))
;; We use `identity' to prevent skeleton from passing
;; `str' through `skeleton-transformation-function' a second time.
'(("") v2 _ v2 "</" (identity ',str) ?> >))
((eq (car v2) t)
(cons '("") (cdr v2)))
(t
(append '(("") (car v2))
(cdr v2)
'(resume: (car v2) _ "</" (identity ',str) ?> >))))))