Function: consult-yank-replace
consult-yank-replace is an autoloaded, interactive and byte-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
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/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)))))))))