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

From: Juri Linkov <[email-masked]>
Date: Thu, 21 Feb 2013 02:45:31 +0200

>> The result is that the first space character is not lazy-highlighted.
>> I think this is wrong.
>
> :-).  I'm not sure.  It has a certain logic behind it.  I think a missing
> lazy-highlight is much less disturbing than an obtrusive one.

Alan, I completely agree with you.  Your logic makes perfect sense.
An obtrusive lazy-highlight is too disturbing.

But I also think that my logic makes sense as well
since a missing lazy-highlight is too bad.

Fortunately, it is possible to combine both logics
with a small patch that you can see below.

The key point is that the lazy-highlighting loop should start
from the same position where the main search function found
the beginning of the match!

Currently the boundary of the lazy-highlighting loop starts at the end
of the found match (the value of `(point)').  But the match found by
the main search function (and highlighted by the primary face `isearch')
begins at `isearch-other-end'.  So currently they are mutually inconsistent.

This patch moves the boundary of lazy-highlighting from the end
of the found match to its beginning - like in the main search function.
Thus it brings the logic of `isearch-lazy-highlight-search' closer to
the logic of the main search function in `isearch-search'.

In the result of removing this inconsistency, this patch passes
the test case that you posted in your original bug report,
i.e. placing point at the start of the second paragraph
("   Each entry in a ....") and typing `C-s M-s C-e' (isearch-yank-line)
doesn't highlight the gap preceding the paragraph with lazy-highlight face.
And it also passes other tests that I tried.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-02-01 23:38:41 +0000
+++ lisp/isearch.el	2013-02-21 00:45:05 +0000
@@ -2936,8 +2936,8 @@ (defun isearch-lazy-highlight-new-loop (
     (setq isearch-lazy-highlight-window       (selected-window)
 	  isearch-lazy-highlight-window-start (window-start)
 	  isearch-lazy-highlight-window-end   (window-end)
-	  isearch-lazy-highlight-start        (point)
-	  isearch-lazy-highlight-end          (point)
+	  isearch-lazy-highlight-start        (or isearch-other-end (point))
+	  isearch-lazy-highlight-end          (or isearch-other-end (point))
 	  isearch-lazy-highlight-wrapped      nil
 	  isearch-lazy-highlight-last-string  isearch-string
 	  isearch-lazy-highlight-case-fold-search isearch-case-fold-search