From: Eshel Yaron Date: Tue, 22 Nov 2022 10:59:41 +0000 (+0200) Subject: FIXED: sweeprolog-beginning-of-next-top-term: other possible loop X-Git-Tag: V8.5.20-sweep-0.8.12~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fbde60f59cc7bc27cb3088c028619692a279765b;p=sweep.git FIXED: sweeprolog-beginning-of-next-top-term: other possible loop * sweeprolog.el (sweeprolog-beginning-of-next-top-term): don't loop when called in the last term of the buffer * sweeprolog-tests.el (beginning-of-next-top-term-at-last-clause): new test case --- diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index ed79c42..f096bf7 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -657,6 +657,24 @@ loop_term(I, Arity, Goal1, Goal2) :- (sweeprolog-end-of-top-term) (should (= (point) 232)))) +(ert-deftest beginning-of-next-top-term-at-last-clause () + "Test finding the beginning of next top term when there isn't one." + (with-temp-buffer + (sweeprolog-mode) + (insert " +test_bindings(Name-Value) --> + [' '~w = ~p'-[Name-Value] ].. +") + (goto-char 43) + (backward-delete-char 1) + (end-of-line) + (backward-delete-char 1) + (should (string= (buffer-string) " +test_bindings(Name-Value) --> + [' ~w = ~p'-[Name-Value] ]. +" + )))) + (defun sweeprolog-test-indentation (given expected) (with-temp-buffer diff --git a/sweeprolog.el b/sweeprolog.el index 2fcabbf..d1c585b 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -2485,9 +2485,9 @@ Interactively, POINT is set to the current point." (re-search-forward (rx bol graph) nil t) (while (and (or (nth 8 (syntax-ppss)) (looking-at-p (rx bol (or "%" "/*")))) - (not (eobp))) - (re-search-forward (rx bol graph) nil t))) - (beginning-of-line) + (not (eobp)) + (re-search-forward (rx bol graph) nil t)))) + (unless (= p (point)) (beginning-of-line)) (not (= p (point))))) (defun sweeprolog-end-of-top-term ()