[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14. Killing and Yanking

Killing means erasing messages (or text in the minibuffer) and copying them into the kill ring, from which it can be retrieved by yanking it. Some systems use the terms "cutting" and "pasting" for these operations.

The commonest way of moving or copying messages within af is to kill them, and later yank them elsewhere one or more times. This is very safe because af remembers several recent kills, not just the last one. It is versatile, because the many commands for killing messages can also be used for moving them.

Af has only one kill ring for all mail buffers, so you can kill messages in one buffer and yank them in another buffer. The minibuffer has a separate kill ring for storing text.

All commands which delete messages from the buffer save it in the kill ring (even delete-message when you save the folder) so that you can move or copy it to other parts of the buffer. These commands are known as kill commands.

14.1 Killing Messages  Details of killing and copying messages.
14.2 Yanking Messages  How to yank messages you have killed.
14.3 Appending Kills  Several kills in a row all yank together.
14.4 Yanking Earlier Kills  Yanking something killed some time ago.
14.5 Killing and Yanking in the Minibuffer  Killing and yanking text in the minibuffer.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.1 Killing Messages

There are two ways to add messages to the kill ring; killing and copying. Killing means deleting messages and adding them to the kill ring, while copying means copying messages to the kill ring without deleting them.

There are commands to kill a single message (see section 5.4 Deleting Messages), commands to kill or copy the region (see section 12.2 Operating on the Region), and commands to kill or copy a tagset (see section 13.3 Using Tags).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.2 Yanking Messages

All killed messages are recorded in the kill ring, a list of blocks of messages that have been killed. There is only one kill ring, shared by all mail buffers, so you can kill messages in one buffer and yank them in another buffer. This is the usual way to move messages from one folder to another (See section 11.1 Saving Messages, for another way).

The command C-y (yank) reinserts the most recently killed messages. It leaves the cursor at the end of the text. It sets the mark at the beginning of the text (see section 12. The Mark and the Region).

C-y can take a numeric argument, in which case it select an earlier kill to yank, rather than the last (see section 14.4 Yanking Earlier Kills).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.3 Appending Kills

Normally, each kill command pushes a new entry onto the kill ring. However, two or more kill commands in a row combine their messages into a single entry, so that a single C-y yanks all the messages as a unit, just as they were before they were killed.

Thus, if you want to yank messages as a unit, you need not kill all of them with one command; you can keep killing line after line, until you have killed them all, and you can still get them all back at once.

Commands that kill forward from point add the messages onto the end of the previous killed messages. Commands that kill backward from point add them onto the beginning. This way, any sequence of mixed forward and backward kill commands puts all the killed messages into one entry without rearrangement. Numeric arguments do not break the sequence of appending kills.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.4 Yanking Earlier Kills

To recover killed messages that are no longer the most recent kill, use the M-y command (yank-pop). It takes the messages previously yanked and replaces them with the messages from an earlier kill. So, to recover the messages of the next-to-the-last kill, first use C-y to yank the last kill, and then use M-y to replace it with the previous kill. M-y is allowed only after a C-y or another M-y.

You can understand M-y in terms of a "last yank" pointer which points at an entry in the kill ring. Each time you kill, the "last yank" pointer moves to the newly made entry at the front of the ring. C-y yanks the entry which the "last yank" pointer points to. M-y moves the "last yank" pointer to a different entry, and the text in the buffer changes to match. Enough M-y commands can move the pointer to any entry in the ring, so you can get any entry into the buffer. Eventually the pointer reaches the end of the ring; the next M-y moves it to the first entry again.

M-y moves the "last yank" pointer around the ring, but it 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.

M-y can take a numeric argument, which tells it how many entries to advance the "last yank" pointer by. A negative argument moves the pointer toward the front of the ring; from the front of the ring, it moves "around" to the last entry and continues forward from there.

Once the messages you are looking for are brought into the buffer, you can stop doing M-y commands and it will stay there. They are a copy of the kill ring entry, so altering them in the buffer does not change what's in the ring. As long as no new killing is done, the "last yank" pointer remains at the same place in the kill ring, so repeating C-y will yank another copy of the same previous kill.

If you know how many M-y commands it would take to find the messages you want, you can yank those messages in one step using C-y with a numeric argument. C-y with an argument 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 messages. 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 it yanks.

The length of the kill ring is controlled by the variable kill-ring-max; no more than that many blocks of killed messages are saved.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.5 Killing and Yanking in the Minibuffer

The minibuffer is used for editing text rather than handling mail, so it has it's own kill ring. Any command which kills more than one character at a time (the word and line killing commands) will store the killed text in the minibuffer kill ring. You can yank the killed text back in exactly the same way as killed messages using C-y.

The minibuffer kill commands will append successive kills to the kill ring, just like the mail buffer kill commands do. If you use M-d (delete-word) three times, then the three words you kill will all be stored in a single kill ring entry; and a single yank will insert them into the text at point.

For simplicity, the minibuffer kill ring only has one entry, so you can't use M-y in the minibuffer. If many people find this a problem, then it may change at some point in the future.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Malc Arnold on August, 22 2002 using texi2html