Next: Internals of Kill Ring, Previous: Yank Commands, Up: The Kill Ring
These functions and variables provide access to the kill ring at a lower level, but still convenient for use in Lisp programs, because they take care of interaction with window system selections (see Window System Selections).
The function
current-killrotates the yanking pointer, which designates the “front” of the kill ring, by n places (from newer kills to older ones), and returns the text at that place in the ring.If the optional second argument do-not-move is non-
nil, thencurrent-killdoesn't alter the yanking pointer; it just returns the nth kill, counting from the current yanking pointer.If n is zero, indicating a request for the latest kill,
current-killcalls the value ofinterprogram-paste-function(documented below) before consulting the kill ring. If that value is a function and calling it returns a string,current-killpushes that string onto the kill ring and returns it. It also sets the yanking pointer to point to that new entry, regardless of the value of do-not-move. Otherwise,current-killdoes not treat a zero value for n specially: it returns the entry pointed at by the yanking pointer and does not move the yanking pointer.
This function pushes the text string onto the kill ring and makes the yanking pointer point to it. It discards the oldest entry if appropriate. It also invokes the value of
interprogram-cut-function(see below).If replace is non-
nil, thenkill-newreplaces the first element of the kill ring with string, rather than pushing string onto the kill ring.If yank-handler is non-
nil, this puts that value onto the string of killed text, as ayank-handlerproperty. See Yanking. Note that if yank-handler isnil, thenkill-newcopies anyyank-handlerproperties present on string onto the kill ring, as it does with other text properties.
This function appends the text string to the first entry in the kill ring and makes the yanking pointer point to the combined entry. Normally string goes at the end of the entry, but if before-p is non-
nil, it goes at the beginning. This function also invokes the value ofinterprogram-cut-function(see below). This handles yank-handler just likekill-new, except that if yank-handler is different from theyank-handlerproperty of the first entry of the kill ring,kill-appendpushes the concatenated string onto the kill ring, instead of replacing the original first entry with it.
This variable provides a way of transferring killed text from other programs, when you are using a window system. Its value should be
nilor a function of no arguments.If the value is a function,
current-killcalls it to get the “most recent kill.” If the function returns a non-nilvalue, then that value is used as the “most recent kill.” If it returnsnil, then the front of the kill ring is used.The normal use of this hook is to get the window system's primary selection as the most recent kill, even if the selection belongs to another application. See Window System Selections.
This variable provides a way of communicating killed text to other programs, when you are using a window system. Its value should be
nilor a function of one required and one optional argument.If the value is a function,
kill-newandkill-appendcall it with the new first element of the kill ring as the first argument. The second, optional, argument has the same meaning as the push argument tox-set-cut-buffer(see Definition of x-set-cut-buffer) and only affects the second and later cut buffers.The normal use of this hook is to set the window system's primary selection (and first cut buffer) from the newly killed text. See Window System Selections.
