On Monday, 31 January 2022 17:29:28 CET Max Nikulin wrote:

> On 31/01/2022 08:14, Ihor Radchenko wrote:

> > chris writes:

> >

> > I am not using Wayland. However, if I just do (kill-new "test") in X and

> > my select-enable-primary is nil (default) - "test" will not go to my X

> > clipboard. It is the default behaviour of Emacs in X that has nothing to

> > do with Org mode.


This quote above is not from me (Chris), I think it's from Ihor, I just say that to try not to add to confusion ;)

I myself, am using Wayland.


> Ihor, please, do not add more confusion to this obscure issue.

> `select-enable-primary' controls PRIMARY selection, not CLIPBOARD.

> `select-enable-clipboard' is an independent variable.

>

> Chris, did you tune clipboard manager in KDE? This kind of software may

> cause quite peculiar behavior...


So, on debian/sid/kde/wayland, I've clicked on "configure clipboard" in the default plasma panel:

I can see "ignore selection" is selected. I don't like "primary selection", I think it's messy.


>

> So, do not confuse PRIMARY selection and CLIPBOARD. Unlike MS Windows,

> X11 has several selection (and legacy cut buffers). I do not know the

> full story, but it seems that wayland developers decided that it is more

> secure to have just clipboard, but they did not sustain pressure of

> users who really like that "hard to discover feature": just select some

> text with mouse without additional hotkeys and paste it using middle click.


Yes, you inadvertently select text, and inadvertently paste it: that's legacy for you.


Well, look at that:

https://bugs.kde.org/show_bug.cgi?id=441668

"Recently middle-click pasting got implemented for the Wayland platform. However, this feature could be regarded as an annoyance due to the risk of inadvertent pasting.", etc.


So "selection ignored by the clipboard" according to kwin/wayland seems to mean "user can't see it when they look in the clipboard"

But it's fully working all right and you just can't disable it.

Awesome.


So yeah, debian-sid-kde-plasma-wayland:

There is both "primary selection"  and "clipboard" and you just can't disable "primary selection".


At least according to the above kde bug report.


>

> Ububntu-21.10 impish, gnome, wayland, Emacs-27.1. I am aware that KDE

> may have rather different implementation related to wayland protocol and

> something may change in Emacs since the released version. I just have VM

> with such configuration.

>

> New session, empty selection and clipboard:

> $ wl-paste --list-types

> No selection

> $ wl-paste --primary --list-types

> No selection

>

> Select a word in terminal using mouse:

> $ wl-paste --primary --list-types

> text/plain

> text/plain;charset=utf-8

> STRING

> TEXT

> COMPOUND_TEXT

> UTF8_STRING

> $ wl-paste --list-types

> No selection

>

> [Ctrl+Shift+V] to copy selection to clipboard

> $ wl-paste --primary --list-types

> text/plain

> text/plain;charset=utf-8

> STRING

> TEXT

> COMPOUND_TEXT

> UTF8_STRING

> $ wl-paste --list-types

> text/plain

> text/plain;charset=utf-8

> STRING

> TEXT

> COMPOUND_TEXT

> UTF8_STRING

>

> Let's copy some text from Firefox and then select another text

> but do not copy it:

> $ wl-paste

> Copy from Firefox

> $ wl-paste --primary

> Just select in Firefox

>

> So paste and insert using middle click are not synchronized now.

>

> Execute the following in Emacs:

> (kill-new "kill-new from Emacs")


Okay, at this point, we have seen, from the kde bug above (https://bugs.kde.org/show_bug.cgi?id=441668), that things are a little bit in a mess, right now.

 

So when I use `wl-paste`, `wl-paste --primary`, `wl-paste --list-types`, `wl-paste --primary --list-types`, I've got results whose logic is following the logic of your examples, with "primary selection" and "clipboard" living their separated lives, and not being synchronized, etc.


But when I use `(kill-new "kill-new from Emacs")`, I've got results "way superior to yours".

 

On the one hand, if I do:

`~/path/emacsclient --create-frame --altern
ate-editor=""`
Then go to `*scratch*`

Then `(kill-new "kill-new from Emacs")`

Then `C-y` gives `kill-new from Emacs`, and,

$ wl-paste
kill-new from Emacs
$ wl-paste --primary
(kill-new "kill-new from Emacs")

On the other hand, if I do `~/path/emacsclient -e "(kill-new \"test523
\")"`, I get:

$ wl-paste --primary; wl-paste
emacsclient -e "(kill-new \"test523\")"
emacsclient -e "(kill-new \"test523\")"
And if I go to the emacsclient actual frame that I've kept open from the example above, and do `C-y`, I get:

test523


So on my system,

`emacsclient -e "(kill-new \"test523\")"`

And

`(kill-new "test523")` executed in a emacsclient frame, in `*scratch*`, with `C-j`.


They don't agree.


And when I do one version, then the other version, then the first version, and try `wl-paste`, very quickly I get a `wl-paste` command that doesn't return, and that I have to stop with "C-c in a terminal let's not get confused".

 

So I think that settles things on my side: it's a mess, let's burry it, forget about it.


> CLIPBOARD is changed, PRIMARY selection is not, it can be tuned in Emacs

> settings. I like the default ones.

> $ wl-paste

> kill-new from Emacs

> $ wl-paste --primary

> Just select in Firefox