Subject: 25.0.50; highlight-regexp from isearch has is case-sensitive even if case-fold is active

From: Dima Kogan <[email-masked]>
Date: Tue, 02 Feb 2016 22:29:22 -0800

This is an offshoot of #22520:

Juri Linkov wrote:

> > Another possible side effect of this is that highlighting
> >
> >   Database directory:
> >
> > doesn't work: hi-lock goes through the motions but nothing ends up being
> > highlighted. Turning off char-folding fixes that.
>
> Actually “Database directory:” is not highlighted due to case-folding.
> After toggling case-folding with ‘M-s c’ and preserving the capital D,
> it's highlighted correctly.

This is true! And it's really weird... The user expectation is that if
we highlight something (M-s h r) directly from isearch, then at least
the thing isearch was finding would be highlighted, and here this
doesn't happen. So a slightly simpler example is:

0: Let the buffer have the string Ab
1: put the point on A
2: C-s
3: C-w (to isearch the whole thing)
4: M-s h r enter

Then Ab isn't found because we defaulted to char-folding, and the regex was

  \(?:a[̀-̄̆-̨̣̥̊̌̏̑]\|[aªà-åāăąǎȁȃȧᵃḁạảₐⓐａ𝐚𝑎𝒂𝒶𝓪𝔞𝕒𝖆𝖺𝗮𝘢𝙖𝚊]\)\(?:b[̣̱̇]\|[bᵇḃḅḇⓑｂ𝐛𝑏𝒃𝒷𝓫𝔟𝕓𝖇𝖻𝗯𝘣𝙗𝚋]\)

This clearly has no case-folding active on top of the char-folding. But
the isearch had both, so the regex should get both. This would make the
regex twice as long, but it would be right, at least.

If we turn off char-folding (but leave case-folding alone; on) by adding
a step

2.5: M-s '

then the regex we get is

  [Aa][Bb]

which clearly has the case-folding, and works the way we expect.