Function: combobulate-maybe-insert-attribute
combobulate-maybe-insert-attribute is an interactive and natively
compiled function defined in combobulate-html.el.
Signature
(combobulate-maybe-insert-attribute)
Documentation
Insert = or maybe a an attribute.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-html.el
;; Note: brittle.
;; (defun combobulate-maybe-close-tag-or-self-insert ()
;; "Insert `/' or maybe close the nearest unopened tag."
;; (interactive)
;; (cl-flet ((get-text (node closing)
;; (if (equal (combobulate-parser-language (combobulate-parser-node node)) 'html)
;; (thread-first node
;; (combobulate-node-child
;; (if (equal field combobulate-sgml-close-tag)
;; -1
;; 0))
;; (combobulate-node-child 0)
;; (combobulate-node-text))
;; (thread-first node
;; (combobulate-node-child-by-field
;; (if closing "close_tag" "open_tag"))
;; (combobulate-node-child-by-field "name")
;; (combobulate-node-text)))))
;; (if (looking-back "<" 1)
;; (progn
;; (let* ((element (combobulate-node-at-point (list combobulate-sgml-whole-tag))))
;; (if (equal (get-text element nil)
;; (get-text element t))
;; (self-insert-command 1 ?/)
;; (combobulate-message "Closing node" element)
;; (combobulate-pulse-node (combobulate-node-child element 0))
;; (insert (format "/%s>" (get-text element combobulate-sgml-open-tag))))))
;; (self-insert-command 1 ?/))))
(defun combobulate-maybe-insert-attribute ()
"Insert `=' or maybe a an attribute."
(interactive)
(if-let ((node (combobulate-node-at-point (list combobulate-sgml-open-tag
combobulate-sgml-self-closing-tag))))
;; Expanding an attribute is only desirable if we are inside an
;; open (or self-closing) node, but *also not* inside a node
;; type in `combobulate-sgml-exempted-tags' which happens to be
;; inside one of those node types.
(if (combobulate-node-contains-node-p
(combobulate-node-at-point combobulate-sgml-exempted-tags)
node)
(self-insert-command 1 ?=)
(combobulate-atomic-change-group
(catch 'done
(unless (equal (combobulate-parser-language (combobulate-parser-node node)) 'html)
(pcase-dolist (`(,attribute . ,envelope) (combobulate-read attribute-envelope-alist))
(when (looking-back (concat "\\<" attribute "\\>") (length attribute))
(combobulate-execute-envelope envelope node)
(throw 'done t))))
;; catch flagrant, out-of-place uses of `='.
(if (looking-back "[[:alpha:]]" 1)
(cond
;; html can only do strings, so just use that.
((equal (combobulate-parser-language (combobulate-parser-node node)) 'html)
(combobulate-execute-envelope "attr-string" node))
((combobulate-read attribute-envelope-default)
(combobulate-execute-envelope (combobulate-read attribute-envelope-default) node))
(t (self-insert-command 1 ?=)))
(self-insert-command 1 ?=)))))
(self-insert-command 1 ?=)))