mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.94k stars 716 forks source link

Built-in clipboard integration #3935

Open lenormf opened 3 years ago

lenormf commented 3 years ago

Feature

A substantial amount of users complains that the editor doesn't integrate with their system's clipboard out of the box.

If that's not going to happen, is there anything we can do to meet them halfway? I was thinking that the editor hardcodes multiple commands already (for example, to interact with window managers like Tmux, Kitty…), and has some selection logic (termcmd).

Could we not provide users with a command (or user mode? other?) based API that works along the same lines, so that they at least wouldn't have to look for the right xclip/xsel/… command? It would then be up to them to declare mapping in their user configuration.

HTH.

NotAFile commented 3 years ago

I'm currently experimenting with kakoune and this was my first real stumble.

I had expected to have the system clipboard available via the "* and "+ registers as in vim. I think this is my far the most elegant way to handle it.

lenormf commented 3 years ago

How about a command that sets a global NormalIdle hook which populates a register (* or + or other) with the contents of the system clipboard?

The user calls the command in their configuration, and the editor does everything else.

NotAFile commented 3 years ago

@lenormf

How about a command that sets a global NormalIdle hook which populates a register (* or + or other) with the contents of the system clipboard?

If my assumptions about NormalIdle are correct, this wouldn't be a good idea. Counterintuitively, the content of the clipboard is not fetched when you copy, but when you paste. The act of copying merely tells the OS to notify that window the next time something is pasted. It sounds with this solution, if you copied (or selected) something large, kakoune would be constantly requesting that process to send over the contents of the clipboard. Furthermore, if you accessed the register from another mode, it would be outdated.

I think a solution where you can specify a hook to populate a register when it is accessed would be better there, if you want to avoid special casing the clipboard.

Screwtapello commented 3 years ago

859 was about register hooks. mawww implemented the RegisterModified hook, but I guess the corresponding "about to read register value" hook was too intrusive.