From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31061: 27.0.50; next-page of page-ext non-functional in dired Date: Tue, 24 Apr 2018 21:51:16 -0400 Message-ID: <874lk0rr3f.fsf@gmail.com> References: <84bmezxd5k.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1524621007 17705 195.159.176.226 (25 Apr 2018 01:50:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Apr 2018 01:50:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 31061@debbugs.gnu.org To: Marco Wahl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 25 03:50:02 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fB9ZK-0004WG-Jf for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Apr 2018 03:50:02 +0200 Original-Received: from localhost ([::1]:33409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB9bR-00006a-EY for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Apr 2018 21:52:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB9bL-000064-Fi for bug-gnu-emacs@gnu.org; Tue, 24 Apr 2018 21:52:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB9bG-0007wu-KV for bug-gnu-emacs@gnu.org; Tue, 24 Apr 2018 21:52:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fB9bG-0007wP-ER for bug-gnu-emacs@gnu.org; Tue, 24 Apr 2018 21:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fB9bG-0000NX-24 for bug-gnu-emacs@gnu.org; Tue, 24 Apr 2018 21:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Apr 2018 01:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 31061-submit@debbugs.gnu.org id=B31061.15246210851413 (code B ref 31061); Wed, 25 Apr 2018 01:52:02 +0000 Original-Received: (at 31061) by debbugs.gnu.org; 25 Apr 2018 01:51:25 +0000 Original-Received: from localhost ([127.0.0.1]:38617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fB9af-0000Mj-5m for submit@debbugs.gnu.org; Tue, 24 Apr 2018 21:51:25 -0400 Original-Received: from mail-it0-f51.google.com ([209.85.214.51]:55343) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fB9ad-0000MX-Lr for 31061@debbugs.gnu.org; Tue, 24 Apr 2018 21:51:24 -0400 Original-Received: by mail-it0-f51.google.com with SMTP id 144-v6so3394368iti.5 for <31061@debbugs.gnu.org>; Tue, 24 Apr 2018 18:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=de0sT4kzc/DCLq0admUy7K//MYNlwbwD5uJH3wy+EoM=; b=h0oAQ3JL0iu2WXCQQAa0gp5Cbq6O02lCwCKdf1r01G9q+wrthfx4Z5dPh+JKa4ZzA/ 6Se/NHN2yNTBo4d1R3DITy0s1T70r0mpnLddA6H1U2yNmodx3jijk+Qkw5tiyUPyOEN/ W5yFZh/sZ5G+jKI5EwgKdBQcU2KGmf5vNM70SnbjxpUaQ9YRDysTpkJ6UG0rPuY1FK6Z svGu+1E7Oz31QAVmrqsS50kxVf2n7vqKgpQfOVnV4FsyUh3D2ZKxaV+OJWaMKEFfTLrY WM0Eu1XW0PaAml0UTwbDXxCIsVzbqryVibKa1pYtloVxivZgCCAAo3MGW7uAEn+Sktxb y+/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=de0sT4kzc/DCLq0admUy7K//MYNlwbwD5uJH3wy+EoM=; b=fs/1RrK6yrc9dAND41Iu4ojd7e4GVaI6nItujtHrHoQNrh8yYOgLjE8M1kV+vs14a5 ffcV+phJETVQ+UYzCskVOfSeesp+69MfbWSo0pbxZNc0l6+cdlMYN0d7QIyWfFh+o5HW 7vboRt/+PhLrOZ1mPC+r1ZlX1hZyHkTqQprDnFOt7uSBdoDzuGGUzQxh7F/h/D1blzX4 3LfSFf+BRlmc7OqsfTppFCKia5+DO02g1xKyCe6Idvhv8FPyVPkN/Ps9/M0UJM1UdUVk dG3xGIkV8W5J5uj+qG2On4cJiyV22wk/YDVE59O9/eOgT7nvETODUn6SvX4tDUjlYzOc GU0g== X-Gm-Message-State: ALQs6tBVpCot3/Idiw1ujBUEy8D80+BOKHojMvu374yzMdQpaHENkh+i 4N1iwF7kPFlBxIzWo2RbKJqhLA== X-Google-Smtp-Source: AIpwx4+hng42zKltHIq/Tp77O2oiZVD5uv6668kL0fz9SnKmqpDDS7+ju8P2V1q7QzQe4/E42TxSHg== X-Received: by 2002:a24:3284:: with SMTP id j126-v6mr22262625ita.117.1524621077897; Tue, 24 Apr 2018 18:51:17 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id m20-v6sm8613730ioo.66.2018.04.24.18.51.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Apr 2018 18:51:17 -0700 (PDT) In-Reply-To: <84bmezxd5k.fsf@gmail.com> (Marco Wahl's message of "Wed, 04 Apr 2018 16:24:39 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145743 Archived-At: --=-=-= Content-Type: text/plain Marco Wahl 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)) --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Fix-off-by-1-error-in-next-page-Bug-31061.patch Content-Description: patch >From d0be1dd4592fbe16a4d9799031aed5a7c22fb144 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--