Function: evil-paste-pop
evil-paste-pop is an interactive and byte-compiled function defined in
evil-common.el.
Signature
(evil-paste-pop COUNT)
Documentation
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.
This command uses the same paste command as before, i.e., when
used after evil-paste-after the new text is also yanked using
evil-paste-after, used with the same paste-count argument.
The COUNT argument inserts the COUNTth previous kill. If COUNT is negative this is a more recent kill.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
;; TODO: if undoing is disabled in the current buffer, paste-pop won't
;; work. Although this is probably not a big problem, because usually
;; buffers where `evil-paste-pop' may be useful have undoing enabled.
;; A solution would be to temporarily enable undo when pasting and
;; store the undo information in a special variable that does not
;; interfere with `buffer-undo-list'.
(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'.
This command uses the same paste command as before, i.e., when
used after `evil-paste-after' the new text is also yanked using
`evil-paste-after', used with the same paste-count argument.
The COUNT argument inserts the COUNTth previous kill. If COUNT
is negative this is a more recent kill."
(interactive "p")
(unless (memq last-command
'(evil-paste-after
evil-paste-before
evil-visual-paste))
(user-error "Previous command was not an evil-paste: %s" last-command))
(unless evil-last-paste
(user-error "Previous paste command used a register"))
(evil-undo-pop)
(goto-char (nth 2 evil-last-paste))
(setq this-command (nth 0 evil-last-paste))
;; use temporary kill-ring, so the paste cannot modify it
(let ((kill-ring (list (current-kill
(if (and (> count 0) (nth 5 evil-last-paste))
;; if was visual paste then skip the
;; text that has been replaced
(1+ count)
count))))
(kill-ring-yank-pointer kill-ring))
(when (eq last-command 'evil-visual-paste)
(let ((evil-no-display t))
(evil-visual-restore)))
(funcall (nth 0 evil-last-paste) (nth 1 evil-last-paste))
;; if this was a visual paste, then mark the last paste as NOT
;; being the first visual paste
(when (eq last-command 'evil-visual-paste)
(setcdr (nthcdr 4 evil-last-paste) nil))))