+ (and (smie-rule-bolp) (smie-rule-parent-p "(") (smie-rule-parent 0)))
+ (`(:after . ,(or `"->" `"*->"))
+ ;; We distinguish
+ ;;
+ ;; (a ->
+ ;; b;
+ ;; c)
+ ;; and
+ ;; ( a ->
+ ;; b
+ ;; ; c)
+ ;;
+ ;; based on the space between the open paren and the "a".
+ (unless (and (smie-rule-parent-p "(" ";")
+ (save-excursion
+ (smie-indent-forward-token)
+ (smie-backward-sexp 'halfsexp)
+ (if (smie-rule-parent-p "(")
+ (not (eq (char-before) ?\())
+ (smie-indent-backward-token)
+ (smie-rule-bolp))))
+ prolog-indent-width))
+ (`(:after . ";")
+ ;; Align with same-line comment as in:
+ ;; ; %% Toto
+ ;; foo
+ (and (smie-rule-bolp)
+ (looking-at ";[ \t]*\\(%\\)")
+ (let ((offset (- (save-excursion (goto-char (match-beginning 1))
+ (current-column))
+ (current-column))))
+ ;; Only do it for small offsets, since the comment may actually be
+ ;; an "end-of-line" comment at comment-column!
+ (if (<= offset prolog-indent-width) offset))))
+ (`(:after . ",")
+ ;; Special indent for:
+ ;; foopredicate(x) :- !,
+ ;; toto.
+ (and (eq (char-before) ?!)
+ (save-excursion
+ (smie-indent-backward-token) ;Skip !
+ (equal ":-" (car (smie-indent-backward-token))))
+ (smie-rule-parent prolog-indent-width)))
+ (`(:after . ":-")
+ (if (bolp)
+ (save-excursion
+ (smie-indent-forward-token)
+ (skip-chars-forward " \t")
+ (if (eolp)
+ prolog-indent-width
+ (min prolog-indent-width (current-column))))
+ prolog-indent-width))
+ (`(:after . "-->") prolog-indent-width)))