changeset 14160:d85151c5699d

(forward-page): Simplify how we avoid getting stuck when moving backwards.
author Richard M. Stallman <rms@gnu.org>
date Fri, 12 Jan 1996 21:23:05 +0000
parents 93175ed23e01
children 670721a540c8
files lisp/textmodes/page.el
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/page.el	Fri Jan 12 21:14:51 1996 +0000
+++ b/lisp/textmodes/page.el	Fri Jan 12 21:23:05 1996 +0000
@@ -42,19 +42,17 @@
       (goto-char (point-max)))
     (setq count (1- count)))
   (while (and (< count 0) (not (bobp)))
+    ;; In case the page-delimiter matches the null string,
+    ;; don't find a match without moving.
+    (and (save-excursion (re-search-backward page-delimiter nil t))
+	 (= (match-end 0) (point))
+	 (goto-char (match-beginning 0)))
     (forward-char -1)
-    (let (result (end (point)))
-      ;; If we find a match that ends where we started searching,
-      ;; look for another one.
-      (while (and (setq result (re-search-backward page-delimiter nil t))
-		  (= (match-end 0) end))
-	;; Just search again.
-	)
-      (if result
-	  ;; We found one--move to the end of it.
-	  (goto-char (match-end 0))
-	;; We found nothing--go to beg of buffer.
-	(goto-char (point-min))))
+    (if (re-search-backward page-delimiter nil t)
+	;; We found one--move to the end of it.
+	(goto-char (match-end 0))
+      ;; We found nothing--go to beg of buffer.
+      (goto-char (point-min)))
     (setq count (1+ count))))
 
 (defun backward-page (&optional count)