Subject: Re: bug#13402: 24.2.92 pretest: bugs in isearch-yank-line in info page. [Patch]

From: Juri Linkov <[email-masked]>
Date: Sat, 16 Feb 2013 23:50:39 +0200

> OK, here's a better patch.  As already suggested, every match now has its
> lazy-highlight overlay, just that the one overlapping the current match
> no longer has the 'face property set.  I don't think there can be more
> than one overlapping match.  This approach preserves the optimisation
> with `C-s'.

Yes, this is a more reliable approach, and it works correctly now in isearch.
It fails only in `replace-highlight', i.e. after running `query-replace'
and answering `n' to skip to the next match, it doesn't re-highlight
the previous skipped match.

But in principle I don't oppose your approach provided it's working
correctly in all cases.

While testing I noticed an interesting effect.  Test case:

emacs -Q
Eval (info "(elisp) Syntax Table Internals")
Place point at the start of the second paragraph
("   Each entry in a ....").
Type `C-s C-w C-w' that puts " each" to the search string.

Type another C-s (isearch-repeat-forward) that will go to the second
match of " each" (try to use a smaller font to be able to see both
matches of the string " each" on the same screen).

As soon as the cursor leaves the first match, its highlighting
(with a different color for a lazy match) grows to a wider region
previously hidden by your patch.

This indicates that surprises will remain even after using your approach.
Another case surprising to users is reversing the search direction -
e.g. when the cursor is on the second match, type `C-r' and see how
the lazy-highlighted first match shrinks from multi-line to single-line.
It seems nothing can be done to fix this case.