Subject: Re: bug#27442: Un-obsolete x-clipboard-yank, or provide analogous functional

From: Stefan Monnier <[email-masked]>
Date: Mon, 05 Jul 2021 10:46:12 -0400

> (defun gui-selection-value ()
>   (let ((clip-text
>          (when select-enable-clipboard
>            (let ((text (gui--selection-value-internal 'CLIPBOARD)))
>              (if (string= text "") (setq text nil))
>
>              ;; Check the CLIPBOARD selection for 'newness', is it different
>              ;; from what we remembered them to be last time we did a
>              ;; cut/paste operation.
>              (prog1
>                  (unless (equal text gui--last-selected-text-clipboard)
>                    text)
>                (setq gui--last-selected-text-clipboard text)))))
>
> So, indeed, if you `M-x clipboard-yank', then kill some text in Emacs,
> you can't `M-x clipboard-yank' until you've clipboarded some other text,
> yanked it, and then clipboarded the original text again.
>
> Fixing this should be pretty trivial -- the following patch should do
> the trick, I think (although I haven't tested it).  But I'm not quite
> sure about the intended logic here, so I've added Stefan M to the CCs --
> perhaps he has some comments.

AFAIK this part of the clipboard interaction is one I just preserved
from earlier code when I did my "gui-selection" rework.
I "just preserved" it because I don't really understand how it's
intended to work, nor do I understand enough of the design constraints
to be able to come up with my own design of how it should work :-(

Your patch looks acceptable to me (it is also disappointing because
it doesn't really help understand how this thing is intended to work,
but it follows the same principles as the ones I followed).

        Stefan