Subject: bug#29360: 26.0; Add full-buffer choice for `isearch-lazy-highlight'

From: Drew Adams <[email-masked]>
Date: Thu, 18 Oct 2018 16:25:03 -0700 (PDT)

> > It would really be good if this enhancement were made - for the
> > reasons I gave in bug #21092, and for other reasons. You asked me
> > (in bug #21092) to file this bug if I thought we needed such a
> > full-buffer possibility. This enhancement request was the result.
> 
> Actually, a full-buffer lazy-highlighting possibility already exists:
> 
>   (setq lazy-highlight-cleanup nil)
>   (add-hook 'isearch-mode-end-hook
>             (lambda ()
>               (setq window-group-start-function (lambda (_w) (point-min)))
>               (setq window-group-end-function (lambda (_w _u) (point-max)))))

Thanks for this info. I don't really understand it, though. `C-h v window-group-start-function' tells me nothing, for instance - no doc, apparently.

(FWIW, I already use `isearch-mode-end-hook' quite a bit. Not that another
addition would necessarily break the bank. ;-))

> But I agree that more straightforward customization would be better
> with a clear value of the customizable variable.

Thank you. Will you please implement that when you get a chance?

> > Did you not have a patch that took care of this? IIRC you then found
> > a problem with it wrt `follow-mode', but I thought you had a solution
> > for that too. (I thought the latter solution was provided by Artur's
> > `all-windows' value for `isearch-lazy-highlight' etc., which was added.)
> 
> That patch was installed more than a year ago.

What is that patch? Is this about `window-group-start|end-function' or
is there some other way to force lazy highlighting to be done throughout
the buffer? If this is patch is now reflected in isearch.el, where would
I see it there?

> > What's the status of this feature? Can we add it to Emacs now?
> > I hope so.
> 
> The reason why it's not yet finished is because it was unclear how to
> integrate it with another similar feature of matches-counting (that counts
> the number of matches in the full buffer).  The reasoning is the following:
> both features require using the same loop in isearch-lazy-highlight
> extending it to operate on the full buffer.  I know you will argue that
> these are unrelated features and should be treated separately.

I won't argue any such thing, as I know nothing about this stuff. ;-)

> But implementation-wise they have only one difference:
> 
> 1. buffer-matches-highlighting visits all matches and highlights them;
> 2. buffer-matches-counting visits all matches but doesn't highlight them
>    (only counts)

That doesn't sound like a big difference, a priori. Can't you just
have a variable or a function argument that says whether to
highlight?

> Both need special treatment for possible slowdown in a
> large buffer, so for performance reasons we need to add
> a new customizable variable like lazy-buffer-max-at-a-time,
> separate not to conflict with lazy-highlight-max-at-a-time.
> The latter applies to the matches on the screen, the former
> to the matches in the full buffer.

I see. Sounds like that would be do-able, but I don't know anything
about the details. Hope you can/will resolve this sometime soon.

Thanks for taking a look.