Function: web-mode-block-close
web-mode-block-close is an interactive and natively compiled function
defined in web-mode.el.
Signature
(web-mode-block-close &optional POS)
Documentation
Close the first unclosed control block.
Key Bindings
web-mode-map C-c C-b c
Source Code
;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-block-close (&optional pos)
"Close the first unclosed control block."
(interactive)
(unless pos (setq pos (point)))
(let ((continue t)
(h (make-hash-table :test 'equal)) ctx ctrl n closing-block)
(save-excursion
(while (and continue (web-mode-block-previous))
(when (setq ctx (web-mode-block-is-control (point)))
(setq ctrl (car ctx))
(setq n (gethash ctrl h 0))
(if (cdr ctx)
(puthash ctrl (1+ n) h)
(puthash ctrl (1- n) h))
(when (> (gethash ctrl h) 0)
(setq continue nil))
)
) ;while
) ;save-excursion
(when (and (null continue)
(setq closing-block (web-mode-closing-block ctrl)))
(insert closing-block)
(indent-according-to-mode))
))