Function: consult-yank-replace
consult-yank-replace is an interactive and natively compiled function
defined in consult.el.
Signature
(consult-yank-replace STRING)
Documentation
Select STRING from the kill ring.
If there was no recent yank, insert the string. Otherwise replace the just-yanked string with the selected string.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/6higv2v1wk916v4ynnybyrdkfy2gq44d-emacs-packages-deps/share/emacs/site-lisp/elpa/consult-20261004.957/consult.el
;; Adapted from the Emacs yank-pop function.
;;;###autoload
(defun consult-yank-replace (string)
"Select STRING from the kill ring.
If there was no recent yank, insert the string.
Otherwise replace the just-yanked string with the selected string."
(interactive (list (consult--read-from-kill-ring)))
(when string
(if (not (eq last-command 'yank))
(consult-yank-from-kill-ring string)
(let ((inhibit-read-only t)
(pt (point))
(mk (mark t)))
(setq this-command 'yank)
(funcall (or yank-undo-function 'delete-region) (min pt mk) (max pt mk))
(setq yank-undo-function nil)
(set-marker (mark-marker) pt (current-buffer))
(insert-for-yank string)
(set-window-start (selected-window) yank-window-start t)
(if (< pt mk)
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point) (current-buffer)))))))))