Function: prolog-pred-start

prolog-pred-start is a byte-compiled function defined in prolog.el.gz.

Signature

(prolog-pred-start)

Documentation

Return the starting point of the first clause of the current predicate.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/prolog.el.gz
(defun prolog-pred-start ()
  "Return the starting point of the first clause of the current predicate."
  ;; FIXME: Use SMIE.
  (save-excursion
    (goto-char (prolog-clause-start))
    ;; Find first clause, unless it was a directive
    (if (and (not (looking-at "[:?]-"))
             (not (looking-at "[ \t]*[%/]"))  ; Comment

             )
        (let* ((pinfo (prolog-clause-info))
               (predname (nth 0 pinfo))
               (arity (nth 1 pinfo))
               (op (point)))
          (while (and (re-search-backward
                       (format "^%s\\([(\\.]\\| *%s\\)"
                               predname prolog-head-delimiter) nil t)
                      (= arity (nth 1 (prolog-clause-info)))
                      )
            (setq op (point)))
          (if (eq prolog-system 'mercury)
              ;; Skip to the beginning of declarations of the predicate
              (progn
                (goto-char (prolog-beginning-of-clause))
                (while (and (not (eq (point) op))
                            (looking-at
                             (format ":-[ \t]*\\(pred\\|mode\\)[ \t]+%s"
                                     predname)))
                  (setq op (point))
                  (goto-char (prolog-beginning-of-clause)))))
          op)
      (point))))