Function: combobulate-maybe-auto-close-tag

combobulate-maybe-auto-close-tag is an interactive and natively compiled function defined in combobulate-html.el.

Signature

(combobulate-maybe-auto-close-tag)

Documentation

Insert > or maybe insert the closing tag.

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
(defun combobulate-maybe-auto-close-tag ()
  "Insert `>' or maybe insert the closing tag."
  (interactive)
  (self-insert-command 1 ?>)
  (save-excursion
    (forward-char -1)
    (when (not (eq ?/ (char-before)))
      (let ((open-node (combobulate-node-at-point (list combobulate-sgml-open-tag))))
        ;; only attempt an expansion if we are not inside one of the exempted tags.
        (when (and open-node
                   (= (combobulate-node-end open-node) (1+ (point)))
                   (not (combobulate-node-contains-node-p
                         (combobulate-node-at-point combobulate-sgml-exempted-tags)
                         open-node)))
          (forward-char 1)
          (insert (format "</%s>" (combobulate-node-text
                                   (or
                                    ;; for tsx/jsx
                                    (combobulate-node-child-by-field
                                     open-node "name")
                                    ;; for `html'
                                    (combobulate-node-child
                                     open-node 0))))))))))