Subject: Re: bug#73830: using one expression to make multiple X selections

From: Po Lu <[email-masked]>
Date: Thu, 17 Oct 2024 07:49:13 +0800

libreville <[email-masked]> writes:

> Hi there,
>
> going by the list archive, my first email didn't go through. Here it is
> again in case that's right:
>
>
> Hello,
>
> I stumbled on this while trying to elisp a few things into my X
> clipboard manager. Evaluating these two expressions in turn:
>
> (gui-set-selection 'CLIPBOARD "1")
> (gui-set-selection 'CLIPBOARD "2")
>
> results in both "1" and "2" being saved to the clipboard history.
> However:
>
> (progn
>   (gui-set-selection 'CLIPBOARD "1")
>   (gui-set-selection 'CLIPBOARD "2"))
>
> results in "2" being saved to the clipboard history but, contrary to
> what I would expect, not "1". On the other hand this:
>
> (progn
>   (gui-set-selection 'CLIPBOARD "3")
>   (sleep-for 1)
>   (gui-set-selection 'CLIPBOARD "4"))
>
> gets both "3" and "4" onto the clipboard (history). I get similar
> results with kill-new in place of gui-set-selection 'CLIBOARD and with
> other ways of grouping the two kills into one expression.
>
> Why does waiting work around the problem?

Because it takes time for X clipboard managers to respond to selection
ownership changes and to complete reading from other programs'
selections.

Not a bug, sorry.