Function: sgml-attributes
sgml-attributes is an interactive and byte-compiled function defined
in sgml-mode.el.gz.
Signature
(sgml-attributes TAG &optional QUIET)
Documentation
When at top level of a tag, interactively insert attributes.
Completion and configuration of TAG are done according to sgml-tag-alist.
If QUIET, do not print a message when there are no attributes for TAG.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/sgml-mode.el.gz
(defun sgml-attributes (tag &optional quiet)
"When at top level of a tag, interactively insert attributes.
Completion and configuration of TAG are done according to `sgml-tag-alist'.
If QUIET, do not print a message when there are no attributes for TAG."
(interactive (list (save-excursion (sgml-beginning-of-tag t))))
(or (stringp tag) (error "Wrong context for adding attribute"))
(if tag
(let ((completion-ignore-case t)
(alist (cdr (assoc (downcase tag) sgml-tag-alist)))
car attribute i)
(if (or (symbolp (car alist))
(symbolp (car (car alist))))
(setq car (car alist)
alist (cdr alist)))
(unless (or alist quiet)
(message "No attributes configured."))
(when alist
;; Add class and id attributes if a) the element has any
;; other attributes configured, and b) they're not already
;; present.
(unless (assoc-string "class" alist)
(setq alist (cons '("class") alist)))
(unless (assoc-string "id" alist)
(setq alist (cons '("id") alist))))
(require 'skeleton)
(if (stringp (car alist))
(progn
(insert (if (eq (preceding-char) ?\s) "" ?\s)
(funcall skeleton-transformation-function (car alist)))
(sgml-value alist))
(setq i (length alist))
(while (> i 0)
(insert ?\s)
(insert (funcall skeleton-transformation-function
(setq attribute
(skeleton-read (lambda ()
(completing-read
"Attribute: "
alist))))))
(if (string= "" attribute)
(setq i 0)
(sgml-value (assoc (downcase attribute) alist))
(setq i (1- i))))
(if (eq (preceding-char) ?\s)
(delete-char -1)))
car)))