Skip to content

evil-visual-paste corrupts kill-ring-yank-pointer, interfering with subsequent paste commands #2011

Description

@AlexLewandowski

Environment

  • Emacs version: 30.2
  • Evil version: 1.15.0

Start with

emacs -Q -L evil -l evil/evil.el --eval "(evil-mode 1)"

Description

After evil-visual-paste runs, kill-ring-yank-pointer is left pointing at the tail of the kill ring. This causes subsequent paste commands (both evil-paste-after and evil-visual-paste) to paste from the wrong position in the kill ring.

For reproducing

(setq kill-ring nil)

;; Yank these in sequence
0
1
2
3

;; (message (number-to-string (length kill-ring-yank-pointer)))
;; returns 4

;; evil-paste-after alone on each newline
3
3
3
3

;; evil-visual-paste alone on each newline
0
;; (message (number-to-string (length kill-ring-yank-pointer)))
;; returns 1

0
;; (message (number-to-string (length kill-ring-yank-pointer)))
;; returns 2

0
;; (message (number-to-string (length kill-ring-yank-pointer)))
;; returns 3

0

;; Alternate evil-paste-after and evil-visual-paste
3 ;evil-paste-after
0 ;evil-visual-paste
0 ;evil-paste-after
0 ;evil-visual-paste
1 ;evil-paste-after
0 ;evil-visual-paste
2 ;evil-paste-after
0 ;evil-visual-paste

Workaround

Resetting the pointer after each visual paste prevents evil-paste-after from drifting:

  (defun my/evil-paste-fix (&rest _)
    (setq kill-ring-yank-pointer kill-ring))
  (advice-add 'evil-visual-paste :after #'my/evil-paste-fix)

Even with this fix, evil-visual-paste still pastes 0 (rather than 3). However, this seems to fix the downstream issue that i was experiencing regarding v e " 0 p and its effect on subsequent pastes in doom-emacs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions