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)
Drew
  • 75,699
  • 9
  • 109
  • 225
  • 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 Dec 17 '17 at 05:53
  • 1
    They apparently fixed it in evil: https://github.com/emacs-evil/evil/pull/937 But I haven't tested it myself. – Thomas Bonk Feb 03 '18 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 Feb 04 '18 at 00:42
  • How about @ThomasBonk write his comment as an answer and OP accept it, so this question can be marked as answered? – Davor Cubranic Jul 25 '18 at 17:26
  • @DavorCubranic I didn't know I could answer my own question. Thanks! – Thomas Bonk Jul 26 '18 at 18:09
  • @ThomasBonk now accept it! – Davor Cubranic Jul 27 '18 at 07:49

1 Answers1

1

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