Next: Yanking, Previous: Kill Ring Concepts, Up: The Kill Ring
kill-region is the usual subroutine for killing text. Any
command that calls this function is a “kill command” (and should
probably have “kill” in its name). kill-region puts the
newly killed text in a new element at the beginning of the kill ring or
adds it to the most recent element. It determines automatically (using
last-command) whether the previous command was a kill command,
and if so appends the killed text to the most recent entry.
This function kills the text in the region defined by start and end. The text is deleted but saved in the kill ring, along with its text properties. The value is always
nil.In an interactive call, start and end are point and the mark.
If the buffer or text is read-only,
kill-regionmodifies the kill ring just the same, then signals an error without modifying the buffer. This is convenient because it lets the user use a series of kill commands to copy text from a read-only buffer into the kill ring.If yank-handler is non-
nil, this puts that value onto the string of killed text, as ayank-handlertext property. See Yanking. Note that if yank-handler isnil, anyyank-handlerproperties present on the killed text are copied onto the kill ring, like other text properties.
If this option is non-
nil,kill-regiondoes not signal an error if the buffer or text is read-only. Instead, it simply returns, updating the kill ring but not changing the buffer.
This command saves the region defined by start and end on the kill ring (including text properties), but does not delete the text from the buffer. It returns
nil.The command does not set
this-commandtokill-region, so a subsequent kill command does not append to the same kill ring entry.Don't call
copy-region-as-killin Lisp programs unless you aim to support Emacs 18. For newer Emacs versions, it is better to usekill-neworkill-appendinstead. See Low-Level Kill Ring.
