Function: web-mode-bracket-indentation

web-mode-bracket-indentation is a natively compiled function defined in web-mode.el.

Signature

(web-mode-bracket-indentation POS INITIAL-COLUMN LANGUAGE-OFFSET LANGUAGE &optional 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-bracket-indentation (pos initial-column language-offset language &optional limit)
  (save-excursion
    (let* ((ctx (web-mode-bracket-up pos language limit))
           (char (plist-get ctx :char))
           (pos (plist-get ctx :pos))
           (indentation (plist-get ctx :indentation)))
      ;;(message "pos(%S) initial-column(%S) language-offset(%S) language(%S) limit(%S)" pos initial-column language-offset language limit)
      ;;(message "bracket-up: %S, %c" ctx char)
      (cond
        ((null pos)
         (setq indentation initial-column))
        ((and (member language '("php"))
              (eq char ?\{)
              (web-mode-looking-back "switch[ ]*" pos)
              (not (looking-at-p "case\\|default")))
         (setq indentation (+ indentation (* language-offset 2)))
         )
        ((and (member language '("php"))
              (eq char ?\{)
              (goto-char pos)
              (web-mode-looking-back "[)][ ]*" pos)
              (search-backward ")")
              (web-mode-block-opening-paren limit))
         (setq indentation (+ (current-indentation) language-offset))
         )
        (t
         (setq indentation (+ indentation language-offset))
         )
        ) ;cond
      (cons (if (< indentation initial-column) initial-column indentation) ctx)
      )))