Function: web-mode-tag-beginning-position

web-mode-tag-beginning-position is a natively compiled function defined in web-mode.el.

Signature

(web-mode-tag-beginning-position &optional POS)

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-beginning-position (&optional pos)
  (unless pos (setq pos (point)))
  (let (beg depth)
    (setq depth (get-text-property pos 'jsx-depth))
    (when (and depth (get-text-property pos 'tag-attr-beg))
      (setq depth (get-text-property (1- pos) 'jsx-depth)))
    (cond
      ((null pos))
      ((get-text-property pos 'tag-beg)
       (setq beg pos))
      ((and (> pos 1) (get-text-property (1- pos) 'tag-beg))
       (setq beg (1- pos)))
      ((get-text-property pos 'tag-type)
       (setq beg (previous-single-property-change pos 'tag-beg))
       (when beg (setq beg (1- beg)))
       (cond
         ((not (get-text-property beg 'tag-beg))
          (setq beg nil))
         ((and depth (not (eq depth (get-text-property beg 'jsx-depth))))
          (let ((continue (> beg (point-min))))
            (while continue
              (setq beg (previous-single-property-change beg 'tag-beg))
              (when beg (setq beg (1- beg)))
              (cond
                ((null beg)
                 (setq continue nil))
                ((not (get-text-property beg 'tag-beg))
                 (setq continue nil
                       beg nil))
                ((eq depth (get-text-property beg 'jsx-depth))
                 (setq continue nil))
                ) ;cond
              ) ;while
            ) ;let
          )
         ) ;cond
       )
      (t
       (setq beg nil))
      ) ;cond
    beg))