Subject: Re: bug#53894: 27.2; Clipboard copy -> C-y -> M-y -> Same clipboard copy does not push to kill ring

From: Ignacio Casso <[email-masked]>
Date: Sun, 27 Feb 2022 19:57:46 +0100

Hello again,

Sorry for not answering earlier, my original intention was just to
report the bug and clarify the misunderstanding and then leave you all
to discuss it since you would know better what to do. But I though this
could be a chance to make my first Emacs contribution so I'm reviving
the discussion.

> So if (x-get-selection 'CLIPBOARD 'TIMESTAMP) is larger than the last
> time it was recorded, then it is safe to say that the selection has
> "changed".
>
> However, it will still be necessary to keep the DWIM logic on X as a
> fallback in the case that the clipboard timestamp has not changed, since
> some clients are badly behaved and only change their record of the
> current period's selection if they already own it.

So I guess you mean that if the timestamp has not changed, we can't
assume that the selection has not changed either and we need to confirm
it by checking whether the selection text has changed. In other words,
consider that the selection has changed if and only if either the
timestamp or the text has.

If we implemented that, the only new case we would distinguish would be
when the text has not changed but the timestamp has, which is precisely
the case of the "bug" I reported.

If (x-get-selection 'CLIPBOARD 'TIMESTAMP) works out of the box right
now, maybe it's worth to implement it. And it it's not, we could still
update the documentation that reflects the previous, incomplete
understanding of the issue, e.g., in the last paragraph of the docstring
for interprogram-paste-function or in the comments of the definition of
gui-selection-value.

I volunteer to do both if you agree that it would be an improvement. Not
because it's actually important for me (again, all of this began because
I started reporting the bugs I had written down over my time using
Emacs, most of which I did not really care about), but because I see it
as a chance to get started in contributing to free software and Emacs.

Let me know what you think.

Regards,

Ignacio