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

From: Juri Linkov <[email-masked]>
Date: Fri, 19 Oct 2018 01:18:21 +0300

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

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

> 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'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.
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)

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.