From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marco Wahl Newsgroups: gmane.emacs.bugs Subject: bug#31061: 27.0.50; next-page of page-ext non-functional in dired Date: Fri, 27 Apr 2018 13:50:08 +0200 Organization: Marco Wahl Message-ID: <84k1ss3m33.fsf@gmail.com> References: <84bmezxd5k.fsf@gmail.com> <874lk0rr3f.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1524829750 18090 195.159.176.226 (27 Apr 2018 11:49:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2018 11:49:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31061@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 27 13:49:06 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 1fC1s9-0004Zb-4B for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Apr 2018 13:49:05 +0200 Original-Received: from localhost ([::1]:47457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC1uG-0004eh-3c for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Apr 2018 07:51:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC1u7-0004db-5F for bug-gnu-emacs@gnu.org; Fri, 27 Apr 2018 07:51:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fC1u2-0006cI-9W for bug-gnu-emacs@gnu.org; Fri, 27 Apr 2018 07:51:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fC1u2-0006cC-55 for bug-gnu-emacs@gnu.org; Fri, 27 Apr 2018 07:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fC1u1-0000gE-Rd for bug-gnu-emacs@gnu.org; Fri, 27 Apr 2018 07:51:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <84bmezxd5k.fsf@gmail.com> Resent-From: Marco Wahl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Apr 2018 11:51:01 +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.15248298182556 (code B ref 31061); Fri, 27 Apr 2018 11:51:01 +0000 Original-Received: (at 31061) by debbugs.gnu.org; 27 Apr 2018 11:50:18 +0000 Original-Received: from localhost ([127.0.0.1]:41002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fC1tK-0000fA-Hn for submit@debbugs.gnu.org; Fri, 27 Apr 2018 07:50:18 -0400 Original-Received: from mail-wr0-f171.google.com ([209.85.128.171]:33812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fC1tI-0000ew-6i for 31061@debbugs.gnu.org; Fri, 27 Apr 2018 07:50:16 -0400 Original-Received: by mail-wr0-f171.google.com with SMTP id p18-v6so1500122wrm.1 for <31061@debbugs.gnu.org>; Fri, 27 Apr 2018 04:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:organization:references:date:message-id :user-agent:mime-version; bh=5AZGmQAVrlmF83cvhCOKKYFHGOR3MVbBG+bgXm/3L3U=; b=LV9z0FH4PAqt7bkCmUWCyhpXHMkiljEelQuFZhUGuXrBzEr4yl9uQnzLjjD+HjxRDL aWvjg6fPrvLNeodZQgZ4SvftEAEDY00IH0R13TsVzcmXJ9i8BJzagzhV4n/QMAJxtnnd a7eA34G98a/qM3MrFzyqsrEi0D/Zv+JhLlpDf6/Adlw5Iux9KEm67qCiZ5rf43dpIk8x LdXNzl2t6lt0a5m/zk8CAGwEoAIECVehOL2gA3WIz6bXA7y0DRoWkD6ZGmZDIIjp5XzC goNB0uGsVbD0f4BAKnkAq1IeVC+xnFp7IztodnVgiRFtuh77jZrtDRtW1tT+yBsdGlWe Beow== 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:organization:references:date :message-id:user-agent:mime-version; bh=5AZGmQAVrlmF83cvhCOKKYFHGOR3MVbBG+bgXm/3L3U=; b=Ckrc4WSSG4PQB+73qjYewYeif4RmVMCO4Fsrd8trP55hm86kS0qPLlUqpV6vvj7CB5 EOqe8LjuN4YntV+1wqfUsHl5Y29qXjjq2NJyRLEcANccc0bzKyxCBDblm5M2NWSHvb0L o/fqabkGDYbPSz6oS/H1tPB0z4nl+1XyMSU+SMKen5JViFQd3v9Ck3YH0JBw3kDB5GOY 4Jojtu7n8vuHYs1ZVD0tpmP8CrNgR0O/NQ8DsE6rLQJ6eYSwDuSJTkjhZRXU/gBxlGmj DWe5F/oOiUcLWcFzodmhYSZHhsYQQUkekwUhMhoci/SvvyDQpZ+71VJpwynaAW3KJuIq rp7Q== X-Gm-Message-State: ALQs6tB8jX8zp5H551sPxOYKKiE9UsqIj3sWO9da8trATtegm+GR2imE hPIL+kIaVeZneNyOmJq2sMc= X-Google-Smtp-Source: AB8JxZru20KEJmrfL8krg873cjpmcoAqfDnAaa3SS7nVm42Fj22SYsNnUmFKZ6ooTsqTYP4BpnEB+A== X-Received: by 2002:adf:b1cd:: with SMTP id r13-v6mr1458281wra.221.1524829810422; Fri, 27 Apr 2018 04:50:10 -0700 (PDT) Original-Received: from tm6592 (p200300ED5BC18810060D64B9750D36D8.dip0.t-ipconnect.de. [2003:ed:5bc1:8810:60d:64b9:750d:36d8]) by smtp.gmail.com with ESMTPSA id o133sm916388wmo.15.2018.04.27.04.50.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Apr 2018 04:50:09 -0700 (PDT) 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:145781 Archived-At: Noam Postavsky writes: > Marco Wahl writes: > >> Precondition: >> >> - Have a dired with several subdirectories open. > > Also, M-x load-lib RET page-ext RET Yes, thanks. >> 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)) I think this is a good idea to separate the cases clearly. I found that with your suggestion next-page with negative argument goes back one page too much in a dired buffer, though. I further think that the core of the irritation is that `narrow-to-page' does not narrow to the following page when on the start of the '\n\n' page-separator (unlike for the usual '^^L' separator). Starting with your fix I propose this modification of the else part: (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))) This is: go to the end of the delimiter when the final page has been reached. Below a diff to make the suggested change perfectly clear, hopefully. diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el index fbdae5892a..4990fde65a 100644 --- a/lisp/textmodes/page-ext.el +++ b/lisp/textmodes/page-ext.el @@ -304,19 +304,21 @@ 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) + (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))