Function: m2-smie-rules

m2-smie-rules is a byte-compiled function defined in modula2.el.gz.

Signature

(m2-smie-rules KIND TOKEN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/modula2.el.gz
(defun m2-smie-rules (kind token)
  ;; FIXME: Apparently, the usual indentation convention is something like:
  ;;
  ;;    TYPE t1 = bar;
  ;;    VAR x : INTEGER;
  ;;    PROCEDURE f ();
  ;;    TYPE t2 = foo;
  ;;      PROCEDURE g ();
  ;;      BEGIN blabla END;
  ;;    VAR y : type;
  ;;    BEGIN blibli END
  ;;
  ;; This is inconsistent with the actual structure of the code in 2 ways:
  ;; - The inner VAR/TYPE are indented just like the outer VAR/TYPE.
  ;; - The inner PROCEDURE is not aligned with its VAR/TYPE siblings.
  (pcase (cons kind token)
    ('(:elem . basic) m2-indent)
    ('(:after . ":=") (or m2-indent smie-indent-basic))
    (`(:after . ,(or "CONST" "VAR" "TYPE"))
     (or m2-indent smie-indent-basic))
    ;; (`(:before . ,(or `"VAR" `"TYPE" `"CONST"))
    ;;  (if (smie-rule-parent-p "PROCEDURE") 0))
    ('(:after . ";-block")
     (if (smie-rule-parent-p "PROCEDURE")
         (smie-rule-parent (or m2-indent smie-indent-basic))))
    ('(:before . "|") (smie-rule-separator kind))
    ))