Previous: , Up: Mark   [Contents][Index]


9.1.4 The Mark Ring

Aside from delimiting the region, the mark is also useful for marking a spot that you may want to go back to. To make this feature more useful, Emacs remembers 16 previous locations of the mark in the mark ring. Most commands that set the mark push the old mark onto this ring. To return to a marked location, use C-u C-SPC (or C-u C-@); this is the command set-mark-command given a numeric argument. The command moves point to where the mark was, and restores the mark from the ring of former marks. Repeated use of this command moves point to all the old marks on the ring, one by one. The marks you have seen go to the end of the ring, so no marks are lost.

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.

Many commands that can move long distances, such as M-< (beginning-of-buffer), start by setting the mark and saving the old mark on the mark ring. This makes it easier for you to move back later. Searches set the mark, unless they do not actually move point. When a command sets the mark, ‘Mark Set’ is printed in the echo area.

The variable mark-ring-max is the maximum number of entries to keep in the mark ring. If that many entries exist and another entry is added, the last entry in the list is discarded. Repeating C-u C-SPC circulates through the entries that are currently in the ring.

The variable mark-ring holds the mark ring itself, as a list of marker objects in the order most recent first. This variable is local in every buffer.


Previous: , Up: Mark   [Contents][Index]