aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-06-26 19:31:01 +0000
committerChong Yidong2008-06-26 19:31:01 +0000
commit0665a8b093d530c52efcbbbeea5694ff20847a64 (patch)
tree368a08f2c0c9d3084fbe011df544097a58ba9703
parentdc9bebb8c7b9a336d3ba0374b2d782699ebf50d3 (diff)
downloademacs-0665a8b093d530c52efcbbbeea5694ff20847a64.tar.gz
emacs-0665a8b093d530c52efcbbbeea5694ff20847a64.zip
(Shift selection): New node.
(Mark): Copyedits. (Persistent Mark): Move to the end of the chapter.
-rw-r--r--doc/emacs/mark.texi408
1 files changed, 218 insertions, 190 deletions
diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi
index cf131d32b2e..c5df52aaba9 100644
--- a/doc/emacs/mark.texi
+++ b/doc/emacs/mark.texi
@@ -13,13 +13,12 @@ current buffer. To specify the text for such a command to operate on,
13you set @dfn{the mark} at one end of it, and move point to the other 13you set @dfn{the mark} at one end of it, and move point to the other
14end. The text between point and the mark is called @dfn{the region}. 14end. The text between point and the mark is called @dfn{the region}.
15 15
16 The region always extends between point and the mark, no matter 16 If the mark is active, the region always extends between point and
17which one comes earlier in the text---the region starts from point or 17the mark, no matter which one comes earlier in the text; each time you
18the mark (whichever comes first), and ends at point or the mark 18move point, the region changes. Whenever the mark is active, Emacs
19(whichever comes last). Every time you move point, the region 19highlights the region. You can customize the appearance of this
20changes. When a region is active, Emacs highlights it using the 20highlighting by changing the @code{region} face (@pxref{Face
21@code{region} face. You can customize the appearance of the 21Customization}).
22highlighting by changing this face (@pxref{Face Customization}).
23 22
24 The region persists only until you use it. The mark is 23 The region persists only until you use it. The mark is
25automatically @dfn{deactivated} after certain non-motion commands, 24automatically @dfn{deactivated} after certain non-motion commands,
@@ -28,26 +27,23 @@ also explicitly deactivate the mark at any time, by typing @kbd{C-g}
28(@pxref{Quitting}). 27(@pxref{Quitting}).
29 28
30@vindex highlight-nonselected-windows 29@vindex highlight-nonselected-windows
31 Each Emacs buffer has its own mark, and setting the mark in one 30 Setting the mark in one buffer has no effect on the marks in other
32buffer has no effect on other buffers' marks. When you return to a 31buffers. When you return to a buffer with an active mark, the mark is
33buffer with an active mark, the mark is at the same place as before. 32at the same place as before. When multiple windows show the same
34When multiple windows show the same buffer, they can have different 33buffer, they can have different values of point, and thus different
35values of point, and thus different regions (though they all share one 34regions, but they all share one common mark position. @xref{Windows}.
36common mark position). @xref{Windows}. Ordinarily, only the selected 35Ordinarily, only the selected window highlights its region; however,
37window highlights its region, if a region exists; however, if the 36if the variable @code{highlight-nonselected-windows} is
38variable @code{highlight-nonselected-windows} is non-@code{nil}, each 37non-@code{nil}, each window highlights its own region.
39window highlights its own region.
40
41 If Delete Selection mode is enabled, some commands delete the region
42when used while the mark is active. @xref{Mouse Commands}.
43 38
44@menu 39@menu
45* Setting Mark:: Commands to set the mark. 40* Setting Mark:: Commands to set the mark.
46* Marking Objects:: Commands to put region around textual units. 41* Marking Objects:: Commands to put region around textual units.
47* Using Region:: Summary of ways to operate on contents of the region. 42* Using Region:: Summary of ways to operate on contents of the region.
48* Persistent Mark:: Keeping the mark active all the time.
49* Mark Ring:: Previous mark positions saved so you can go back there. 43* Mark Ring:: Previous mark positions saved so you can go back there.
50* Global Mark Ring:: Previous mark positions in various buffers. 44* Global Mark Ring:: Previous mark positions in various buffers.
45* Shift selection:: Using shifted cursor motion keys.
46* Persistent Mark:: Keeping the mark active all the time.
51@end menu 47@end menu
52 48
53@node Setting Mark 49@node Setting Mark
@@ -57,67 +53,70 @@ when used while the mark is active. @xref{Mouse Commands}.
57 53
58@table @kbd 54@table @kbd
59@item C-@key{SPC} 55@item C-@key{SPC}
60Set the mark where point is (@code{set-mark-command}). 56Set the mark at point (@code{set-mark-command}).
61@item C-@@ 57@item C-@@
62The same. 58The same.
63@item C-x C-x 59@item C-x C-x
64Set the mark where point was, and move point where the mark was 60Set the mark at point, and move point where the mark was
65(@code{exchange-point-and-mark}). 61(@code{exchange-point-and-mark}).
66@item Drag-Mouse-1 62@item Drag-Mouse-1
67Set point and the mark around the text you drag across. 63Set point and the mark around the text you drag across.
68@item Mouse-3 64@item Mouse-3
69Set the mark where point is, then move point to where you click 65Set the mark at point, then move point to where you click
70(@code{mouse-save-then-kill}). 66(@code{mouse-save-then-kill}).
67@item @samp{Shifted motion keys}
68Set the mark at point if the mark is inactive, then move point.
71@end table 69@end table
72 70
73@kindex C-SPC 71@kindex C-SPC
72@kindex C-@@
74@findex set-mark-command 73@findex set-mark-command
75 The most common way to set the mark is with @kbd{C-@key{SPC}} 74 The most common way to set the mark is with @kbd{C-@key{SPC}}
76(@code{set-mark-command}). This sets the mark where point is. You 75(@code{set-mark-command}), which sets the mark where point
77can then move point away, leaving the mark behind. 76is@footnote{There is no @kbd{C-@key{SPC}} character in
77@acronym{ASCII}; usually, typing @kbd{C-@key{SPC}} on a text terminal
78gives the character @kbd{C-@@}. This key is also bound to
79@code{set-mark-command}, so unless you are unlucky enough to have an
80text terminal that behaves differently, you might as well think of
81@kbd{C-@@} as @kbd{C-@key{SPC}}.}. You can then move point away,
82leaving the mark behind.
78 83
79 For example, suppose you wish to convert part of the buffer to upper 84 For example, suppose you wish to convert part of the buffer to upper
80case. To accomplish this, first go to the beginning of the text to be 85case. To accomplish this, go to the beginning of the desired text,
81capitalized, type @kbd{C-@key{SPC}}, and move point until the desired 86type @kbd{C-@key{SPC}}, and move point until the desired portion of
82portion of text is highlighted. You can now type @kbd{C-x C-u} 87text is highlighted. Now type @kbd{C-x C-u} (@code{upcase-region}).
83(@code{upcase-region}), which converts the text in the region to upper 88This converts the text in the region to upper case, and then
84case. This also automatically deactivates the mark. (Alternatively, 89deactivates the mark.
85you could set the mark at the end, move to the beginning, and do
86@kbd{C-x C-u}.)
87 90
88@kindex C-x C-x 91@kindex C-x C-x
89@findex exchange-point-and-mark 92@findex exchange-point-and-mark
90 The command @kbd{C-x C-x} (@code{exchange-point-and-mark}) puts the 93 The command @kbd{C-x C-x} (@code{exchange-point-and-mark}) exchanges
91mark where point was and moves point where the mark was, keeping the 94the positions of point and the mark, keeping the region unchanged. If
92region unchanged. If no mark is active, Emacs reactivates the mark at 95no mark is active, Emacs first reactivates the mark wherever it was
93the position where it was last set. @kbd{C-x C-x} is useful when you 96last set. @kbd{C-x C-x} is useful when you are satisfied with the
94are satisfied with the position of point but want to move the other 97position of point but want to move the other end of the region (where
95end of the region (where the mark is); do @kbd{C-x C-x} to put point 98the mark is). Using @kbd{C-x C-x} a second time, if necessary, puts
96at that end of the region, and then move it. Using @kbd{C-x C-x} a 99the mark at the new position with point back at its original position.
97second time, if necessary, puts the mark at the new position with 100
98point back at its original position. 101 You can also set the mark with the mouse (@pxref{Mouse Commands}).
99 102If you press the left mouse button (@kbd{down-mouse-1}) and drag the
100 You can also set the mark with the mouse. In fact, there are two 103mouse across a range of text while holding down this button, this sets
101ways to do this. You can press the left mouse button 104the mark where you first pressed the mouse button and puts point where
102(@kbd{down-mouse-1}) and drag the mouse across a range of text while 105you release it. Alternatively, clicking the right mouse button
103holding down the button; this sets the mark where you first pressed 106(@kbd{mouse-3}) sets the mark at point and then moves point to where
104the mouse button, and point where you release it. Alternatively, you 107you clicked. Using the mouse to mark a region also copies the region
105can click the right mouse button (@kbd{mouse-3}), which sets the mark 108into the kill ring (@pxref{Kill Ring}).
106at point and then moves point to where you clicked. 109
107 110@cindex shift-selection
108 Using the mouse to mark a region also copies the region into the 111 Finally, you can set the mark by holding down the shift key while
109kill ring (@pxref{Kill Ring}). If you don't want to modify the kill 112typing certain cursor motion commands (such as @kbd{S-@key{right}},
110ring, you must use keyboard commands to set the mark. @xref{Mouse 113@kbd{S-C-f}, @kbd{S-C-n}, etc.) This is referred to as
111Commands}. 114@dfn{shift-selection}. This sets the mark at point before moving
112 115point, but only if there is no active mark set via shift-selection.
113@kindex C-@@ 116The mark set by mouse commands and by shift-selection behaves slightly
114 There is no such character as @kbd{C-@key{SPC}} in @acronym{ASCII}; 117differently from the usual mark: any subsequent unshifted cursor
115when you type @key{SPC} while holding down @key{CTRL} on a text 118motion command deactivates it automatically. For details, @xref{Shift
116terminal, what you get is the character @kbd{C-@@}. This key is also 119selection}.
117bound to @code{set-mark-command}---so unless you are unlucky enough to
118have a text terminal where typing @kbd{C-@key{SPC}} does not produce
119@kbd{C-@@}, you might as well think of this character as
120@kbd{C-@key{SPC}}.
121 120
122 Whenever the mark is active, you can deactivate it by typing 121 Whenever the mark is active, you can deactivate it by typing
123@kbd{C-g} (@pxref{Quitting}). The mark is also automatically 122@kbd{C-g} (@pxref{Quitting}). The mark is also automatically
@@ -132,24 +131,27 @@ object such as a word, list, paragraph or page:
132 131
133@table @kbd 132@table @kbd
134@item M-@@ 133@item M-@@
135Set mark after end of next word (@code{mark-word}). This command and 134Set mark after end of next word (@code{mark-word}). This does not
136the following one do not move point. 135move point.
137@item C-M-@@ 136@item C-M-@@
138Set mark after end of following balanced expression (@code{mark-sexp}). 137Set mark after end of following balanced expression
138(@code{mark-sexp}). This does not move point.
139@item M-h 139@item M-h
140Move point to the beginning of the current paragraph, and set mark at 140Move point to the beginning of the current paragraph, and set mark at
141the end (@code{mark-paragraph}). 141the end (@code{mark-paragraph}).
142@item C-M-h 142@item C-M-h
143Move point to the beginning of the current defun, and set mark at the 143Move point to the beginning of the current defun, and set mark at the
144end (@code{mark-defun}). 144end (@code{mark-defun}).
145@item C-x h
146Move point to the beginning of the buffer, and set mark at the end
147(@code{mark-whole-buffer}).
148@item C-x C-p 145@item C-x C-p
149Move point to the beginning of the current page, and set mark at the 146Move point to the beginning of the current page, and set mark at the
150end (@code{mark-page}). 147end (@code{mark-page}).
148@item C-x h
149Move point to the beginning of the buffer, and set mark at the end
150(@code{mark-whole-buffer}).
151@end table 151@end table
152 152
153@findex mark-word
154@findex mark-sexp
153@kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next 155@kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next
154word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the 156word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the
155next balanced expression (@pxref{Expressions}). These commands handle 157next balanced expression (@pxref{Expressions}). These commands handle
@@ -157,38 +159,32 @@ arguments just like @kbd{M-f} and @kbd{C-M-f}.
157 159
158@kindex C-x h 160@kindex C-x h
159@findex mark-whole-buffer 161@findex mark-whole-buffer
160 Other commands set both point and mark, to delimit an object in the 162 The other commands in the above list set both point and mark, so as
161buffer. For example, @kbd{M-h} (@code{mark-paragraph}) moves point to 163to delimit an object in the buffer. @kbd{M-h} (@code{mark-paragraph})
162the beginning of the paragraph that surrounds or follows point, and 164moves point to the beginning of the paragraph that surrounds or
163puts the mark at the end of that paragraph (@pxref{Paragraphs}). It 165follows point, and sets the mark at the end of that paragraph
164prepares the region so you can indent, case-convert, or kill a whole 166(@pxref{Paragraphs}). As a special exception, repeated invocations of
165paragraph. With a prefix argument, if the argument's value is positive, 167@kbd{M-h} extend the region to subsequent paragraphs. This is
166@kbd{M-h} marks that many paragraphs starting with the one surrounding 168convenient for indenting, case-converting, or killing entire
167point. If the prefix argument is @minus{}@var{n}, @kbd{M-h} also 169paragraphs.
168marks @var{n} paragraphs, running back form the one surrounding point. 170
169In that last case, point moves forward to the end of that paragraph, 171 The @kbd{M-h} command accepts prefix arguments. If the argument's
170and the mark goes at the start of the region. 172value is positive, @kbd{M-h} marks that many paragraphs starting with
171 173the one surrounding point; therefore, @kbd{C-u M-h} is equivalent to
172 @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the 174@kbd{M-h M-h M-h M-h}. If the prefix argument is @minus{}@var{n},
173mark after, the current (or following) major top-level definition, or 175@kbd{M-h} marks @var{n} paragraphs running back from the one
174defun (@pxref{Moving by Defuns}). Repeating @kbd{C-M-h} extends 176surrounding point; in this case, point moves forward to the end of
175the region to subsequent defuns. 177that paragraph, and the mark goes at the start of the region.
176 178
177 @kbd{C-x C-p} (@code{mark-page}) puts point before the current page, 179 Similarly, @kbd{C-M-h} (@code{mark-defun}) sets mark and point
178and mark at the end (@pxref{Pages}). The mark goes after the 180around major top-level definitions (@pxref{Moving by Defuns}), and
179terminating page delimiter (to include it in the region), while point 181@kbd{C-x C-p} (@code{mark-page}) does the same for pages
180goes after the preceding page delimiter (to exclude it). A numeric 182(@pxref{Pages}). These treat repeated invokations and prefix
181argument specifies a later page (if positive) or an earlier page (if 183arguments similarly to @code{mark-paragraph}.
182negative) instead of the current page.
183
184 While the mark is active, repeating the above commands extends the
185region accordingly. For example, you can type either @kbd{C-u 2 M-@@}
186or @kbd{M-@@ M-@@} to mark the next two words. Similarly, repeating
187the @kbd{M-h} command extends the region to subsequent paragraphs.
188 184
189 Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire 185 Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire
190buffer as the region, by putting point at the beginning and the mark at 186buffer as the region, by putting point at the beginning and the mark
191the end. (In some programs this is called ``select all.'') 187at the end. (In some programs this is called ``select all.'')
192 188
193@node Using Region 189@node Using Region
194@section Operating on the Region 190@section Operating on the Region
@@ -225,6 +221,124 @@ Save it in a buffer or a file (@pxref{Accumulating Text}).
225 Most commands that operate on the text in the region have the word 221 Most commands that operate on the text in the region have the word
226@code{region} in their names. 222@code{region} in their names.
227 223
224 If Delete Selection mode is enabled, some commands delete the region
225when used while the mark is active. @xref{Mouse Commands}.
226
227@node Mark Ring
228@section The Mark Ring
229
230@cindex mark ring
231 Aside from delimiting the region, the mark is also useful for
232remembering spots that you may want to go back to. Each buffer
233remembers 16 previous locations of the mark, in the @dfn{mark ring}.
234Commands that set the mark also push the old mark onto this ring.
235
236@table @kbd
237@item C-@key{SPC} C-@key{SPC}
238Set the mark, pushing it onto the mark ring, without activating it.
239@item C-u C-@key{SPC}
240Move point to where the mark was, and restore the mark from the ring
241of former marks.
242@end table
243
244@kindex C-SPC C-SPC
245 The command C-@key{SPC} C-@key{SPC} is handy when you want to use
246the mark to remember a position to which you may wish to return. It
247pushes the current point onto the mark ring, without activating the
248mark (which would cause Emacs to highlight the region). This is
249actually two consecutive invocations of @kbd{C-@key{SPC}}
250(@code{set-mark-command}); the first @kbd{C-@key{SPC}} sets the mark,
251and the second @kbd{C-@key{SPC}} deactivates it. (When Transient Mark
252mode is off, C-@key{SPC} C-@key{SPC} instead activates Transient Mark
253mode temporarily. @xref{Persistent Mark}.)
254
255@kindex C-u C-SPC
256 To return to a marked position, use @code{set-mark-command} with a
257prefix argument: @kbd{C-u C-@key{SPC}}. This moves point to where the
258mark was, and deactivates the mark if it was active. Each subsequent
259@kbd{C-u C-@key{SPC}} jumps to a prior position stored in the mark
260ring. The positions you move through in this way are not lost; they
261go to the end of the ring.
262
263@vindex set-mark-command-repeat-pop
264 If you set @code{set-mark-command-repeat-pop} to non-@code{nil},
265then immediately after you type @kbd{C-u C-@key{SPC}}, you can type
266@kbd{C-@key{SPC}} instead of @kbd{C-u C-@key{SPC}} to cycle through
267the mark ring. By default, @code{set-mark-command-repeat-pop} is
268@code{nil}.
269
270 Each buffer has its own mark ring. All editing commands use the
271current buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}}
272always stays in the same buffer.
273
274@vindex mark-ring-max
275 The variable @code{mark-ring-max} specifies the maximum number of
276entries to keep in the mark ring. If that many entries exist and
277another one is pushed, the earliest one in the list is discarded. Repeating
278@kbd{C-u C-@key{SPC}} cycles through the positions currently in the
279ring.
280
281@vindex mark-even-if-inactive
282 If the variable @code{mark-even-if-inactive} is @code{nil}, commands
283can only use the mark and the region when it is active. This variable
284is non-@code{nil} by default.
285
286 If you want to move back to the same place over and over, the mark
287ring may not be convenient enough. If so, you can record the position
288in a register for later retrieval (@pxref{RegPos,, Saving Positions in
289Registers}).
290
291@node Global Mark Ring
292@section The Global Mark Ring
293@cindex global mark ring
294
295 In addition to the ordinary mark ring that belongs to each buffer,
296Emacs has a single @dfn{global mark ring}. Each time you set a mark,
297in any buffer, this is recorded in the global mark ring in addition to
298the current buffer's own mark ring.
299
300@kindex C-x C-@key{SPC}
301@findex pop-global-mark
302 The command @kbd{C-x C-@key{SPC}} (@code{pop-global-mark}) jumps to
303the buffer and position of the latest entry in the global ring. It also
304rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take
305you to earlier buffers and mark positions.
306
307@node Shift selection
308@section Shift selection
309@cindex shift-selection
310
311 If you hold down the shift key while typing a cursor motion command,
312this sets the mark before moving point, so that the region extends
313from the original position of point to its new position. This
314feature, newly introduced in Emacs 23, is referred to as
315@dfn{shift-selection}. It is similar to the way text is selected in
316other editors.
317
318 The mark set via shift-selection behaves a little differently from
319what we have described above. Firstly, in addition to the usual ways
320of deactivating the mark (such as changing the buffer text or typing
321@kbd{C-g}), the mark is deactivated by any @emph{unshifted} cursor
322motion command. Secondly, any subsequent @emph{shifted} cursor motion
323command avoids setting the mark anew. Therefore, a series of shifted
324cursor motion commands will continuously extend the region.
325
326 Shift-selection only works if the shifted cursor motion key is not
327already bound to a separate command (@pxref{Customization}). For
328example, if you bind @kbd{S-C-f} to another command, typing
329@kbd{S-C-f} runs that command instead of performing a shift-selected
330version of @kbd{C-f} (@code{forward-char}).
331
332 A mark set via mouse commands behaves the same as a mark set via
333shift-selection (@pxref{Setting Mark}). For example, if you specify a
334region by dragging the mouse, you can continue to extend the region
335using shifted cursor motion commands. In either case, any unshifted
336cursor motion command deactivates the mark.
337
338 To turn off shift-selection, set @code{shift-select-mode} to
339@code{nil}. Doing this does not disable setting the mark via mouse
340commands.
341
228@node Persistent Mark 342@node Persistent Mark
229@section Persistent Marks 343@section Persistent Marks
230@cindex mode, Transient Mark 344@cindex mode, Transient Mark
@@ -233,7 +347,7 @@ Save it in a buffer or a file (@pxref{Accumulating Text}).
233@cindex region highlighting 347@cindex region highlighting
234@cindex Zmacs mode 348@cindex Zmacs mode
235 349
236 By default, the region is highlighted whenever it exists, and it 350 By default, the region is highlighted whenever it exists, and
237disappears once you use it or explicitly deactivate the mark. This 351disappears once you use it or explicitly deactivate the mark. This
238behavior is called Transient Mark mode@footnote{It is also sometimes 352behavior is called Transient Mark mode@footnote{It is also sometimes
239called @dfn{Zmacs mode}, because the Zmacs editor on the MIT Lisp 353called @dfn{Zmacs mode}, because the Zmacs editor on the MIT Lisp
@@ -246,15 +360,15 @@ Transient Mark mode is off, the mark is persistent: it is @emph{never}
246deactivated, but can be set to different locations using commands such 360deactivated, but can be set to different locations using commands such
247as @kbd{C-@key{SPC}}. After the first time you set the mark in a 361as @kbd{C-@key{SPC}}. After the first time you set the mark in a
248buffer, there is always a region in that buffer. Emacs will not 362buffer, there is always a region in that buffer. Emacs will not
249highlight the region, because that would be a nuisance. As an 363highlight the region, because that would be a nuisance. As a special
250exception, the region is temporarily highlighted after it is set with 364exception, the region is temporarily highlighted after it is set with
251the mouse. 365the mouse.
252 366
253 To turn off Transient Mark mode, type @kbd{M-x transient-mark-mode}. 367 To turn off Transient Mark mode, type @kbd{M-x transient-mark-mode}.
254This command toggles the mode; you can use the same command to turn 368This command toggles the mode; you can use the same command to turn
255Transient Mark mode on again. You can also toggle Transient Mark mode 369Transient Mark mode on again. You can also turn off Transient Mark
256using the menu bar: in the @samp{Options} menu, use the @samp{Active 370mode using the menu bar: in the @samp{Options} menu, toggle the
257Region Highlighting} menu item. 371@samp{Active Region Highlighting} menu item.
258 372
259 Here are the details of how Emacs behaves when Transient Mark mode 373 Here are the details of how Emacs behaves when Transient Mark mode
260is off: 374is off:
@@ -311,92 +425,6 @@ use them is that some commands operate on the entire buffer instead of
311the region when Transient Mark mode is off. Enabling Transient Mark 425the region when Transient Mark mode is off. Enabling Transient Mark
312mode momentarily gives you a way to use these commands on the region. 426mode momentarily gives you a way to use these commands on the region.
313 427
314@node Mark Ring
315@section The Mark Ring
316
317@cindex mark ring
318 Aside from delimiting the region, the mark is also useful for
319remembering spots that you may want to go back to. Each buffer
320remembers 16 previous locations of the mark, in the @dfn{mark ring}.
321Commands that set the mark also push the old mark onto this ring.
322
323@table @kbd
324@item C-@key{SPC} C-@key{SPC}
325Set the mark, pushing it onto the mark ring, without activating it.
326@item C-u C-@key{SPC}
327Move point to where the mark was, and restore the mark from the ring
328of former marks.
329@end table
330
331@kindex C-SPC C-SPC
332 The command C-@key{SPC} C-@key{SPC} is handy when you want to use
333the mark to remember a position to which you may want to return. It
334pushes the current point onto the mark ring, without activating the
335mark (which would cause Emacs to highlight the region). This is
336actually two consecutive invocations of @kbd{C-@key{SPC}}
337(@code{set-mark-command}); the first @kbd{C-@key{SPC}} sets the mark,
338and the second @kbd{C-@key{SPC}} deactivates it. (When Transient Mark
339mode is off, C-@key{SPC} C-@key{SPC} instead activates Transient Mark
340mode temporarily. @xref{Persistent Mark}.)
341
342@kindex C-u C-SPC
343 To return to a marked position, use @code{set-mark-command} with a
344prefix argument: @kbd{C-u C-@key{SPC}}. This moves point to where the
345mark was, and deactivates the mark if it was active. Each subsequent
346@kbd{C-u C-@key{SPC}} jumps to a prior position stored in the mark
347ring. The positions you move through in this way are not lost; they
348go to the end of the ring.
349
350@vindex set-mark-command-repeat-pop
351 If you set @code{set-mark-command-repeat-pop} to non-@code{nil},
352then immediately after you type @kbd{C-u C-@key{SPC}}, you can type
353@kbd{C-@key{SPC}} instead of @kbd{C-u C-@key{SPC}} to cycle through
354the mark ring. By default, @code{set-mark-command-repeat-pop} is
355@code{nil}.
356
357 Each buffer has its own mark ring. All editing commands use the
358current buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}}
359always stays in the same buffer.
360
361@vindex mark-ring-max
362 The variable @code{mark-ring-max} specifies the maximum number of
363entries to keep in the mark ring. If that many entries exist and
364another one is pushed, the earliest one in the list is discarded. Repeating
365@kbd{C-u C-@key{SPC}} cycles through the positions currently in the
366ring.
367
368@vindex mark-even-if-inactive
369 If the variable @code{mark-even-if-inactive} is @code{nil}, commands
370can only use the mark and the region when it is active. This variable
371is non-@code{nil} by default.
372
373 If you want to move back to the same place over and over, the mark
374ring may not be convenient enough. If so, you can record the position
375in a register for later retrieval (@pxref{RegPos,, Saving Positions in
376Registers}).
377
378@node Global Mark Ring
379@section The Global Mark Ring
380@cindex global mark ring
381
382 In addition to the ordinary mark ring that belongs to each buffer,
383Emacs has a single @dfn{global mark ring}. It records a sequence of
384buffers in which you have recently set the mark, so you can go back
385to those buffers.
386
387 Setting the mark always makes an entry on the current buffer's mark
388ring. If you have switched buffers since the previous mark setting, the
389new mark position makes an entry on the global mark ring also. The
390result is that the global mark ring records a sequence of buffers that
391you have been in, and, for each buffer, a place where you set the mark.
392
393@kindex C-x C-@key{SPC}
394@findex pop-global-mark
395 The command @kbd{C-x C-@key{SPC}} (@code{pop-global-mark}) jumps to
396the buffer and position of the latest entry in the global ring. It also
397rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take
398you to earlier and earlier buffers.
399
400@ignore 428@ignore
401 arch-tag: f35e4d82-911b-4cfc-a3d7-3c87b2abba20 429 arch-tag: f35e4d82-911b-4cfc-a3d7-3c87b2abba20
402@end ignore 430@end ignore