Function: web-mode-block-statement-beginning-position

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

Signature

(web-mode-block-statement-beginning-position POS BLOCK-BEG IS-TERNARY)

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-statement-beginning-position (pos block-beg _is-ternary)
  (unless pos (setq pos (point)))
  (setq pos (1- pos))
  (unless block-beg (setq block-beg (web-mode-block-beginning-position pos)))
  (let (char (continue (not (null pos))))
    (while continue
      (setq char (char-after pos))
      (cond
        ((< pos block-beg)
         (setq continue nil
               pos block-beg))
        ((and (member (get-text-property pos 'block-token) '(string comment))
              (eq (get-text-property pos 'block-token) (get-text-property (1- pos) 'block-token)))
         (setq pos (web-mode-block-token-beginning-position pos)))
        ((member char '(?\) ?\] ?\}))
         (setq pos (web-mode-block-opening-paren-position pos block-beg))
         (setq pos (1- pos)))
        ((and (eq char ?\=)
              (web-mode-looking-back "[<>!=]+" pos block-beg t))
         (setq pos (- pos 1 (length (match-string-no-properties 0))))
         ;;(setq pos (1- pos))
         ;;(message "%S pos=%S" (match-string-no-properties 0) pos)
         )
        ((member char '(?\( ?\[ ?\{ ?\=))
         (setq continue nil)
         (web-mode-looking-at ".[ \t\n]*" pos)
         (setq pos (+ pos (length (match-string-no-properties 0)))))
        ((web-mode-looking-at "\\(return\\|echo\\|include\\|print\\)[ \n]" pos)
         (setq pos (+ pos (length (match-string-no-properties 0)))
               continue nil))
        (t
         (setq pos (web-mode-rsb-position pos "[\]\[}{)(=]\\|\\(return\\|echo\\|include\\|print\\)" block-beg))
         (when (not pos)
           (message "block-statement-beginning-position ** search failure **")
           (setq continue nil
                 pos block-beg)))
        ) ;cond
      ) ;while
    pos))