meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.07k stars 128 forks source link

Clipboard Confusing Defaults and Documentation #543

Open drdrjacobs opened 3 months ago

drdrjacobs commented 3 months ago

The default clipboard configuration is confusing and there isn't much clipboard discussion to be found in the docs or other issue reports.

Confusing Defaults

By default the Emacs variable select-enable-clipboard is t as specified here. As a result, kill and yank will access the clipboard.

However, by default meow-use-clipboard is nil as specified in the docs. Consequently, the meow versions of the commands meow-kill and meow-yank will not access the clipboard.

The interplay between these defaults is confusing. For example, lets say I am in INSERT mode, and use C-k to kill line A. Now I exit INSERT mode and then use meow-kill to kill line B. Finally, I re-enter insert mode, and use C-y to yank. I expect this yank will give me line B, the last thing I killed. However, I instead get line A.

Setting meow-use-clipboard to t as a fix: not recommended

If I set meow-use-clipboard to t, I will get the behavior I expect. However, this is listed as "Not recommended" in the docs. There is no reason given, but presumably the idea is to keep kill/yank functionality separate from the clipboard.

Keeping the clipboard separate

If it is desirable to keep the clipboard and kill/yank separate, how do you implement this? Do you use SimpleClip or a custom setup?

eshrh commented 3 months ago

I was also confused about why use clipboard is off by default in meow. At least in my case, I have meow-use-clipboard on all the time. If meow's idea is to wrap emacs defaults then it should match then meow commands should match the behavior of their equivalents...

montchr commented 3 months ago

The nil default for meow-use-clipboard also causes an unexpected disconnect between meow-save (y) and the Emacs default binding of C-y to yank.

When the option is nil, calling meow-save then yank (via C-y) will not insert the text from meow-save. Instead, yank will insert the text from a previous kill.

For some reason, the text saved by meow-save and text saved with kill-line (C-k) always seems to be stored in an unpredictable order. I wasn't able to deduce its ordering logic directly with a couple minutes of trial-and-error, which is also why I don't have a snippet to test. But it always seems that meow-saves will tend to be pushed further back in the slot of the kill-ring, and kill-ring items saved by non-Meow actions seem to be prioritized ahead of Meow's saves. I intentionally did not look at the code to understand why this would be happening because I don't want to rationalize it.

When meow-use-clipboard is non-nil... none of that weirdness happens at all.


[Edit]: I like that Meow has gotten me more comfortable with core Emacs behavior and even its keybindings thanks to the project's admirable philosophy of augmenting instead of replacing (e.g. evil-mode) of Emacs functionality. For that reason, I do find myself alternating frequently between using Meow bindings and core Emacs bindings even within the course of writing a single paragraph or function or whatever. That is a good thing. And that is why any inconsistent behavior becomes more frustrating -- with Meow, inconsistencies become less expected than if I were using evil-mode.

DogLooksGood commented 3 months ago

There were some hacks around the copy/paste in the past, so I was not sure about the compatibility. So I documented as "not recommended". If people think it works well with the clipboard, then I should update the document, or maybe even the default behavior.