9.5.3 Yanking Earlier Kills
To recover killed text that is no longer the most recent kill, you need
the `Meta-y' (`yank-pop') command. You can use `M-y' only after a
`C-y' or another `M-y'. It takes the text previously yanked and
replaces it with the text from an earlier kill. To recover the text of
the next-to-the-last kill, first use `C-y' to recover the last kill,
then `M-y' to replace it with the previous kill.
You can think in terms of a "last yank" pointer which points at an
item in the kill ring. Each time you kill, the "last yank" pointer
moves to the new item at the front of the ring. `C-y' yanks the item
which the "last yank" pointer points to. `M-y' moves the "last yank"
pointer to a different item, and the text in the buffer changes to
match. Enough `M-y' commands can move the pointer to any item in the
ring, so you can get any item into the buffer. Eventually the pointer
reaches the end of the ring; the next `M-y' moves it to the first item
Yanking moves the "last yank" pointer around the ring, but does not
change the order of the entries in the ring, which always runs from the
most recent kill at the front to the oldest one still remembered.
Use `M-y' with a numeric argument to advance the "last yank" pointer
by the specified number of items. A negative argument moves the
pointer toward the front of the ring; from the front of the ring, it
moves to the last entry and starts moving forward from there.
Once the text you are looking for is brought into the buffer, you can
stop doing `M-y' commands and the text will stay there. Since the text
is just a copy of the kill ring item, editing it in the buffer does not
change what's in the ring. As long you don't kill additional text, the
"last yank" pointer remains at the same place in the kill ring:
repeating `C-y' will yank another copy of the same old kill.
If you know how many `M-y' commands it would take to find the text
you want, you can yank that text in one step using `C-y' with a numeric
argument. `C-y' with an argument greater than one restores the text
the specified number of entries back in the kill ring. Thus, `C-u 2
C-y' gets the next to the last block of killed text. It is equivalent
to `C-y M-y'. `C-y' with a numeric argument starts counting from the
"last yank" pointer, and sets the "last yank" pointer to the entry that
The variable `kill-ring-max' controls the length of the kill ring;
no more than that many blocks of killed text are saved.
automatically generated by info2www version 184.108.40.206