Subject: Re: bug#56747: 28.1.90; Char fold search doesn't work

From: Eli Zaretskii <[email-masked]>
Date: Mon, 25 Jul 2022 15:01:31 +0300

> From: Damien Cassou <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 24 Jul 2022 21:43:10 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> > Which part of the manual led you to expect the above behavior?
> 
> This page (info "(emacs) Lax Search") says:
> 
>   In addition, ‘a’ matches other characters that resemble it, or have it
>   as part of their graphical representation, such as U+249C
>   PARENTHESIZED LATIN SMALL LETTER A and U+2100 ACCOUNT OF (which looks
>   like a small ‘a’ over ‘c’)
> 
> Those 2 characters are the ones I tried so I was expecting to make it
> work.

Ah, you are right.  I wasn't reading the text closely enough.

> > By default, Emacs only folds "canonically-equivalent" characters, and
> > those two aren't equivalent to 'a'.
> 
> Then I don't understand what the manual is saying. Can you please
> explain?

It's a documentation bug: these 2 pairs are by default not handled as
equivalent.  The reasons are to some extent heuristics: since the
table of the equivalent character sequences is produced mechanically,
allowing such "too lax" equivalences would lead to surprising false
matches; see bug#20975 for one example.  (These surprising results are
in part due to the our simplistic implementation, whereby we convert
the set of equivalent sequences to a regexp.)  So we decided to play
it safe, and not allow 'a' to match a character whose Unicode
decomposition is "(a)", because 'a' is not the first character of the
decomposition.  We do allow the sequence "(a)" to match ⒜ (but not
vice versa!), and we do allow 'a' to match 'ⓐ' (because 'a' is the
only character in the decomposition of the latter).

The result of these heuristics is somewhat inconsistent from user POV,
which is why we have a facility to customize it.

So I've now updated the manual to quote only examples that really
work.

> By the way, you are doing an amazing job with Emacs! Thank you so much
> Eli.

Thanks, but please don't forget Lars and others involved in the
development.