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)
http://stable.melpa.org/packages/
tohttp://melpa.org/packages/
for the fix to work.