5

In certain situations Emacs doesn't properly paste text. Apparently this only happens if the current buffer isn't saved and both web-mode and evil-mode are loaded. I was able to reproduce this behavior with the following config:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(require 'evil)
(evil-mode 1)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))

Reproduction:

Edit the following file:

function test() {
    console.log('hello world');
}

Then press the following series of keys:

yGPwywp (Copy the function in front of the cursor, go to the function name, copy it behind the cursor)

Result:

function test() {
tes
    console.log('hello world');
}
function test() {
    console.log('hello world');
}

Apparently the text has been truncated and is being pasted to the next line. If I remove web-mode (the last two lines) from my config, then everything works as expected:

function ttestest() {
    console.log('hello world');
}
function test() {
    console.log('hello world');
}

Here is the output of web-mode-debug:

Loading /usr/share/emacs/site-lisp/site-start.d/autoconf-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/cmake-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/git-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
test.js has auto save data; consider M-x recover-this-file
 [2 times]
--- WEB-MODE DEBUG BEG ---
versions: emacs(25.0) web-mode("14.0.8")
vars: engine("none") minor("none") content-type("javascript") file("/home/tbo/test.js")
system: window(nil) config("x86_64-redhat-linux-gnu")
colors: fg(nil) bg(nil)
minor modes: (completion-in-region-mode global-eldoc-mode evil-local-mode evil-mode undo-tree-mode global-undo-tree-mode shell-dirtrack-mode)
vars:
web-mode-enable-current-column-highlight=nil
web-mode-enable-current-element-highlight=nil
indent-tabs-mode=t
--- WEB-MODE DEBUG END ---

Here is the output of list-command-history:

(evil-yank 10 14 (quote exclusive) nil nil)
(evil-yank 1 53 (quote line) nil nil)
6
  • Any updates on this issue? I am having the same problem, where the last character on my clipboard is ommited, and a line break seems to be prefixed to my clipboard.
    – modulitos
    Commented Dec 17, 2017 at 5:53
  • 1
    They apparently fixed it in evil: github.com/emacs-evil/evil/pull/937 But I haven't tested it myself. Commented Feb 3, 2018 at 15:52
  • Thanks for the update - I just upgraded my evil mode, and it seems to be working! I think I also had to move away from http://stable.melpa.org/packages/ to http://melpa.org/packages/ for the fix to work.
    – modulitos
    Commented Feb 4, 2018 at 0:42
  • How about @ThomasBonk write his comment as an answer and OP accept it, so this question can be marked as answered? Commented Jul 25, 2018 at 17:26
  • @DavorCubranic I didn't know I could answer my own question. Thanks! Commented Jul 26, 2018 at 18:09

1 Answer 1

1

They apparently fixed it in evil: https://github.com/emacs-evil/evil/pull/937 But I haven't tested it myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.