From b665b84b235e36f2724077f77ccf6d62d1b3f6cb Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 16 Oct 2022 18:18:10 +0300 Subject: [PATCH] FIXED: possible loop finding start of clause at start of buffer --- sweeprolog.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index e7bd25c..d1131d3 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -1818,10 +1818,12 @@ Interactively, a prefix arg means to prompt for BUFFER." (nth 8 (syntax-ppss (1+ (point))))))) (while (and safe-start (not (bobp))) (goto-char safe-start) - (backward-char) - (re-search-backward (rx bol graph) nil t) - (setq safe-start (or (nth 8 (syntax-ppss)) - (nth 8 (syntax-ppss (1+ (point))))))))) + (if (bobp) + (setq safe-start nil) + (backward-char) + (re-search-backward (rx bol graph) nil t) + (setq safe-start (or (nth 8 (syntax-ppss)) + (nth 8 (syntax-ppss (1+ (point)))))))))) (not (= p (point)))) (sweeprolog-beginning-of-next-top-term (- times))))) @@ -2444,7 +2446,7 @@ predicate definition at or directly above POINT." (let ((point (point)) (fun (cadr def)) (ari (caddr def))) - (while point + (while (and point (not (bobp))) (sweeprolog-beginning-of-top-term) (backward-char 1) (if-let* ((ndef (sweeprolog-definition-at-point (point))) -- 2.39.2