Subject: RE: bug#21092: 25.0.50; Option `lazy-highlight-max-at-a-time' does not work

From: Drew Adams <[email-masked]>
Date: Tue, 1 Sep 2015 17:07:11 -0700 (PDT)

> I tried to find a useful application for this feature, and finally found.

Great.  What's the application?

> > Whole buffer OR rest-of-buffer forward or backward.  Au choix.
> > Both behaviors are useful.
> 
> Since you can scroll up or down, highlighting the whole buffer is
> unavoidable.

I don't understand.  Can you elaborate a bit?  With the patch I
sent it seemed to be avoided.  When searching forward, the only
matches before point that got highlighted were those in the window.

IIUC, this is not important to me, but I would like to understand.

> > Not clear why you want a separate option for this.  It cannot be
> > used in combination with `lazy-highlight-max-at-a-time', can it?
> 
> Of course, it is useful in combination with ‘lazy-highlight-max-at-a-time’
> that can define the incrementality (how many steps to do) regardless
> whether highlighting the whole buffer or only matches on the screen.

I see now that I misunderstood what was meant by "at a time" in
"max-at-a-time".

I was thinking that it referred to all of the highlighting for
a given input (e.g. after an input change).  Instead, it refers
to one invocation of `isearch-lazy-highlight-update', whose loop
runs only `lazy-highlight-max-at-a-time' iterations.  And `*-update'
can get reinvoked by the timer to complete the highlighting for the
input.

> > A second question concerns how to control whether this acts
> > only in the current search direction or in both directions.
> 
> We can highlight only in the search direction because regexp
> search might match different results depending on direction.
> So you need to switch directions with ‘C-r’ to re-highlight
> the buffer.

You just said that "highlighting the whole buffer is unavoidable",
so I am a bit confused.  Now you seem to be saying that we can
highlight only in one direction at a time.  Maybe you could
elaborate a bit here?

> > For exmaple, I might want a toggle between max=10 and
> > whole-buffer.
> 
> This will be possible with two separate variables:
> the existing ‘lazy-highlight-max-at-a-time’
> to toggle between max=10 and max=nil
> and the new ‘lazy-highlight-buffer’
> to toggle between whole-buffer and screen-only
> implemented by this small patch:

I misunderstood max-at-a-time.  So maybe the doc for it needs
clarifying wrt what is meant by at a time etc.

The doc and defcustom need fixing anyway, for the confusion
over the meaning of "all matches" etc., discussed previously.

Anyway, your patch looks good.  It is essentially the same
as mine, but using `lazy-highlight-buffer' instead of a nil
value of `lazy-highlight-max-at-a-time'.  I understand now
that they have different purposes.

The difference is that I did not change the occurrences of
`window-(start|end)' in `isearch-lazy-highlight-new-loop'.
I wasn't sure it was needed (not fully understanding it),
and I didn't notice a problem without it.  But I'm glad that
you, knowing more, made the same change there as well.

Thx - Drew