]> code.delx.au - gnu-emacs/commitdiff
Fix "Beginning of buffer" error in forward-page
authorLeo Liu <sdl.web@gmail.com>
Thu, 7 Apr 2016 13:42:40 +0000 (21:42 +0800)
committerLeo Liu <sdl.web@gmail.com>
Thu, 7 Apr 2016 13:42:40 +0000 (21:42 +0800)
* lisp/textmodes/page.el (forward-page): Check before move to prevent
  "Beginning of buffer" error.

lisp/textmodes/page.el

index 17fda677754bf76d9b8f7e95c36062c93f461149..22c73591b919aa47c2730c07fe4750381a603d7e 100644 (file)
@@ -48,12 +48,13 @@ A page boundary is any line whose beginning matches the regexp
     (and (save-excursion (re-search-backward page-delimiter nil t))
         (= (match-end 0) (point))
         (goto-char (match-beginning 0)))
-    (forward-char -1)
-    (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)))
+    (unless (bobp)
+      (forward-char -1)
+      (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)