Subject: bug#20975: Replacing text add also the comma

From: Juri Linkov <[email-masked]>
Date: Sun, 05 Jul 2015 00:07:34 +0300

> Suppose one has a file with this text
>
> $ cat foo.log
> abcd r8 efg
> foo(a_r8,b_r8,c_r8)
>
> Try to replace 'r8' with 'DP', i.e. in the minibuffer,
>
> M-% <RETURN>
> Query replace:
> r8 <RETURN>
> Query replace r8 with: DP
>
> The 'r8' on the first row is replaced correctly while on the second row
> also the comma is added to the text 'r8' to be replaced.
>
> foo.log becomes
>
> $ cat foo.log
> abcd DP efg
> foo(a_DPb_DPc_DP)
>
> Is this intentional or a bug?

Thanks for the report, this is an unintentional bug.

'8' matches the adjacent comma because (character-fold-to-regexp "8")
contains "8[,.]"

The culprit is #x1f109 “DIGIT EIGHT COMMA” with decomposition: (compat
'8' ',') and #x248f “DIGIT EIGHT FULL STOP” with decomposition: (compat
'8' '.')

We don't need to match the decomposition “8,” when searching for “8”.
We only need to match the char #x1f109 when searching for “8”.

Maybe Artur has an idea how to fix this regexp?