Subject: Re: bug#43702: Emacs master: Incorrect highlighting in regexp isearch.

From: Juri Linkov <[email-masked]>
Date: Wed, 30 Sep 2020 22:16:19 +0300

>> 16.  The problem was that the submatch highlight was light magenta on
>> dark magenta, which I just didn't see.  Maybe the colours used for
>> isearch-group-1 on a 16 colour terminal are suboptimal.  They certainly
>> don't work well on my Linux virtual tty.
>
> I've now changed the face specs to inherit from the isearch face if
> there's fewer than 88 colours.

There is another problem: currently isearch-group-3 is indistinguishable
visually from the default isearch face (on X with more than 88 colours).

Also I don't understand why users would need so many faces (9!)

Maybe better to do what Drew proposed: to distinguish the odd groups
from the even groups, i.e. to have only 2 additional faces
(a brighter face like the current isearch-group-1 for the odd groups,
and a darker face for the even groups).

>> However, on pressing backspace to go back to previous matches, this new
>> highlighting is no longer there.
>>
>> So, perhaps there is/are (a) bug(s) here after all, just not the one I
>> thought I'd found.
>
> Yup; I can reproduce that bug.

The problem is that isearch-delete-char doesn't run the search again
that would set match-data.  It just restores an old position
(isearch-other-end and point) that isearch-highlight uses.

One solution is to call isearch-search in isearch-delete-char
before isearch-update.  But I can't predict all dire consequences.

So a better solution is maybe to save match-data on the isearch stack
and restore in isearch-pop-state (called by isearch-delete-char).
I could try to do this.