Function: sh-smie-rc-rules

sh-smie-rc-rules is a byte-compiled function defined in sh-script.el.gz.

Signature

(sh-smie-rc-rules KIND TOKEN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sh-script.el.gz
(defun sh-smie-rc-rules (kind token)
  (pcase (cons kind token)
    ('(:elem . basic) sh-basic-offset)
    ;; (`(:after . "case") (or sh-basic-offset smie-indent-basic))
    ('(:after . ";")
     (if (smie-rule-parent-p "case")
         (smie-rule-parent (sh-var-value 'sh-indent-after-case))))
    ('(:before . "{")
     (save-excursion
       (when (sh-smie--rc-after-special-arg-p)
         `(column . ,(current-column)))))
    (`(:before . ,(or "(" "{" "["))
     (if (smie-rule-hanging-p) (smie-rule-parent)))
    ;; FIXME: SMIE parses "if (exp) cmd" as "(if ((exp) cmd))" so "cmd" is
    ;; treated as an arg to (exp) by default, which indents it all wrong.
    ;; To handle it right, we should extend smie-indent-exps so that the
    ;; preceding keyword can give special rules.  Currently the only special
    ;; rule we have is the :list-intro hack, which we use here to align "cmd"
    ;; with "(exp)", which is rarely the right thing to do, but is better
    ;; than nothing.
    (`(:list-intro . ,(or "for" "if" "while")) t)
    ;; sh-indent-after-switch: handled implicitly by the default { rule.
    ))