From: Eshel Yaron Date: Sat, 10 Dec 2022 06:28:44 +0000 (+0200) Subject: * (sweeprolog-beginning-of-predicate-at-point): fix hang near bob X-Git-Tag: V9.1.1-sweep-0.9.5~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1e09cf648d8bc151015e9cefe6341044b385352b;p=sweep.git * (sweeprolog-beginning-of-predicate-at-point): fix hang near bob --- diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index eb08bcc..cf0d331 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -587,7 +587,7 @@ foo. foo :- Body. ")))) -(ert-deftest dwim-next-clause-module-qualified-cdg () +(ert-deftest dwim-next-clause-module-qualified-dcg () "Tests inserting new module-qualified DCG non-terminal." (let ((temp (make-temp-file "sweeprolog-test" nil @@ -1020,6 +1020,15 @@ scasp_and_show(Q, Model, Tree) :- (sweeprolog-end-of-top-term) (should (= (point) 252)))) +(ert-deftest beginning-of-predicate-definition-near-bob () + "Test finding the beginning of the first predicate definition." + (with-temp-buffer + (sweeprolog-mode) + (insert "foo :- bar.") + (goto-char (point-min)) + (sweeprolog-beginning-of-predicate-at-point) + (should (= (point) (point-min))))) + (ert-deftest align-spacs-in-line-comment () "Test using `sweeprolog-align-spaces' in a line comment." (with-temp-buffer diff --git a/sweeprolog.el b/sweeprolog.el index 2161dc5..9fabeb0 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -2962,7 +2962,8 @@ predicate definition at or directly above POINT." (while (and point (not (bobp))) (sweeprolog-beginning-of-top-term) (backward-char 1) - (if-let* ((ndef (sweeprolog-definition-at-point (point))) + (if-let* ((moved (< (point) point)) + (ndef (sweeprolog-definition-at-point (point))) (nfun (cadr ndef)) (nari (caddr ndef)) (same (and (string= fun nfun)