Function: web-mode-block-opening-paren-position

web-mode-block-opening-paren-position is a natively compiled function defined in web-mode.el.

Signature

(web-mode-block-opening-paren-position POS LIMIT)

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-opening-paren-position (pos limit)
  (save-excursion
    (when (> limit pos)
      (message "block-opening-paren-position: limit(%S) > pos(%S)" limit pos))
    (goto-char pos)
    (let (c
          n
          pt
          (continue (> pos limit))
          (pairs '((?\) . ?\()
                   (?\] . ?\[)
                   (?\} . ?\{)))
          (h (make-hash-table :test 'equal))
          (regexp "[\]\[)(}{]"))
      (while (and continue (re-search-backward regexp limit t))
        (cond
          ((web-mode-is-comment-or-string)
           )
          (t
           (setq c (char-after))
           (cond
             ((member c '(?\( ?\{ ?\[))
              (setq n (gethash c h 0))
              (if (= n 0)
                  (setq continue nil
                        pt (point))
                  (puthash c (1+ n) h)
                  ))
             (t
              (setq c (cdr (assoc c pairs)))
              (setq n (gethash c h 0))
              (puthash c (1- n) h))
             ) ;cond
           ) ;t
          ) ;cond
        ) ;while
      pt)))