all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Marco Wahl <marcowahlsoft@gmail.com>
Cc: 31061@debbugs.gnu.org
Subject: bug#31061: 27.0.50; next-page of page-ext non-functional in dired
Date: Tue, 24 Apr 2018 21:51:16 -0400	[thread overview]
Message-ID: <874lk0rr3f.fsf@gmail.com> (raw)
In-Reply-To: <84bmezxd5k.fsf@gmail.com> (Marco Wahl's message of "Wed, 04 Apr 2018 16:24:39 +0200")

[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]

Marco Wahl <marcowahlsoft@gmail.com> writes:

> Precondition:
>
> - Have a dired with several subdirectories open.

Also, M-x load-lib RET page-ext RET

> Action:
>
> - C-x C-p C-n
>
> Expectation:
>
> - The dired buffer narrows to the next subdirectory.
>
> Observation:
>
> - The dired buffer narrows to the current subdirectory.

> * lisp/textmodes/page-ext.el (next-page): Jump ahead page-delimiter if
>   at such before narrow.  This fixes the command for dired.

I think the problem is rather that next-page is going an extra page
backwards even when COUNT was positive, so the fix should be more like
this (inline version with whitespace changes ignored, full version
attached):

--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -304,6 +304,7 @@ next-page
   (or count (setq count 1))
   (widen)
   ;; Cannot use forward-page because of problems at page boundaries.
+  (if (>= count 0)
       (while (and (> count 0) (not (eobp)))
         (if (re-search-forward page-delimiter nil t)
             nil
@@ -316,7 +317,7 @@ next-page
       (if (re-search-backward page-delimiter nil t)
           (goto-char (match-beginning 0))
         (goto-char (point-min)))
-    (setq count (1+ count)))
+      (setq count (1+ count))))
   (narrow-to-page)
   (goto-char (point-min))
   (recenter 0))



[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1931 bytes --]

From d0be1dd4592fbe16a4d9799031aed5a7c22fb144 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Tue, 24 Apr 2018 21:36:17 -0400
Subject: [PATCH] Fix off-by-1 error in next-page (Bug#31061)

* lisp/textmodes/page-ext.el (next-page): Only go backwards if COUNT
was originally negative.
---
 lisp/textmodes/page-ext.el | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el
index 8a41bc3742..1a1a62e963 100644
--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -304,19 +304,20 @@ next-page
   (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)
+          (goto-char (match-beginning 0))
+        (goto-char (point-min)))
+      (setq count (1+ count))))
   (narrow-to-page)
   (goto-char (point-min))
   (recenter 0))
-- 
2.11.0


  reply	other threads:[~2018-04-25  1:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04 14:24 bug#31061: 27.0.50; next-page of page-ext non-functional in dired Marco Wahl
2018-04-25  1:51 ` Noam Postavsky [this message]
2018-04-27 11:50   ` Marco Wahl
2018-04-29  0:13     ` Noam Postavsky
2018-04-29 20:23       ` Marco Wahl
2018-05-03  0:36         ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lk0rr3f.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=31061@debbugs.gnu.org \
    --cc=marcowahlsoft@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.