Subject: bug#32747: 26; `C-M-w M-w' with non-nil `mouse-drag-copy-region', if selected with mouse

From: Eli Zaretskii <[email-masked]>
Date: Wed, 19 Sep 2018 17:38:22 +0300

> Date: Wed, 19 Sep 2018 06:51:40 -0700 (PDT)
> From: Drew Adams <[email-masked]>
> Cc: [email-masked]
> 
> Anyay, replaying the recipe now (again, from -Q), I see the bad
> behavior in _all_ Emacs releases (including back to Emacs 20,
> when there was no variable `mouse-drag-copy-region').

Makes sense, because those versions worked as if
mouse-drag-copy-region was t.  Emacs 22.1 added that variable, and you
should be able to see the problem go away starting from that version,
when this variable is nil.

> In Emacs 23.4, changing `mouse-drag-copy-region' to nil does _not_
> fix the behavior, for me. Are you sure that it does, for you?

Yes.  I just rechecked again, to be sure.  I don't understand why it
doesn't work for you, maybe it's something specific to your system, or
maybe that Emacs binary is somehow different from mine (unlikely).  Or
maybe you made some mistake in reproducing the behavior in that
version.

> In Emacs 24.5 and later the bad behavior exists only when the
> variable is non-nil.

When that variable is non-nil, what you see is expected behavior, see
below.

> So the bug does not seem to be a regression, and it is longstanding.
> Perhaps no one ever tried to use `C-M-w M-w' with a mouse
> selection when testing?

Indeed, with that variable non-nil, users are not expected to copy and
paste using the keyboard, they are expected to do that with the mouse.
And they certainly aren't expected to mix both methods in the same
sequence of actions on the same text.

> Do you agree that this is a bug?

No, I think it's expected.  When that variable is non-nil, making the
second selection automatically copies the selected text into the
kill-ring, so your C-M-w affects the next M-w, which copies the same
text.  The text of the first selection should be available with M-y,
as it is one slot down in the kill-ring (and should also be there
twice, for the same reason).

> To me, this is a bug. The behavior contradicts what the doc says for
> `C-M-w', and the behavior is useless (why would anyone want
> duplication of the mouse selection - appending it to itself instead
> of the previous kill?)

You create the duplication by using M-w, because with that variable
non-nil, there's no need for M-w, as selected text automatically gets
placed in the kill-ring as soon as it is selected.  This mode is for
people who select and copy/paste with the mouse, not with the
keyboard.

What documentation does this contradict?  Perhaps we should clarify
that, but in general you are doing something unexpected: mixing the
mouse-based selection and copy/paste paradigm with the keyboard-based
one.  They are supposed to be separate, and the defaults since Emacs
24 make sure they are.