syl20bnr/evil-iedit-state

evil-paste-pop error

Open

#31 建立於 2020年8月20日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)Emacs Lisp (26 fork)github user discovery
bughelp wanted

倉庫指標

Star
 (59 star)
PR 合併指標
 (PR 指標待抓取)

描述

It doesn't work to cycle the kill-ring with M-y after pasting.

Reproduction steps

  • type or copy and paste the following into a new buffer:
a
a
a

b
c
d
  • copy yy the three lines: b, c and d
  • move the cursor to one of the first three lines (on an: a)
  • call: M-x evil-iedit-state/iedit-mode
  • paste: p (evil-iedit-state/paste-replace) the three as were replaced by ds and a newline as expected:
d

d

d


b
c
d
  • cycle to the previous kill-ring item by pressing: M-y (evil-paste-pop)

Error message:

user-error: Previous command was not an evil-paste: evil-iedit-state/paste-replace

Cause

evil-paste-pop expects the following commands:

(defun evil-paste-pop (count)
  "Replace the just-yanked stretch of killed text with a different stretch.
This command is allowed only immediatly after a `yank',
`evil-paste-before', `evil-paste-after' or `evil-paste-pop'.

source: https://github.com/emacs-evil/evil/blob/6b3df51009d1044dca01031084235a7deea50d00/evil-common.el#L2671-L2674

A possible fix

Change the this-command to evil-paste-before:

(defun evil-iedit-state/paste-replace (count)
  "Replace the selection with the yanked text."
  (interactive "P")
  (setq this-command 'evil-paste-before)
  (when kill-ring (iedit-delete-occurrences))
  (evil-paste-before count nil '(#'insert-as-yank)))

Now the following error is shown after pressing M-y in the reproduction steps above:

Error in post-command-hook (iedit-update-occurrences-2): (wrong-type-argument number-or-marker-p nil)

and the buffer looks like this:

c
d




b
c
d

iedit without evil or evil-iedit-state

M-y (yank-pop) works after C-y (yank) in iedit without evil or evil-iedit-state.

System Info

evil-iedit-state ;; Version: 1.2 (evil-iedit-state-20200820.1258) iedit ;; Version: 0.9.9.9 (iedit-20200807.853) Evil version 1.14.0 GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) of 2020-08-12 Windows 1903

貢獻者指南