unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20975: Replacing text add also the comma
@ 2015-07-03 22:15 Angelo Graziosi
  2015-07-04 21:07 ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Angelo Graziosi @ 2015-07-03 22:15 UTC (permalink / raw)
  To: 20975

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)


Soppose, now, that foo(a_r8,b_r8,c_r8) is a Fortran/C/C++ routine...

Is this intentional or a bug?

I discovered this with recent (master) builds on MSYS2-MINGW64 (64bit 
Windows native). I suspect this also regards the builds on other systems..

Angelo





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-03 22:15 bug#20975: Replacing text add also the comma Angelo Graziosi
@ 2015-07-04 21:07 ` Juri Linkov
  2015-07-04 21:31   ` Artur Malabarba
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2015-07-04 21:07 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: 20975, Artur Malabarba

> 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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-04 21:07 ` Juri Linkov
@ 2015-07-04 21:31   ` Artur Malabarba
  2015-07-05  2:46     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Artur Malabarba @ 2015-07-04 21:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 20975, Angelo Graziosi

[-- Attachment #1: Type: text/plain, Size: 1379 bytes --]

On Jul 4, 2015 10:07 PM, "Juri Linkov" <juri@linkov.net> wrote:
>
> >
> '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?

Yes, it's simple enough to fix.
The reason why we set characters to also match the decomposition of other
unicode characters is that this lets us match a letter combined with a non
spacing accent.
Within that, I've already added a clause to avoid matching when the
decomposition has more than one letter (this prevents "a" from matching
"am").

Clearly, we need another clause to avoid this situation here.
If no one has a different opinion, I'll add a clause so that a
decomposition is folded only if it contains at least one non-spacing
character. (though I'm not sure how to check for this, at the phone right
now).

That would fix this situation, and wouldn't affect how ascii characters are
allowed to match unicode characters. This would only affect how ascii
characters are allowed to match decompositions.

[-- Attachment #2: Type: text/html, Size: 1707 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-04 21:31   ` Artur Malabarba
@ 2015-07-05  2:46     ` Eli Zaretskii
  2015-07-05 15:47       ` Artur Malabarba
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2015-07-05  2:46 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: 20975, juri, angelo.graziosi

> Date: Sat, 4 Jul 2015 22:31:45 +0100
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> Cc: 20975@debbugs.gnu.org, Angelo Graziosi <angelo.graziosi@alice.it>
> 
> If no one has a different opinion, I'll add a clause so that a decomposition is
> folded only if it contains at least one non-spacing character. (though I'm not
> sure how to check for this, at the phone right now). 

You could look at the character's 'canonical-combining-class' property
(should be non-zero).  Or you could look at its 'general-category',
and allow only those whose value is one of Mc, Mn, Me.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-05  2:46     ` Eli Zaretskii
@ 2015-07-05 15:47       ` Artur Malabarba
  2015-07-05 21:07         ` Angelo Graziosi
  0 siblings, 1 reply; 7+ messages in thread
From: Artur Malabarba @ 2015-07-05 15:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 20975, Juri Linkov, Angelo Graziosi

Should be fixed by 5516728

Angelo, does it work for you?

2015-07-05 3:46 GMT+01:00 Eli Zaretskii <eliz@gnu.org>:
>> Date: Sat, 4 Jul 2015 22:31:45 +0100
>> From: Artur Malabarba <bruce.connor.am@gmail.com>
>> Cc: 20975@debbugs.gnu.org, Angelo Graziosi <angelo.graziosi@alice.it>
>>
>> If no one has a different opinion, I'll add a clause so that a decomposition is
>> folded only if it contains at least one non-spacing character. (though I'm not
>> sure how to check for this, at the phone right now).
>
> You could look at the character's 'canonical-combining-class' property
> (should be non-zero).  Or you could look at its 'general-category',
> and allow only those whose value is one of Mc, Mn, Me.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-05 15:47       ` Artur Malabarba
@ 2015-07-05 21:07         ` Angelo Graziosi
  2015-07-05 21:32           ` Artur Malabarba
  0 siblings, 1 reply; 7+ messages in thread
From: Angelo Graziosi @ 2015-07-05 21:07 UTC (permalink / raw)
  To: bruce.connor.am, Eli Zaretskii; +Cc: 20975, Juri Linkov



Il 05/07/2015 17:47, Artur Malabarba ha scritto:
> Should be fixed by 5516728
>
> Angelo, does it work for you?

Oh yes, it seems to work just fine now.. :)

Thank you!

Angelo


>
> 2015-07-05 3:46 GMT+01:00 Eli Zaretskii <eliz@gnu.org>:
>>> Date: Sat, 4 Jul 2015 22:31:45 +0100
>>> From: Artur Malabarba <bruce.connor.am@gmail.com>
>>> Cc: 20975@debbugs.gnu.org, Angelo Graziosi <angelo.graziosi@alice.it>
>>>
>>> If no one has a different opinion, I'll add a clause so that a decomposition is
>>> folded only if it contains at least one non-spacing character. (though I'm not
>>> sure how to check for this, at the phone right now).
>>
>> You could look at the character's 'canonical-combining-class' property
>> (should be non-zero).  Or you could look at its 'general-category',
>> and allow only those whose value is one of Mc, Mn, Me.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20975: Replacing text add also the comma
  2015-07-05 21:07         ` Angelo Graziosi
@ 2015-07-05 21:32           ` Artur Malabarba
  0 siblings, 0 replies; 7+ messages in thread
From: Artur Malabarba @ 2015-07-05 21:32 UTC (permalink / raw)
  To: 20975-done

Great. Closing then.

2015-07-05 22:07 GMT+01:00 Angelo Graziosi <angelo.graziosi@alice.it>:
>
>
> Il 05/07/2015 17:47, Artur Malabarba ha scritto:
>>
>> Should be fixed by 5516728
>>
>> Angelo, does it work for you?
>
>
> Oh yes, it seems to work just fine now.. :)
>
> Thank you!
>
> Angelo
>
>
>
>>
>> 2015-07-05 3:46 GMT+01:00 Eli Zaretskii <eliz@gnu.org>:
>>>>
>>>> Date: Sat, 4 Jul 2015 22:31:45 +0100
>>>> From: Artur Malabarba <bruce.connor.am@gmail.com>
>>>> Cc: 20975@debbugs.gnu.org, Angelo Graziosi <angelo.graziosi@alice.it>
>>>>
>>>> If no one has a different opinion, I'll add a clause so that a
>>>> decomposition is
>>>> folded only if it contains at least one non-spacing character. (though
>>>> I'm not
>>>> sure how to check for this, at the phone right now).
>>>
>>>
>>> You could look at the character's 'canonical-combining-class' property
>>> (should be non-zero).  Or you could look at its 'general-category',
>>> and allow only those whose value is one of Mc, Mn, Me.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-05 21:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-03 22:15 bug#20975: Replacing text add also the comma Angelo Graziosi
2015-07-04 21:07 ` Juri Linkov
2015-07-04 21:31   ` Artur Malabarba
2015-07-05  2:46     ` Eli Zaretskii
2015-07-05 15:47       ` Artur Malabarba
2015-07-05 21:07         ` Angelo Graziosi
2015-07-05 21:32           ` Artur Malabarba

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).