(setq times (1- times))
(when-let ((safe-start (nth 8 (syntax-ppss))))
(goto-char safe-start))
- (re-search-backward (rx bol graph) nil t)
- (let ((safe-start (or (nth 8 (syntax-ppss))
- (nth 8 (syntax-ppss (1+ (point)))))))
- (while (and safe-start (not (bobp)))
- (goto-char safe-start)
- (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))))))))))
+ (unless (and (sweeprolog-at-beginning-of-top-term-p)
+ (not (= p (point))))
+ (re-search-backward (rx bol graph) nil t)
+ (let ((safe-start (or (nth 8 (syntax-ppss))
+ (nth 8 (syntax-ppss (1+ (point)))))))
+ (while (and safe-start (not (bobp)))
+ (goto-char safe-start)
+ (if (or (bobp)
+ (sweeprolog-at-beginning-of-top-term-p))
+ (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)))))