Subject: This bug is ... unfixable right now

From: Harald Jörg <[email-masked]>
Date: Tue, 04 Jul 2023 16:16:05 +0000

On 2016-07-28 20:05, Vincent Lefevre wrote:

> 1. Under X Window (so that Emacs uses its own interface), open
> a file containing:
> 
> # -*- mode: cperl -*-
> 
> tr/ABCDE/12345/;
> 
> 2. Double-click over "4".
> 
> Only "2345" is selected, instead of "12345".

The bug can still be reproduced in Emacs master (Emacs 30).
Unfortunately, it can not be fixed due to an Emacs limitation.

Background: cperl-mode treats the "match"-part and the
"replacement"-part differently.  To do that, cperl-mode uses the
"generic strings" of Emacs.  These need a delimiter character, but the
middle "/" can not serve as a end delimiter for the match part _and_ a
start delimiter of the replacement part.  So cperl-mode "cheats" and
makes the first character of the replacement part the start delimiter,
and by doing this, it is no longer part of the following "word".
Changing that would mean dropping significant features of cperl-mode.

Therefore, this only happens for words which start immediately after the
"/" which separates match- from replacement part.

A workaround is to use paired delimiters, because in that case
cperl-mode has two characters to use as end and start delimiter.
Selecting by double-clicking (or calling word-at-point) gives the
desired result.

    tr{ABCDE}{12345};

So, as of today I can still confirm the bug - but not fix it.
-- 
Cheers,
haj