Subject: Re: bug#15957: 24.3.50; Follow mode scrolling broken on Emacs trunk

From: martin rudalics <[email-masked]>
Date: Sat, 23 Nov 2013 12:58:47 +0100

Hi Anders

 > Scrolling multiple pages when Follow mode is enabled sometimes fails.
 >
 > Steps to repeat:
 >
 >     Emacs -Q
 >     C-h t
 >     ESC : (set-frame-size (selected-frame) 200 70) RET

Is this really necessary?  70 lines means I can't see my echo area any
more.

 >     M-x follow-delete-other-windows-and-split RET
 >     C-c . C-v
 >
 > The intent is to scroll the entire document two pages down, the left
 > window should still be selected (this causes Follow mode to arrange the
 > right window after it). Instead, the right window is selected,

Can you tell when and where the window on the right is selected?

 > which causes
 > the left to be arranged after it, effectively undoing the scroll.

IIUC `follow-scroll-up' should select the proper window via

	 (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))

which seems to imply that `follow-all-followers' doesn't return what it
is supposed to.  Am I correct that the first window returned by the
latter should be `frame-first-window'?  In that case try to replace the
last line of `follow-all-followers' by something like

     (prog1
	(setq windows (sort windows 'follow--window-sorter))
       (unless (eq (car windows) (frame-first-window (window-frame win)))
	(error "Bad windows %s" windows)))))

and maybe this way we can find out whether the problem is there.

 > The problem seems to be sometimes intermittent, sometimes the scroll works,
 > sometimes it don't.
 >
 > An interesting effect is that the problem only occurs when
 > follow-scroll-up is bound to a key. When issuing M-x follow-scroll-up
 > RET, the command seems to be working properly.

I have no idea why this could change the course of things because ARG
should be nil in both cases.

 > By the way, I'm the original author of Follow mode, even tough I haven't
 > touched it for many years.

I suppose you should touch it again ;-)

martin