On Sunday, 30 January 2022 04:36:01 CET Ihor Radchenko wrote:

> chris <inkbottle007@gmail.com> writes:

> > 3- if you do `C-y` you can see the URL is in the kill-ring

> > But obviously there is no reason for this URL to be also in the Wayland

> > (or

> > x11) clipboard? (there is no law of nature saying that what is in emacs

> > kill- ring must necessarily also be in wayland clipboard. I think there

> > is a law of nature for the other way around though)

> > In any case, in the case of Kde/Kwin/Wayland, it is not copied in the

> > Wayland clipboard.

> > Maybe it's in the description of org-protocol/store-link that the URL

> > should be copied in emacs kill-ring, in any case, it is.

> > But no it doesn't show in the kde/wayland clipboard (and why would it).

>

> I am not 100% sure if I understand your message clearly. However, just

> letting you know about existence of the following Emacs customisations:


It is, only, in conjunction with `org-protocol`, that kill-ring and Wayland-clipboard get out of sync.


Not in some general case. General case is fine.


But in the case of org-protocol, as described in the original post and not present in the excerpt you quoted, they do get out of sync.


To summarize again there are two things that are happening:


After doing `xdg-open "org-protocol://store-link?url=URL&title=TITLE"`.

The string "URL" is pushed into Emacs kill-ring.

But, this very string "URL", is not inserted into Wayland clipboard.


That was the first thing, string pushed into kill-ring, but not pushed simultaneously, into Wayland clipboard.


Now second thing: from that point onward, the other way around is broken. (And that is the part that is really annoying.)


[Then] I mouse-select a string in Firefox, or any application not Emacs. I verify the string is indeed in Wayland clipboard, I paste it in Firefox, or in the terminal (not Emacs).


Now I do `C-y`: this later string is not pasted, even though it should have been. I do `M-y` to see if I can find the string in the kill-ring: I can't find the string in the kill-ring.


What, instead, is the string at the top of Emacs kill-ring: the string "URL" (from the initial org-protocol action).


So Emacs has now stopped inserting strings from Wayland-clipboard into Emacs kill-ring.


No matter how hard I try.


The labor-intensive workaround:


Now what I do is copy a string inside Emacs using `C-w`.


Then, I verify if I can past it in Firefox: I can. It really is in Wayland clipboard.


Now I copy a string from Firefox into Emacs: it is not broken anymore, until the next time I use org-protocol, at which point it gets broken again.


And now it really is also present in Emacs kill-ring.


> save-interprogram-paste-before-kill:

>         Whether to save existing clipboard text into kill ring before

> replacing it. select-enable-primary:

>         Non-nil means cutting and pasting uses the primary selection.

>

> Best,

> Ihor