Function: prolog-smie-rules
prolog-smie-rules is a byte-compiled function defined in prolog.el.gz.
Signature
(prolog-smie-rules KIND TOKEN)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/prolog.el.gz
(defun prolog-smie-rules (kind token)
(pcase (cons kind token)
('(:elem . basic) prolog-indent-width)
;; The list of arguments can never be on a separate line!
(`(:list-intro . ,_) t)
;; When we don't know how to indent an empty line, assume the most
;; likely token will be ";".
('(:elem . empty-line-token) ";")
('(:after . ".") '(column . 0)) ;; To work around smie-closer-alist.
;; Allow indentation of if-then-else as:
;; ( test
;; -> thenrule
;; ; elserule
;; )
(`(:before . ,(or "->" ";"))
(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)))