Subject: bug#17453: Isearch doesn't work properly with Follow Mode.

From: Alan Mackenzie <[email-masked]>
Date: Mon, 2 Nov 2015 12:35:12 +0000

Hello, Artur.

On Mon, Nov 02, 2015 at 11:53:10AM +0000, Artur Malabarba wrote:
> > I don't actually understand that patch, I'll need to study the wierd/new
> > constructs used in it, like `when-let'.

> Here's a more thoroughly explained version of this function, that
> doesn't use when-let.

> seq-find is equivalent to cl-find-if, it returns the first element
> that matches the provided predicate.

OK.

[ .... ]

> I also changed it to use (follow-all-followers).

That's unwanted.  ;-)  Isearch should not be using internal Follow Mode
functions.  Some more abstraction would be needed.

> > However, I'm certain that that patch will not fix all the problems
> > discussed in this post.

> The patch as provided doesn't fix the “highlighting matches on all
> windows” issue. But that's trivial to solve by removing that
> `(overlay-put ov 'window (selected-window))' line. (which I have half
> a mind to do right now because I just think it's a generally useful
> improvement.)

Lazy highlighting searches for matches on the current window.  It must
be extended to search for matches on the Follow Mode group of windows.
For that, it needs the details of the "window*-start" and "window*-end".

> >  One way or another, isearch MUST work with the
> > window boundaries of the entire Follow Mode group.

> Maybe I missed part of the issue. I thought you wanted Isearch to
> switch to another window if that window contains the next match
> (instead of scrolling the current window). For that, you only need
> pos-visible-in-window-p, you don't need to mess with boundaries.

What is causing the unwanted scrolling rather than moving to the next
window, is the form "(sit-for 0)" near the start of
isearch-lazy-highlight-new-loop.  When point is outside the window, this
form causes redisplay, which scrolls point back into the window -
without Follow Mode getting a look in.  In my patch, I replaced this
with "(sit*-for 0)", where Follow Mode can do its thing before the
redisplay happens.

-- 
Alan Mackenzie (Nuremberg, Germany).