From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23347: 25.0.92; Follow mode scrolling broken -- scrolls only one page Date: Tue, 26 Apr 2016 11:51:08 +0000 Message-ID: <20160426115108.GC3033@acm.fritz.box> References: <20160424090035.87856.qmail@mail.muc.de> <20160424142313.GB3517@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1461672029 11171 80.91.229.3 (26 Apr 2016 12:00:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Apr 2016 12:00:29 +0000 (UTC) Cc: 23347@debbugs.gnu.org To: Anders Lindgren Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 26 14:00:19 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1av1f5-0001gA-N6 for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Apr 2016 14:00:15 +0200 Original-Received: from localhost ([::1]:37653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1av1f4-0001VD-Fw for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Apr 2016 08:00:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1av1ey-0001RB-Su for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2016 08:00:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1av1es-00084V-Pd for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2016 08:00:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1av1es-00084D-Lv for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2016 08:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1av1es-0003IW-G0 for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2016 08:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Apr 2016 12:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23347 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23347-submit@debbugs.gnu.org id=B23347.146167197112605 (code B ref 23347); Tue, 26 Apr 2016 12:00:02 +0000 Original-Received: (at 23347) by debbugs.gnu.org; 26 Apr 2016 11:59:31 +0000 Original-Received: from localhost ([127.0.0.1]:47551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1av1eN-0003HF-1t for submit@debbugs.gnu.org; Tue, 26 Apr 2016 07:59:31 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:39667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1av1eL-0003H6-69 for 23347@debbugs.gnu.org; Tue, 26 Apr 2016 07:59:29 -0400 Original-Received: (qmail 17015 invoked by uid 3782); 26 Apr 2016 11:59:27 -0000 Original-Received: from acm.muc.de (p548A4B35.dip0.t-ipconnect.de [84.138.75.53]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 26 Apr 2016 13:59:26 +0200 Original-Received: (qmail 4389 invoked by uid 1000); 26 Apr 2016 11:51:08 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:116864 Archived-At: Hello, Anders. On Sun, Apr 24, 2016 at 05:37:57PM +0200, Anders Lindgren wrote: > Hi! > Agreed. All three scroll commands (non-follow-mode scroll, scroll one page, > and scroll N pages) are useful. [ .... ] > Yes, I agree, `page' isn't a good choice. > What about `follow-scroll-up-keep-point'? That way it would be clear what > the difference is between it and the normal scroll command. > If I would have designed Follow mode today, I probably would have used your > name, `follow-scroll-up-window', and named the N-page scroll > `follow-scroll-up-window-group'. I've just used `follow-scroll-up-window' and `follow-scroll-down-window'. At least, for now. [ .... ] > Anyway, here is what I think we can agree on: > > 1. `follow-scroll-up/down' should scroll by N windows. > > 2. There need to be commands in follow.el that scroll by 1 window as is > > done by the current `follow-scroll-up/down'. You have suggested the > > name `follow-scroll-up/down-one-page'. I have countered with > > `follow-scroll-up/down-window'. > > If we can agree, I'm willing to amend follow.el. I think it's probably > > too late for this fix to make it into Emacs 25.1, though. > > > Well, give it a try. Feel free to pick a suitable name. If we come up with > a clean solution quickly John might accept it. OK. I had one or two minor problems with follow-scroll-up/down with a non-nil ARG. In the end, I just extracted functionality from follow-scroll-up/down-window into separate functions, and called those from all four scrolling functions. Anyway, here is the patch I've come up with. Could you review it and test it, please. Thanks! diff --git a/lisp/follow.el b/lisp/follow.el index 5801f79..3e23247 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -532,6 +532,80 @@ follow-get-scrolled-point ;; position... (This would also be corrected if we would have had a ;; good redisplay abstraction.) +(defun follow-scroll-up-arg (arg) + "Scroll the text in a follow mode window chain up by ARG lines. +If ARG is nil, scroll the size of the current window. + +This is an internal function for `follow-scroll-up' and +`follow-scroll-up-window'." + (let ((opoint (point)) (owin (selected-window))) + (while + ;; If we are too near EOB, try scrolling the previous window. + (condition-case nil (progn (scroll-up arg) nil) + (end-of-buffer + (condition-case nil (progn (follow-previous-window) t) + (error + (select-window owin) + (goto-char opoint) + (signal 'end-of-buffer nil)))))) + (unless (and scroll-preserve-screen-position + (get this-command 'scroll-command)) + (goto-char opoint)) + (setq follow-fixed-window t))) + +(defun follow-scroll-down-arg (arg) + "Scroll the text in a follow mode window chain down by ARG lines. +If ARG is nil, scroll the size of the current window. + +This is an internal function for `follow-scroll-down' and +`follow-scroll-down-window'." + (let ((opoint (point))) + (scroll-down arg) + (unless (and scroll-preserve-screen-position + (get this-command 'scroll-command)) + (goto-char opoint)) + (setq follow-fixed-window t))) + +;;;###autoload +(defun follow-scroll-up-window (&optional arg) + "Scroll text in a Follow mode window up by that window's size. +The other windows in the window chain will scroll synchronously. + +If called with no ARG, the `next-screen-context-lines' last lines of +the window will be visible after the scroll. + +If called with an argument, scroll ARG lines up. +Negative ARG means scroll downward. + +Works like `scroll-up' when not in Follow mode." + (interactive "P") + (cond ((not follow-mode) + (scroll-up arg)) + ((eq arg '-) + (follow-scroll-down-window)) + (t (follow-scroll-up-arg arg)))) +(put 'follow-scroll-up-window 'scroll-command t) + +;;;###autoload +(defun follow-scroll-down-window (&optional arg) + "Scroll text in a Follow mode window down by that window's size. +The other windows in the window chain will scroll synchronously. + +If called with no ARG, the `next-screen-context-lines' top lines of +the window in the chain will be visible after the scroll. + +If called with an argument, scroll ARG lines down. +Negative ARG means scroll upward. + +Works like `scroll-down' when not in Follow mode." + (interactive "P") + (cond ((not follow-mode) + (scroll-down arg)) + ((eq arg '-) + (follow-scroll-up-window)) + (t (follow-scroll-down-arg arg)))) +(put 'follow-scroll-down-window 'scroll-command t) + ;;;###autoload (defun follow-scroll-up (&optional arg) "Scroll text in a Follow mode window chain up. @@ -546,23 +620,18 @@ follow-scroll-up (interactive "P") (cond ((not follow-mode) (scroll-up arg)) - ((eq arg '-) - (follow-scroll-down)) - (t - (let ((opoint (point)) (owin (selected-window))) - (while - ;; If we are too near EOB, try scrolling the previous window. - (condition-case nil (progn (scroll-up arg) nil) - (end-of-buffer - (condition-case nil (progn (follow-previous-window) t) - (error - (select-window owin) - (goto-char opoint) - (signal 'end-of-buffer nil)))))) - (unless (and scroll-preserve-screen-position - (get this-command 'scroll-command)) - (goto-char opoint)) - (setq follow-fixed-window t))))) + (arg (follow-scroll-up-arg arg)) + (t + (let* ((windows (follow-all-followers)) + (end (window-end (car (reverse windows))))) + (if (eq end (point-max)) + (signal 'end-of-buffer nil) + (select-window (car windows)) + ;; `window-end' might return nil. + (if end + (goto-char end)) + (vertical-motion (- next-screen-context-lines)) + (set-window-start (car windows) (point))))))) (put 'follow-scroll-up 'scroll-command t) ;;;###autoload @@ -579,15 +648,22 @@ follow-scroll-down (interactive "P") (cond ((not follow-mode) (scroll-down arg)) - ((eq arg '-) - (follow-scroll-up)) - (t - (let ((opoint (point))) - (scroll-down arg) - (unless (and scroll-preserve-screen-position - (get this-command 'scroll-command)) - (goto-char opoint)) - (setq follow-fixed-window t))))) + (arg (follow-scroll-down-arg arg)) + (t + (let* ((windows (follow-all-followers)) + (win (car (reverse windows))) + (start (window-start (car windows)))) + (if (eq start (point-min)) + (signal 'beginning-of-buffer nil) + (select-window win) + (goto-char start) + (vertical-motion (- (- (window-height win) + (if header-line-format 2 1) + next-screen-context-lines))) + (set-window-start win (point)) + (goto-char start) + (vertical-motion (- next-screen-context-lines 1)) + (setq follow-internal-force-redisplay t)))))) (put 'follow-scroll-down 'scroll-command t) (declare-function comint-adjust-point "comint" (window)) > -- Anders -- Alan Mackenzie (Nuremberg, Germany).