spudlyo/clipetty

[BUG] (Evil-paste-after) fails after (evil-yank-line) when clipetty enabled

Closed this issue · 4 comments

Describe the bug
When clipetty-mode is enabled running in terminal (tmux or not), (evil-paste-after) fails after (evil-yank-line). Instead of pasting the yanked line into the line below the point, it is pasted after the point.
It happens in MacOS (iTerm2) and Linux (Kitty). It doesn't happen in graphical mode.
It's intereting that right after the paste fails, if I undo the paste, yank the line again and paste it then it works. As soon as I move the cursor, next yank_line->paste fails, undo->yank_line->paste works, and so on.

To Reproduce
Steps to reproduce the behavior:
1- Run: emacsclient -nw ~/init.el
2- M-x clipetty-mode
3- In evil-mode: yy (over any line) and p ==> FAILS
4- u (undo) -> yy (yank-line) -> p (paste) ==> WORKS
5- move the cursor and repeat 3, 4 and 5, etc...
6- Disable clipetty-mode and then repeating 3, 4 and 5: 3 never fails, always behaves as 4.

Expected behavior
In terminal mode with clipetty-mode enabled (in tmux or not) evil-yank-line should be pasted below the point/cursor, not after the point/cursor

** System Info (please complete the following information):**

  • OS: Linux and MacOS
  • Emacs Version: 26.3
  • Terminal program: iTerm2 and Kitty
  • Any terminal multiplexers in play: doesn't matter, it happens within TMUX or in not multiplexed terminal.
  • Local or remote: both

Additional context
It happens pasting within the same buffer or into diferent one.

This is a just a little annoyance compared with how usefull and convenient clipetty has been in my workflow this last week since I discovered it, so thank you very much for your work.

Thanks for submitting this bug! Not knowing much about to modal editing, it's taken me a bit to wrap my head around this, as in vim parlance to 'yank' something means to save it to the kill ring, and to paste something is what Emacs folks call yanking.

Now as I understand it, the way the evil-paste-after function works is dependent on what kind of content exists in the Emacs kill ring. If the text in the kill-ring has a newline, then it's considered to be a 'linewise' paste, and in which case it's supposed to act as you expect, and the content is pasted below the point. If however the stuff you're pasting doesn't end in a newline (like if you did y$ instead of yy) it will paste in a 'characterwise' way, where it pastes after the point.

It sounds like the bug here is that for some reason Clipetty is making Evil mode think that the content in the kill ring is characterwise instead of linewise, like somehow it's removing the ending newline? When the bug happens for you, does the content that gets pasted after the point have a newline at the end?

Having said all that, I can't reproduce this on my vanilla 26.3 setup. If I do a yy on a line followed by a p it always pastes the line below the point. If I do a y$ followed by a p it pastes after the point. It works this way for me with or without clipetty-mode.

Can you think of anything I could try to help me to reproduce it? Are you using a distro like Doom or Spacemacs?

Closing this issue as I've not heard back from the @ceblan on this.

Sorry for not coming back to report.
I've not been able to reproduce it again. Probably it was related to having xclip-mode enabled, which I'm not using any more. Anyway, at some point in time clipetty begans to work like a charm. It's a boost in my daily workflow, thanks again.

Cheers!

Great, happy to hear it's working for ya!