Subject: Re: bug#22097: Ispell: lazy highlighting doesn't work properly.

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Dec 2015 15:23:42 +0200

> Date: Sat, 5 Dec 2015 11:42:30 +0000
> From: Alan Mackenzie <[email-masked]>
> 
> emacs -Q
> C-x C-f src/xdisp.c
> Adjust frame/window configuration such that the buffer is displayed in a
>   window at least 50 lines high.
> M-x ispell
> 
> Press the spacebar several times until "xdisp" on line 34 is highlighted.
> Notice that the next occurrence of "xdisp" (L48, in the diagram) hasn't
> been lazily highlighted.  This is a bug.
> 
> Press the spacebar several times more until "xdisp" on L48 is
> highlighted.  The occurrence on L34 is now lazily highlighted as it
> should be.

This is a "feature".  Ispell skips regions determined by certain
regexps, see ispell-skip-region-alist.  In this case, the ASCII-art
diagram around the second occurrence of "xdisp" includes regions that
match some of the regexps (AFAICT, the '+' character followed and
preceded by '-' triggers that).  Lazy highlight doesn't want to try
matching in those skip-regions, and since it cannot support
non-contiguous regions, it simply limits itself to the beginning of
the first such region, which happens to be before the second "xdisp".

IOW, the lazy highlight, as coded, should not be expected to highlight
all the matching misspellings in such situations.

If we think this is a grave limitation (do we?), then we need to
invoke isearch-lazy-highlight-new-loop more than once, until we get to
the end of the window.  I don't know enough about
isearch-lazy-highlight-new-loop to tell if this will work, but
hopefully someone else here will.