Aside from delimiting the region, the mark is also useful for remembering spots that you may want to go back to. Each buffer remembers 16 previous locations of the mark, in the mark ring. Commands that set the mark also push the old mark onto this ring.
The command C-<SPC> C-<SPC> is handy when you want to use
the mark to remember a position to which you may wish to return. It
pushes the current point onto the mark ring, without activating the
mark (which would cause Emacs to highlight the region). This is
actually two consecutive invocations of C-<SPC>
(set-mark-command); the first C-<SPC> sets the mark,
and the second C-<SPC> deactivates it. (When Transient Mark
mode is off, C-<SPC> C-<SPC> instead activates Transient Mark
mode temporarily. See Persistent Mark.)
To return to a marked position, use set-mark-command with a
prefix argument: C-u C-<SPC>. This moves point to where the
mark was, and deactivates the mark if it was active. Each subsequent
C-u C-<SPC> jumps to a prior position stored in the mark
ring. The positions you move through in this way are not lost; they
go to the end of the ring.
If you set set-mark-command-repeat-pop to non-nil,
then immediately after you type C-u C-<SPC>, you can type
C-<SPC> instead of C-u C-<SPC> to cycle through
the mark ring. By default, set-mark-command-repeat-pop is
nil.
Each buffer has its own mark ring. All editing commands use the current buffer's mark ring. In particular, C-u C-<SPC> always stays in the same buffer.
The variable mark-ring-max specifies the maximum number of
entries to keep in the mark ring. If that many entries exist and
another one is pushed, the earliest one in the list is discarded. Repeating
C-u C-<SPC> cycles through the positions currently in the
ring.
If the variable mark-even-if-inactive is nil, commands
can only use the mark and the region when it is active. This variable
is non-nil by default.
If you want to move back to the same place over and over, the mark ring may not be convenient enough. If so, you can record the position in a register for later retrieval (see Saving Positions in Registers).
blog comments powered by Disqus