Function: web-mode-element-parent-position

web-mode-element-parent-position is a natively compiled function defined in web-mode.el.

Signature

(web-mode-element-parent-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-element-parent-position (&optional pos)
  (let (n tag-type tag-name (continue t) (tags (make-hash-table :test 'equal)))
    (save-excursion
      (if pos (goto-char pos))
      (while (and continue (web-mode-tag-previous))
        (setq pos (point)
              tag-type (get-text-property pos 'tag-type)
              tag-name (get-text-property pos 'tag-name)
              n (gethash tag-name tags 0))
        (when (member tag-type '(end start))
          (if (eq tag-type 'end)
              (puthash tag-name (1- n) tags)
              (puthash tag-name (1+ n) tags)
              (when (= n 0) (setq continue nil))
              ) ;if
          ) ;when
        ) ;while
      ) ;save-excursion
    (if (null continue) pos nil)))