1. Frank Fischer
  2. evil
  3. Issues
Issue #304 wontfix

Paste/Yank to Clipboard: Best Practices

Alexander Shukaev
created an issue
(defun haroogan/evil-paste-from-clipboard ()
  "Paste text from system clipboard."
  (interactive)
  (evil-paste-from-register ?+))

(evil-define-operator haroogan/evil-yank-to-clipboard (beg end type yank-handler)
  "Yank text to system clipboard."
  :move-point nil
  :repeat nil
  (interactive "<x><y>")
  (evil-yank beg end type ?+ yank-handler))

Paste works as intended. Yank works partly:

  • after yanking I can paste this text into other applications;
  • but I cannot paste it into the Emacs itself, i.e. by using haroogan/evil-paste-from-clipboard - it says that the kill-ring is empty; how come?

For the reference, in my .vimrc I have the following:

" Cut to the system clipboard.
nnoremap <C-x> "+x
vnoremap <C-x> "+x
cnoremap <C-x> "+x

" Yank to the system clipboard.
nnoremap <C-y> "+y
vnoremap <C-y> "+y
cnoremap <C-y> "+y

" Paste from the system clipboard.
nnoremap <C-p> "+p
vnoremap <C-p> "+p
cnoremap <C-p> "+p

What's the best way to replicate this with Evil?

Comments (3)

  1. Frank Fischer repo owner
    • changed status to open

    Hm, a have difficulties to reproduce your problem. There are several options in Emacs that influence the interaction with clipboard and/or X-selection independent of Evil (e.g. x-select-enable-clipboard, x-select-enable-primary and so on). And it may depend on the system you use.

    So please tell us which system you use and give a (minimal) example to reproduce the problem (i.e. run make emacs in Evil's source directory and then a sequence of keystrokes that demonstrate your problem).

    And please check whether there's some kind of clipboard-manager running.

    Does the problem remain if you run the yank/paste commands directly with a register argument instead of calling your functions (i.e. "+yy or "+p, respectively).

  2. Frank Fischer repo owner

    I still can't reproduce the problem. If the problem still exists, please reopen the issue and provide a minimal example starting with make emacs from Evil's source.

  3. Log in to comment