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

12. The Mark and the Region

Many af commands operate on an arbitrary contiguous part of the current buffer. To specify the text for such a command to operate on, you set the mark at one end of it, and move point to the other end. The text between point and the mark is called the region.

You can move point or the mark to adjust the boundaries of the region. It doesn't matter which one is set first chronologically, or which one comes earlier in the buffer. Once the mark has been set, it remains where you put it until you set it again at another place. Each af buffer has its own mark, so that when you return to a buffer that had been selected previously, it has the same mark it had before.

Many commands that insert messages (or text in the minibuffer), such as C-y (yank) and C-x i (insert-file), position point and the mark at opposite ends of the inserted text, so that the region contains the text just inserted.

12.1 Setting the Mark  Commands to set the mark.
12.2 Operating on the Region  Ways you can operate on the region.
12.3 Using the Region in Typeout  Things you can do with the region in typeout.
12.4 Using the Region in the Minibuffer  Region operations in the minibuffer.


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

12.1 Setting the Mark

There are two commands to set the mark in a buffer. These commands work identically in mail buffers, typeout, and the minibuffer.

C-SPC or C-@ or M-SPC
Set the mark where point is (set-mark-command).
C-x C-x
Interchange mark and point (exchange-point-and-mark).

For example, suppose you wish to save part of a mail buffer to a folder, using the C-x + (save-region) command, which operates on the messages in the region. You can first go to the beginning of the messages to be saved, type C-SPC to put the mark there, move to the end, and then type C-x +. Or, you can set the mark at the end of the text, move to the beginning, and then type C-x +.

The most common way to set the mark is with the C-SPC command (set-mark-command). This sets the mark where point is. Then you can move point away, leaving the mark behind.

Af doesn't show you where the mark is located. You have to remember. The usual solution to this problem is to set the mark and then use it soon, before you forget where it is. Alternatively, you can see where the mark is with the command C-x C-x (exchange-point-and-mark) which puts the mark where point was and point where the mark was. The extent of the region is unchanged, but point is now at the previous position of the mark.

C-x C-x is also useful when you are satisfied with the position of point but want to move the mark; do C-x C-x to put point at that end of the region, and then move it. A second use of C-x C-x, if necessary, puts the mark at the new position with point back at its original position.

There is no such character as C-SPC in ASCII; when you type SPC while holding down CTRL, what you get on most ordinary terminals is the character C-@. This key is actually bound to set-mark-command. But unless you are unlucky enough to have a terminal where typing C-SPC does not produce C-@, you might as well think of this character as C-SPC. If you are on a terminal where C-SPC doesn't work, you could use M-SPC instead; it is also bound to set-mark-command.


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

12.2 Operating on the Region

Once you have a region in a mail buffer, here are some of the commands that operate on the region. Note that these commands all have the word region in their names.

C-w
Kill the messages in the region (kill-region). See section 14. Killing and Yanking.
M-w
Copy the region into the kill buffer as if it had been killed (copy-region-as-kill). See section 14. Killing and Yanking.
C-x + folder RET
Save the messages in the region into folder (save-region). This command handles the argument in the same way as M-+ (save-message). See section 11.1 Saving Messages.
C-x p
Print a hardcopy of all the messages in the region (print-region). This command handles the argument in the same way as M-p (print-message). See section 11.2 Printing Messages.
C-x | command RET
Pipe the messages in the region into a single instance of the shell command command (pipe-region). Again, this command handles the argument in the same way as M-| (pipe-message) See section 11.3 Piping Messages.


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

12.3 Using the Region in Typeout

Typeout is only used to display text, and not to edit or delete anything. For that reason, there are no commands which operate on the region available in typeout. It is still possible to set the mark in the typeout buffer; but the only thing you can do with it is to use C-x C-x (exchange-point-and-mark) to move back to the mark.


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

12.4 Using the Region in the Minibuffer

The minibuffer supports the mark and region, but only a subset of the commands which are available in a mail buffer to process the region. Since the minibuffer deals with text rather than messages, the region delimits a block of text in the minibuffer.

Just like any other buffer, the minibuffer has its own mark. The mark is not preserved between uses of the minibuffer, or when you move between minibuffer history entries, so you will usually need to set the mark in the minibuffer before you use it.

There are two commands which operate on the region in the minibuffer:

C-w
Delete the text in the region (kill-region). See section 14.5 Killing and Yanking in the Minibuffer.
M-w
Copy the text in the region into the kill buffer as if it had been killed (copy-region-as-kill). See section 14.5 Killing and Yanking in the Minibuffer.


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

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