emacs-evil / evil

The extensible vi layer for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy/paste in + register doesn't work when evil is run in Emacs terminal

sanel opened this issue · comments

Issue type

  • Bug report

Environment

Emacs version: 29.3
Operating System: Slackware Linux 15.0
Evil version: evil-git-fe44a56
Evil installation type: manual, git master latest
Graphical/Terminal: terminal
Tested in a make emacs session (see CONTRIBUTING.md): No

Reproduction steps

  • Start Emacs in terminal mode (emacs -nw)
  • Select some text and copy it to + register via "+y
  • Try to paste it via "+p
  • Evil with complain with evil-get-register: Register ‘+’ is empty

Also, running :reg will show that nothing is stored in + register. However, in Emacs X GUI, it works.

Expected behavior

It should store copied data in + register, even if it doesn't use X clipboard in terminal.

Actual behavior

It doesn't store anything in + register.

Further notes

I have also very old evil version evil-git-7605519 that has this working, so I'm guessing it got broken when register storage was refactored.

I've noticed I have some custom functions for reading/storing clipboard content for older evil that doesn't work with the latest evil, but if I use stock (old) evil version with these custom functions disabled, it behaves like the current master - it doesn't store anything in + register.

However, Vim will store data in + register when is run in terminal, not sure about the behavior here... What others think?

At least on GNU Emacs >=29, Evil mode unambiguously just defers to the ordinary Emacs clipboard handling:

evil/evil-common.el

Lines 1961 to 1964 in fe44a56

((memq register '(?* ?+))
(let ((what (if (eq register ?*) 'PRIMARY 'CLIPBOARD)))
(if (eval-when-compile (>= emacs-major-version 29))
(gui--selection-value-internal what)

That is to say, this is not a concern of Evil mode. In any case, clipboard access in the terminal is not guaranteed. Some terminal emulators support clipboard xterm VT sequences which Emacs will try to use, but e.g. tmux or SSH may not forward those. I previously used the xclip package, which relies on xclip/wl-clipboard/etc. Not sure why your old Evil mode checkout did work however.

Thank you @axelf4 for fast reply and pointing to the actual code. I just started to play with xclip package you mentioned and it works without problems, so closing this was a good call :)