Function: web-mode-tag-match

web-mode-tag-match is an interactive and natively compiled function defined in web-mode.el.

Signature

(web-mode-tag-match &optional POS)

Documentation

Move point to the matching opening/closing tag.

Key Bindings

web-mode-map C-c C-t m

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-tag-match (&optional pos)
  "Move point to the matching opening/closing tag."
  (interactive)
  (unless pos (setq pos (point)))
  (let (regexp name)
    (cond
      ((eq (get-text-property pos 'tag-type) 'void)
       (web-mode-tag-beginning))
      ((and (eq (get-text-property pos 'tag-type) 'comment)
            (web-mode-looking-at-p "<!--#\\(elif\\|else\\|endif\\|if\\)" pos))
       (setq regexp "<!--#\\(end\\)?if")
       (if (web-mode-looking-at-p "<!--#if" pos)
           (web-mode-tag-fetch-closing regexp pos)
           (web-mode-tag-fetch-opening regexp pos))
       )
      (t
       (setq name (get-text-property pos 'tag-name))
       (when (string= name "_fragment_") (setq name ">"))
       (setq regexp (concat "</?" name))
       (when (member (get-text-property pos 'tag-type) '(start end))
         (web-mode-tag-beginning)
         (setq pos (point)))
       (if (eq (get-text-property pos 'tag-type) 'end)
           (web-mode-tag-fetch-opening regexp pos)
           (web-mode-tag-fetch-closing regexp pos))
       ) ;t
      ) ;cond
    t))