Skip to main content
added 69 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

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.)

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).


(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.)

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.)

added 69 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

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. It'sAnd it's what your nextnext yank would yank (by default).


(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.)

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)))

Actually, the current kill is not what you last yanked. It's what you last killed or copied to the kill-ring. It's what your next yank would yank (by default).

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).


(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.)

Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

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)))

Actually, the current kill is not what you last yanked. It's what you last killed or copied to the kill-ring. It's what your next yank would yank (by default).