The kill ring is a list of textual strings. This is what it looks like:
("some text" "a different piece of text" "yet more text")
If this were the contents of my kill ring and I pressed C-y, the string of characters saying ‘some text’ would be inserted in this buffer where my cursor is located.
The yank
command is also used for duplicating text by copying it.
The copied text is not cut from the buffer, but a copy of it is put on the
kill ring and is inserted by yanking it back.
Three functions are used for bringing text back from the kill ring:
yank
, which is usually bound to C-y; yank-pop
,
which is usually bound to M-y; and rotate-yank-pointer
,
which is used by the two other functions.
These functions refer to the kill ring through a variable called the
kill-ring-yank-pointer
. Indeed, the insertion code for both the
yank
and yank-pop
functions is:
(insert (car kill-ring-yank-pointer))
(Well, no more. In GNU Emacs 22, the function has been replaced by
insert-for-yank
which calls insert-for-yank-1
repetitively for each yank-handler
segment. In turn,
insert-for-yank-1
strips text properties from the inserted text
according to yank-excluded-properties
. Otherwise, it is just
like insert
. We will stick with plain insert
since it
is easier to understand.)
To begin to understand how yank
and yank-pop
work, it is
first necessary to look at the kill-ring-yank-pointer
variable.