]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix next-page for dired (Bug#31061)
authorMarco Wahl <marcowahlsoft@gmail.com>
Fri, 27 Apr 2018 11:50:08 +0000 (13:50 +0200)
committerNoam Postavsky <npostavs@gmail.com>
Thu, 3 May 2018 00:35:20 +0000 (20:35 -0400)
* lisp/textmodes/page-ext.el (next-page): Don't go back any pages if
COUNT is 0.  For negative COUNT, end with point just after the last
delimiter.

Co-authored-by: Noam Postavsky <npostavs@gmail.com>
lisp/textmodes/page-ext.el

index fbdae5892a1e6099ee741c0926115320601ce157..92fce4d364b8eb1e2084a20219e4de8457186e79 100644 (file)
@@ -304,19 +304,21 @@ With arg (prefix if interactive), move that many pages."
   (or count (setq count 1))
   (widen)
   ;; Cannot use forward-page because of problems at page boundaries.
-  (while (and (> count 0) (not (eobp)))
-    (if (re-search-forward page-delimiter nil t)
-        nil
-      (goto-char (point-max)))
-    (setq count (1- count)))
-  ;; If COUNT is negative, we want to go back -COUNT + 1 page boundaries.
-  ;; The first page boundary we reach is the top of the current page,
-  ;; which doesn't count.
-  (while (and (< count 1) (not (bobp)))
-    (if (re-search-backward page-delimiter nil t)
-       (goto-char (match-beginning 0))
-      (goto-char (point-min)))
-    (setq count (1+ count)))
+  (if (>= count 0)
+      (while (and (> count 0) (not (eobp)))
+        (if (re-search-forward page-delimiter nil t)
+            nil
+          (goto-char (point-max)))
+        (setq count (1- count)))
+    ;; If COUNT is negative, we want to go back -COUNT + 1 page boundaries.
+    ;; The first page boundary we reach is the top of the current page,
+    ;; which doesn't count.
+    (while (and (< count 1) (not (bobp)))
+      (if (re-search-backward page-delimiter nil t)
+          (when (= count 0)
+            (goto-char (match-end 0)))
+        (goto-char (point-min)))
+      (setq count (1+ count))))
   (narrow-to-page)
   (goto-char (point-min))
   (recenter 0))