The last thing you yanked is typically the front of the kill-ring
.
You can access that programmatically as (current-kill 0 'DONT-MOVE)
.
For example:
(defun my-command ()
"..."
(interactive)
(message "The current kill string is: %s" (current-kill 0 'DONT-MOVE)))
Then you can do M-x my-command
to yank what you last yanked.
Actually, the current kill is not necessarily what you last yanked. It's what you last yanked, killed, or copied to the kill-ring
, whichever of those actions is most recent. And it's what your next yank would yank (by default).
(I think using Avy and Evil are irrelevant to what you're asking, so I removed those tags.)
(Your question as originally worded spoke of using the latest yank as an "argument" of the command or other function you're writing. It's not clear how you want to do that - from what you want to pass it to your function as an argument. But the idea is the same: you access the latest kill using function current-kill
.)
(Your question as originally worded spoke of "interactive function", so I included interactive
in the answer. Dunno if that's what you're really looking for.)