annotate man/mark.texi @ 58731:24090719258d

*** empty log message ***
author Jay Belanger <jay.p.belanger@gmail.com>
date Thu, 02 Dec 2004 21:21:32 +0000
parents 378fee0ad45e
children 83b92481d956 d8411455de48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1 @c This is part of the Emacs manual.
39287
3b40423b9355 Update the copyright years.
Eli Zaretskii <eliz@gnu.org>
parents: 39264
diff changeset
2 @c Copyright (C) 1985,86,87,93,94,95,1997,2001 Free Software Foundation, Inc.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3 @c See file emacs.texi for copying conditions.
Dave Love <fx@gnu.org>
parents:
diff changeset
4 @node Mark, Killing, Help, Top
Dave Love <fx@gnu.org>
parents:
diff changeset
5 @chapter The Mark and the Region
Dave Love <fx@gnu.org>
parents:
diff changeset
6 @cindex mark
Dave Love <fx@gnu.org>
parents:
diff changeset
7 @cindex setting a mark
Dave Love <fx@gnu.org>
parents:
diff changeset
8 @cindex region
Dave Love <fx@gnu.org>
parents:
diff changeset
9
Dave Love <fx@gnu.org>
parents:
diff changeset
10 Many Emacs commands operate on an arbitrary contiguous part of the
Dave Love <fx@gnu.org>
parents:
diff changeset
11 current buffer. To specify the text for such a command to operate on,
Dave Love <fx@gnu.org>
parents:
diff changeset
12 you set @dfn{the mark} at one end of it, and move point to the other
Dave Love <fx@gnu.org>
parents:
diff changeset
13 end. The text between point and the mark is called @dfn{the region}.
Dave Love <fx@gnu.org>
parents:
diff changeset
14 Emacs highlights the region whenever there is one, if you enable
Dave Love <fx@gnu.org>
parents:
diff changeset
15 Transient Mark mode (@pxref{Transient Mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
16
38411
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
17 Certain Emacs commands set the mark; other editing commands do not
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
18 affect it, so the mark remains where you set it last. Each Emacs
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
19 buffer has its own mark, and setting the mark in one buffer has no
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
20 effect on other buffers' marks. When you return to a buffer that was
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
21 current earlier, its mark is at the same place as before.
38411
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
22
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
23 The ends of the region are always point and the mark. It doesn't
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
24 matter which of them was put in its current place first, or which one
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
25 comes earlier in the text---the region starts from point or the mark
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
26 (whichever comes first), and ends at point or the mark (whichever
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
27 comes last). Every time you move point, or set the mark in a new
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
28 place, the region changes.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
29
Dave Love <fx@gnu.org>
parents:
diff changeset
30 Many commands that insert text, such as @kbd{C-y} (@code{yank}) and
38411
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
31 @kbd{M-x insert-buffer}, position point and the mark at opposite ends
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
32 of the inserted text, so that the region consists of the text just
2fc02d49a9a4 Clarify initial discussion.
Richard M. Stallman <rms@gnu.org>
parents: 38208
diff changeset
33 inserted.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
34
Dave Love <fx@gnu.org>
parents:
diff changeset
35 Aside from delimiting the region, the mark is also useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
36 remembering a spot that you may want to go back to. To make this
Dave Love <fx@gnu.org>
parents:
diff changeset
37 feature more useful, each buffer remembers 16 previous locations of the
Dave Love <fx@gnu.org>
parents:
diff changeset
38 mark in the @dfn{mark ring}.
Dave Love <fx@gnu.org>
parents:
diff changeset
39
Dave Love <fx@gnu.org>
parents:
diff changeset
40 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
41 * Setting Mark:: Commands to set the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
42 * Transient Mark:: How to make Emacs highlight the region--
Dave Love <fx@gnu.org>
parents:
diff changeset
43 when there is one.
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
44 * Momentary Mark:: Enabling Transient Mark mode momentarily.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
45 * Using Region:: Summary of ways to operate on contents of the region.
Dave Love <fx@gnu.org>
parents:
diff changeset
46 * Marking Objects:: Commands to put region around textual units.
Dave Love <fx@gnu.org>
parents:
diff changeset
47 * Mark Ring:: Previous mark positions saved so you can go back there.
Dave Love <fx@gnu.org>
parents:
diff changeset
48 * Global Mark Ring:: Previous mark positions in various buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
49 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
50
Dave Love <fx@gnu.org>
parents:
diff changeset
51 @node Setting Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
52 @section Setting the Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
53
Dave Love <fx@gnu.org>
parents:
diff changeset
54 Here are some commands for setting the mark:
Dave Love <fx@gnu.org>
parents:
diff changeset
55
Dave Love <fx@gnu.org>
parents:
diff changeset
56 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
57 @item C-@key{SPC}
Dave Love <fx@gnu.org>
parents:
diff changeset
58 Set the mark where point is (@code{set-mark-command}).
Dave Love <fx@gnu.org>
parents:
diff changeset
59 @item C-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
60 The same.
Dave Love <fx@gnu.org>
parents:
diff changeset
61 @item C-x C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
62 Interchange mark and point (@code{exchange-point-and-mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
63 @item Drag-Mouse-1
Dave Love <fx@gnu.org>
parents:
diff changeset
64 Set point and the mark around the text you drag across.
Dave Love <fx@gnu.org>
parents:
diff changeset
65 @item Mouse-3
Dave Love <fx@gnu.org>
parents:
diff changeset
66 Set the mark where point is, then move point to where you click
Dave Love <fx@gnu.org>
parents:
diff changeset
67 (@code{mouse-save-then-kill}).
Dave Love <fx@gnu.org>
parents:
diff changeset
68 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
69
Dave Love <fx@gnu.org>
parents:
diff changeset
70 For example, suppose you wish to convert part of the buffer to
Dave Love <fx@gnu.org>
parents:
diff changeset
71 upper case, using the @kbd{C-x C-u} (@code{upcase-region}) command,
Dave Love <fx@gnu.org>
parents:
diff changeset
72 which operates on the text in the region. You can first go to the
Dave Love <fx@gnu.org>
parents:
diff changeset
73 beginning of the text to be capitalized, type @kbd{C-@key{SPC}} to put
Dave Love <fx@gnu.org>
parents:
diff changeset
74 the mark there, move to the end, and then type @kbd{C-x C-u}. Or, you
Dave Love <fx@gnu.org>
parents:
diff changeset
75 can set the mark at the end of the text, move to the beginning, and then
Dave Love <fx@gnu.org>
parents:
diff changeset
76 type @kbd{C-x C-u}.
Dave Love <fx@gnu.org>
parents:
diff changeset
77
Dave Love <fx@gnu.org>
parents:
diff changeset
78 @kindex C-SPC
Dave Love <fx@gnu.org>
parents:
diff changeset
79 @findex set-mark-command
Dave Love <fx@gnu.org>
parents:
diff changeset
80 The most common way to set the mark is with the @kbd{C-@key{SPC}} command
Dave Love <fx@gnu.org>
parents:
diff changeset
81 (@code{set-mark-command}). This sets the mark where point is. Then you
Dave Love <fx@gnu.org>
parents:
diff changeset
82 can move point away, leaving the mark behind.
Dave Love <fx@gnu.org>
parents:
diff changeset
83
Dave Love <fx@gnu.org>
parents:
diff changeset
84 There are two ways to set the mark with the mouse. You can drag mouse
Dave Love <fx@gnu.org>
parents:
diff changeset
85 button one across a range of text; that puts point where you release the
Dave Love <fx@gnu.org>
parents:
diff changeset
86 mouse button, and sets the mark at the other end of that range. Or you
Dave Love <fx@gnu.org>
parents:
diff changeset
87 can click mouse button three, which sets the mark at point (like
Dave Love <fx@gnu.org>
parents:
diff changeset
88 @kbd{C-@key{SPC}}) and then moves point (like @kbd{Mouse-1}). Both of
Dave Love <fx@gnu.org>
parents:
diff changeset
89 these methods copy the region into the kill ring in addition to setting
Dave Love <fx@gnu.org>
parents:
diff changeset
90 the mark; that gives behavior consistent with other window-driven
Dave Love <fx@gnu.org>
parents:
diff changeset
91 applications, but if you don't want to modify the kill ring, you must
Dave Love <fx@gnu.org>
parents:
diff changeset
92 use keyboard commands to set the mark. @xref{Mouse Commands}.
Dave Love <fx@gnu.org>
parents:
diff changeset
93
Dave Love <fx@gnu.org>
parents:
diff changeset
94 @kindex C-x C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
95 @findex exchange-point-and-mark
Dave Love <fx@gnu.org>
parents:
diff changeset
96 Ordinary terminals have only one cursor, so there is no way for Emacs
Dave Love <fx@gnu.org>
parents:
diff changeset
97 to show you where the mark is located. You have to remember. The usual
38482
c8c4805bde95 Minor changes from Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents: 38461
diff changeset
98 solution to this problem is to set the mark and then use it soon, before
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
99 you forget where it is. Alternatively, you can see where the mark is
Dave Love <fx@gnu.org>
parents:
diff changeset
100 with the command @kbd{C-x C-x} (@code{exchange-point-and-mark}) which
Dave Love <fx@gnu.org>
parents:
diff changeset
101 puts the mark where point was and point where the mark was. The extent
Dave Love <fx@gnu.org>
parents:
diff changeset
102 of the region is unchanged, but the cursor and point are now at the
Dave Love <fx@gnu.org>
parents:
diff changeset
103 previous position of the mark. In Transient Mark mode, this command
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
104 also reactivates the mark.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
105
Dave Love <fx@gnu.org>
parents:
diff changeset
106 @kbd{C-x C-x} is also useful when you are satisfied with the position
Dave Love <fx@gnu.org>
parents:
diff changeset
107 of point but want to move the other end of the region (where the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
108 is); do @kbd{C-x C-x} to put point at that end of the region, and then
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
109 move it. Using @kbd{C-x C-x} a second time, if necessary, puts the mark at
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
110 the new position with point back at its original position.
Dave Love <fx@gnu.org>
parents:
diff changeset
111
36359
33c7ddaf02c6 (Setting Mark): Add a cross-reference to the section which describes
Eli Zaretskii <eliz@gnu.org>
parents: 36165
diff changeset
112 For more facilities that allow you to go to previously set marks, see
33c7ddaf02c6 (Setting Mark): Add a cross-reference to the section which describes
Eli Zaretskii <eliz@gnu.org>
parents: 36165
diff changeset
113 @ref{Mark Ring}.
33c7ddaf02c6 (Setting Mark): Add a cross-reference to the section which describes
Eli Zaretskii <eliz@gnu.org>
parents: 36165
diff changeset
114
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
115 @kindex C-@@
52979
3649390c0f91 Replace @sc{ascii} and ASCII with @acronym{ASCII}.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
116 There is no such character as @kbd{C-@key{SPC}} in @acronym{ASCII}; when you
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
117 type @key{SPC} while holding down @key{CTRL}, what you get on most
Dave Love <fx@gnu.org>
parents:
diff changeset
118 ordinary terminals is the character @kbd{C-@@}. This key is actually
Dave Love <fx@gnu.org>
parents:
diff changeset
119 bound to @code{set-mark-command}. But unless you are unlucky enough to
Dave Love <fx@gnu.org>
parents:
diff changeset
120 have a terminal where typing @kbd{C-@key{SPC}} does not produce
Dave Love <fx@gnu.org>
parents:
diff changeset
121 @kbd{C-@@}, you might as well think of this character as
Dave Love <fx@gnu.org>
parents:
diff changeset
122 @kbd{C-@key{SPC}}. Under X, @kbd{C-@key{SPC}} is actually a distinct
Dave Love <fx@gnu.org>
parents:
diff changeset
123 character, but its binding is still @code{set-mark-command}.
Dave Love <fx@gnu.org>
parents:
diff changeset
124
Dave Love <fx@gnu.org>
parents:
diff changeset
125 @node Transient Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
126 @section Transient Mark Mode
Dave Love <fx@gnu.org>
parents:
diff changeset
127 @cindex mode, Transient Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
128 @cindex Transient Mark mode
Dave Love <fx@gnu.org>
parents:
diff changeset
129 @cindex highlighting region
Dave Love <fx@gnu.org>
parents:
diff changeset
130 @cindex region highlighting
Dave Love <fx@gnu.org>
parents:
diff changeset
131
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
132 On a terminal that supports colors, Emacs has the ability to
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
133 highlight the current region. But normally it does not. Why not?
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
134
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
135 Once you have set the mark in a buffer, there is @emph{always} a
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
136 region in that buffer. This is because every command that sets the
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
137 mark also activates it, and nothing ever deactivates it. Highlighting
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
138 the region all the time would be a nuisance. So normally Emacs
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
139 highlights the region only immediately after you have selected one
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
140 with the mouse.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
141
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
142 If you want region highlighting, you can use Transient Mark mode.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
143 This is a more rigid mode of operation in which the region always
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
144 ``lasts'' only until you use it; you explicitly must set up a region
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
145 for each command that uses one. In Transient Mark mode, most of the
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
146 time there is no region; therefore, highlighting the region when it
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
147 exists is useful and not annoying. When Transient Mark mode is
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
148 enabled, Emacs always highlights the region whenever there is a
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
149 region.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
150
Dave Love <fx@gnu.org>
parents:
diff changeset
151 @findex transient-mark-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
152 To enable Transient Mark mode, type @kbd{M-x transient-mark-mode}.
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
153 This command toggles the mode; you can use the same command to turn
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
154 the mode off again.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
155
Dave Love <fx@gnu.org>
parents:
diff changeset
156 Here are the details of Transient Mark mode:
Dave Love <fx@gnu.org>
parents:
diff changeset
157
Dave Love <fx@gnu.org>
parents:
diff changeset
158 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
159 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
160 To set the mark, type @kbd{C-@key{SPC}} (@code{set-mark-command}).
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
161 This makes the mark active and thus begins highlighting of the region.
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
162 As you move point, you will see the highlighted region grow and
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
163 shrink.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
164
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46237
diff changeset
165 @item
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
166 The mouse commands for specifying the mark also make it active. So do
Dave Love <fx@gnu.org>
parents:
diff changeset
167 keyboard commands whose purpose is to specify a region, including
Dave Love <fx@gnu.org>
parents:
diff changeset
168 @kbd{M-@@}, @kbd{C-M-@@}, @kbd{M-h}, @kbd{C-M-h}, @kbd{C-x C-p}, and
Dave Love <fx@gnu.org>
parents:
diff changeset
169 @kbd{C-x h}.
Dave Love <fx@gnu.org>
parents:
diff changeset
170
Dave Love <fx@gnu.org>
parents:
diff changeset
171 @item
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
172 You can tell that the mark is active because the region is highlighted.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
173
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
174 @item
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
175 When the mark is active, you can execute commands that operate on the
Dave Love <fx@gnu.org>
parents:
diff changeset
176 region, such as killing, indenting, or writing to a file.
Dave Love <fx@gnu.org>
parents:
diff changeset
177
Dave Love <fx@gnu.org>
parents:
diff changeset
178 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
179 Any change to the buffer, such as inserting or deleting a character,
Dave Love <fx@gnu.org>
parents:
diff changeset
180 deactivates the mark. This means any subsequent command that operates
Dave Love <fx@gnu.org>
parents:
diff changeset
181 on a region will get an error and refuse to operate. You can make the
Dave Love <fx@gnu.org>
parents:
diff changeset
182 region active again by typing @kbd{C-x C-x}.
Dave Love <fx@gnu.org>
parents:
diff changeset
183
Dave Love <fx@gnu.org>
parents:
diff changeset
184 @item
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
185 Quitting with @kbd{C-g} deactivates the mark.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
186
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
187 @item
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
188 Commands like @kbd{M->} and @kbd{C-s}, that ``leave the mark behind'' in
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
189 addition to some other primary purpose, do not activate the new mark.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
190 You can activate the new region by executing @kbd{C-x C-x}
Dave Love <fx@gnu.org>
parents:
diff changeset
191 (@code{exchange-point-and-mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
192
Dave Love <fx@gnu.org>
parents:
diff changeset
193 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
194 @kbd{C-s} when the mark is active does not alter the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
195
Dave Love <fx@gnu.org>
parents:
diff changeset
196 @item
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
197 Some commands operate on the region if a region is active. For
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
198 instance, @kbd{C-x u} in Transient Mark mode operates on the region,
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
199 when there is a region. (Outside Transient Mark mode, you must type
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
200 @kbd{C-u C-x u} if you want it to operate on the region.)
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
201 @xref{Undo}. Other commands that act this way are identified in their
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
202 own documentation.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
203 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
204
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
205 The highlighting of the region uses the @code{region} face; you can
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
206 customize the appearance of the highlighted region by changing this
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
207 face. @xref{Face Customization}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
208
Dave Love <fx@gnu.org>
parents:
diff changeset
209 @vindex highlight-nonselected-windows
Dave Love <fx@gnu.org>
parents:
diff changeset
210 When multiple windows show the same buffer, they can have different
Dave Love <fx@gnu.org>
parents:
diff changeset
211 regions, because they can have different values of point (though they
Dave Love <fx@gnu.org>
parents:
diff changeset
212 all share one common mark position). Ordinarily, only the selected
Dave Love <fx@gnu.org>
parents:
diff changeset
213 window highlights its region (@pxref{Windows}). However, if the
Dave Love <fx@gnu.org>
parents:
diff changeset
214 variable @code{highlight-nonselected-windows} is non-@code{nil}, then
Dave Love <fx@gnu.org>
parents:
diff changeset
215 each window highlights its own region (provided that Transient Mark mode
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
216 is enabled and the mark in the window's buffer is active).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
217
Dave Love <fx@gnu.org>
parents:
diff changeset
218 @vindex mark-even-if-inactive
Dave Love <fx@gnu.org>
parents:
diff changeset
219 If the variable @code{mark-even-if-inactive} is non-@code{nil} in
Dave Love <fx@gnu.org>
parents:
diff changeset
220 Transient Mark mode, then commands can use the mark and the region
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
221 even when it is inactive. Region highlighting appears and disappears
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
222 just as it normally does in Transient Mark mode, but the mark doesn't
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
223 really go away when the highlighting disappears, so you can still use
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
224 region commands.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
225
Dave Love <fx@gnu.org>
parents:
diff changeset
226 @cindex Zmacs mode
Dave Love <fx@gnu.org>
parents:
diff changeset
227 Transient Mark mode is also sometimes known as ``Zmacs mode''
Dave Love <fx@gnu.org>
parents:
diff changeset
228 because the Zmacs editor on the MIT Lisp Machine handled the mark in a
Dave Love <fx@gnu.org>
parents:
diff changeset
229 similar way.
Dave Love <fx@gnu.org>
parents:
diff changeset
230
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
231 @node Momentary Mark
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
232 @section Using Transient Mark Mode Momentarily
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
233
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
234 If you don't like Transient Mark mode in general, you might still
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
235 want to use it once in a while. To do this, type @kbd{C-@key{SPC}
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
236 C-@key{SPC}} or @kbd{C-u C-x C-x}. These commands set or activate the
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
237 mark, and enable Transient Mark mode only until the mark is
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
238 deactivated.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
239
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
240 @table @kbd
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
241 @item C-@key{SPC} C-@key{SPC}
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
242 @kindex C-@key{SPC} C-@key{SPC}
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
243 Set the mark at point (like plain @kbd{C-@key{SPC}}), and enable
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
244 Transient Mark mode just once until the mark is deactivated. (This is
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
245 not really a separate command; you are using the @kbd{C-@key{SPC}}
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
246 command twice.)
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
247
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
248 @item C-u C-x C-x
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
249 @kindex C-u C-x C-x
56691
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
250 Activate the mark without changing it; enable Transient Mark mode just
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
251 once, until the mark is deactivated. (This is the @kbd{C-x C-x}
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
252 command, @code{exchange-point-and-mark}, with a prefix argument.)
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
253 @end table
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
254
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
255 One of the secondary features of Transient Mark mode is that certain
56691
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
256 commands operate only on the region, when there is an active region.
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
257 If you don't use Transient Mark mode, the region once set never
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
258 becomes inactive, so there is no way for these commands to make such a
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
259 distinction. Enabling Transient Mark mode momentarily gives you a way
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
260 to use these commands on the region.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
261
56691
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
262 Momentary use of Transient Mark mode is also a way to highlight the
378fee0ad45e (Momentary Mark): Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 52979
diff changeset
263 region for the time being.
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
264
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
265 @node Using Region
Dave Love <fx@gnu.org>
parents:
diff changeset
266 @section Operating on the Region
Dave Love <fx@gnu.org>
parents:
diff changeset
267
Dave Love <fx@gnu.org>
parents:
diff changeset
268 @cindex operations on a marked region
Dave Love <fx@gnu.org>
parents:
diff changeset
269 Once you have a region and the mark is active, here are some of the
Dave Love <fx@gnu.org>
parents:
diff changeset
270 ways you can operate on the region:
Dave Love <fx@gnu.org>
parents:
diff changeset
271
Dave Love <fx@gnu.org>
parents:
diff changeset
272 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
273 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
274 Kill it with @kbd{C-w} (@pxref{Killing}).
Dave Love <fx@gnu.org>
parents:
diff changeset
275 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
276 Save it in a register with @kbd{C-x r s} (@pxref{Registers}).
Dave Love <fx@gnu.org>
parents:
diff changeset
277 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
278 Save it in a buffer or a file (@pxref{Accumulating Text}).
Dave Love <fx@gnu.org>
parents:
diff changeset
279 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
280 Convert case with @kbd{C-x C-l} or @kbd{C-x C-u} (@pxref{Case}).
Dave Love <fx@gnu.org>
parents:
diff changeset
281 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
282 Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} (@pxref{Indentation}).
Dave Love <fx@gnu.org>
parents:
diff changeset
283 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
284 Fill it as text with @kbd{M-x fill-region} (@pxref{Filling}).
Dave Love <fx@gnu.org>
parents:
diff changeset
285 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
286 Print hardcopy with @kbd{M-x print-region} (@pxref{Hardcopy}).
Dave Love <fx@gnu.org>
parents:
diff changeset
287 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
288 Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}).
Dave Love <fx@gnu.org>
parents:
diff changeset
289 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
290
38482
c8c4805bde95 Minor changes from Richard Stallman.
Eli Zaretskii <eliz@gnu.org>
parents: 38461
diff changeset
291 Most commands that operate on the text in the region have the word
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
292 @code{region} in their names.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
293
Dave Love <fx@gnu.org>
parents:
diff changeset
294 @node Marking Objects
Dave Love <fx@gnu.org>
parents:
diff changeset
295 @section Commands to Mark Textual Objects
Dave Love <fx@gnu.org>
parents:
diff changeset
296
Dave Love <fx@gnu.org>
parents:
diff changeset
297 @cindex marking sections of text
Dave Love <fx@gnu.org>
parents:
diff changeset
298 Here are the commands for placing point and the mark around a textual
Dave Love <fx@gnu.org>
parents:
diff changeset
299 object such as a word, list, paragraph or page.
Dave Love <fx@gnu.org>
parents:
diff changeset
300
Dave Love <fx@gnu.org>
parents:
diff changeset
301 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
302 @item M-@@
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
303 Set mark after end of next word (@code{mark-word}). This command and
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
304 the following one do not move point.
Dave Love <fx@gnu.org>
parents:
diff changeset
305 @item C-M-@@
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
306 Set mark after end of following balanced expression (@code{mark-sexp}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
307 @item M-h
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
308 Put region around current paragraph (@code{mark-paragraph}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
309 @item C-M-h
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
310 Put region around current defun (@code{mark-defun}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
311 @item C-x h
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
312 Put region around the entire buffer (@code{mark-whole-buffer}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
313 @item C-x C-p
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
314 Put region around current page (@code{mark-page}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
315 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
316
38207
e24d77a5adf1 Say "expression" instead of "sexp". Update xref, Sexps -> Expressions.
Richard M. Stallman <rms@gnu.org>
parents: 37316
diff changeset
317 @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next
e24d77a5adf1 Say "expression" instead of "sexp". Update xref, Sexps -> Expressions.
Richard M. Stallman <rms@gnu.org>
parents: 37316
diff changeset
318 word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the
e24d77a5adf1 Say "expression" instead of "sexp". Update xref, Sexps -> Expressions.
Richard M. Stallman <rms@gnu.org>
parents: 37316
diff changeset
319 next balanced expression (@pxref{Expressions}). These commands handle
43301
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
320 arguments just like @kbd{M-f} and @kbd{C-M-f}. If you repeat these
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
321 commands, the region is extended. For example, you can type either
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
322 @kbd{C-u 2 M-@@} or @kbd{M-@@ M-@@} to mark the next two words.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
323
Dave Love <fx@gnu.org>
parents:
diff changeset
324 @kindex C-x h
Dave Love <fx@gnu.org>
parents:
diff changeset
325 @findex mark-whole-buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
326 Other commands set both point and mark, to delimit an object in the
Dave Love <fx@gnu.org>
parents:
diff changeset
327 buffer. For example, @kbd{M-h} (@code{mark-paragraph}) moves point to
41748
0302528bddbc Fix wording of the last change.
Eli Zaretskii <eliz@gnu.org>
parents: 41743
diff changeset
328 the beginning of the paragraph that surrounds or follows point, and
0302528bddbc Fix wording of the last change.
Eli Zaretskii <eliz@gnu.org>
parents: 41743
diff changeset
329 puts the mark at the end of that paragraph (@pxref{Paragraphs}). It
0302528bddbc Fix wording of the last change.
Eli Zaretskii <eliz@gnu.org>
parents: 41743
diff changeset
330 prepares the region so you can indent, case-convert, or kill a whole
0302528bddbc Fix wording of the last change.
Eli Zaretskii <eliz@gnu.org>
parents: 41743
diff changeset
331 paragraph. With prefix argument, if the argument's value is positive,
41795
48c74a2caa77 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41748
diff changeset
332 @kbd{M-h} marks that many paragraphs starting with the one surrounding
48c74a2caa77 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41748
diff changeset
333 point. If the prefix argument is @minus{}@var{n}, @kbd{M-h} also
48c74a2caa77 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41748
diff changeset
334 marks @var{n} paragraphs, running back form the one surrounding point.
48c74a2caa77 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41748
diff changeset
335 In that last case, point moves forward to the end of that paragraph,
43301
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
336 and the mark goes at the start of the region. The @kbd{M-h} command
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
337 also supports the extension of the region, similar to @kbd{M-@@} and
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
338 @kbd{C-M-@@}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
339
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
340 @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38490
diff changeset
341 mark after, the current (or following) major top-level definition, or
43301
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
342 defun (@pxref{Moving by Defuns}). (Currently it only marks one defun,
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
343 but repeating it marks more defuns, like for @kbd{M-@@}.) @kbd{C-x
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
344 C-p} (@code{mark-page}) puts point before the current page, and mark
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
345 at the end (@pxref{Pages}). The mark goes after the terminating page
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
346 delimiter (to include it in the region), while point goes after the
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
347 preceding page delimiter (to exclude it). A numeric argument
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
348 specifies a later page (if positive) or an earlier page (if negative)
898b4b31410f * lisp/simple.el (mark-word): Mark more if repeated.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 41795
diff changeset
349 instead of the current page.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
350
Dave Love <fx@gnu.org>
parents:
diff changeset
351 Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire
Dave Love <fx@gnu.org>
parents:
diff changeset
352 buffer as the region, by putting point at the beginning and the mark at
Dave Love <fx@gnu.org>
parents:
diff changeset
353 the end.
Dave Love <fx@gnu.org>
parents:
diff changeset
354
Dave Love <fx@gnu.org>
parents:
diff changeset
355 In Transient Mark mode, all of these commands activate the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
356
Dave Love <fx@gnu.org>
parents:
diff changeset
357 @node Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
358 @section The Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
359
Dave Love <fx@gnu.org>
parents:
diff changeset
360 @kindex C-u C-SPC
Dave Love <fx@gnu.org>
parents:
diff changeset
361 @cindex mark ring
Dave Love <fx@gnu.org>
parents:
diff changeset
362 @kindex C-u C-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
363 Aside from delimiting the region, the mark is also useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
364 remembering a spot that you may want to go back to. To make this
Dave Love <fx@gnu.org>
parents:
diff changeset
365 feature more useful, each buffer remembers 16 previous locations of the
Dave Love <fx@gnu.org>
parents:
diff changeset
366 mark, in the @dfn{mark ring}. Commands that set the mark also push the
Dave Love <fx@gnu.org>
parents:
diff changeset
367 old mark onto this ring. To return to a marked location, use @kbd{C-u
38490
1518ad710658 Fix last changes.
Eli Zaretskii <eliz@gnu.org>
parents: 38482
diff changeset
368 C-@key{SPC}} (or @kbd{C-u C-@@}); this is the command
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
369 @code{set-mark-command} given a numeric argument. It moves point to
Dave Love <fx@gnu.org>
parents:
diff changeset
370 where the mark was, and restores the mark from the ring of former
46237
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
371 marks.
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
372
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
373 If you repeat the character @kbd{C-@key{SPC}}, after typing @kbd{C-u
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
374 C-@key{SPC}}, each repetition moves point to a previous mark position
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
375 from the ring. The mark positions you move through in this way are
46b0c6f318b5 New node Momentary Mark.
Richard M. Stallman <rms@gnu.org>
parents: 43301
diff changeset
376 not lost; they go to the end of the ring.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
377
Dave Love <fx@gnu.org>
parents:
diff changeset
378 Each buffer has its own mark ring. All editing commands use the current
Dave Love <fx@gnu.org>
parents:
diff changeset
379 buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}} always stays in
Dave Love <fx@gnu.org>
parents:
diff changeset
380 the same buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
381
Dave Love <fx@gnu.org>
parents:
diff changeset
382 Many commands that can move long distances, such as @kbd{M-<}
Dave Love <fx@gnu.org>
parents:
diff changeset
383 (@code{beginning-of-buffer}), start by setting the mark and saving the
Dave Love <fx@gnu.org>
parents:
diff changeset
384 old mark on the mark ring. This is to make it easier for you to move
Dave Love <fx@gnu.org>
parents:
diff changeset
385 back later. Searches set the mark if they move point. You can tell
37316
171ad460e884 Correct case of "Mark set" message.
Richard M. Stallman <rms@gnu.org>
parents: 36359
diff changeset
386 when a command sets the mark because it displays @samp{Mark set} in the
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
387 echo area.
Dave Love <fx@gnu.org>
parents:
diff changeset
388
Dave Love <fx@gnu.org>
parents:
diff changeset
389 If you want to move back to the same place over and over, the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
390 ring may not be convenient enough. If so, you can record the position
37316
171ad460e884 Correct case of "Mark set" message.
Richard M. Stallman <rms@gnu.org>
parents: 36359
diff changeset
391 in a register for later retrieval (@pxref{RegPos,, Saving Positions in
171ad460e884 Correct case of "Mark set" message.
Richard M. Stallman <rms@gnu.org>
parents: 36359
diff changeset
392 Registers}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
393
Dave Love <fx@gnu.org>
parents:
diff changeset
394 @vindex mark-ring-max
Dave Love <fx@gnu.org>
parents:
diff changeset
395 The variable @code{mark-ring-max} specifies the maximum number of
Dave Love <fx@gnu.org>
parents:
diff changeset
396 entries to keep in the mark ring. If that many entries exist and
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 38411
diff changeset
397 another one is pushed, the earliest one in the list is discarded. Repeating
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
398 @kbd{C-u C-@key{SPC}} cycles through the positions currently in the
Dave Love <fx@gnu.org>
parents:
diff changeset
399 ring.
Dave Love <fx@gnu.org>
parents:
diff changeset
400
Dave Love <fx@gnu.org>
parents:
diff changeset
401 @vindex mark-ring
Dave Love <fx@gnu.org>
parents:
diff changeset
402 The variable @code{mark-ring} holds the mark ring itself, as a list of
Dave Love <fx@gnu.org>
parents:
diff changeset
403 marker objects, with the most recent first. This variable is local in
Dave Love <fx@gnu.org>
parents:
diff changeset
404 every buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
405
Dave Love <fx@gnu.org>
parents:
diff changeset
406 @node Global Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
407 @section The Global Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
408 @cindex global mark ring
Dave Love <fx@gnu.org>
parents:
diff changeset
409
Dave Love <fx@gnu.org>
parents:
diff changeset
410 In addition to the ordinary mark ring that belongs to each buffer,
Dave Love <fx@gnu.org>
parents:
diff changeset
411 Emacs has a single @dfn{global mark ring}. It records a sequence of
Dave Love <fx@gnu.org>
parents:
diff changeset
412 buffers in which you have recently set the mark, so you can go back
Dave Love <fx@gnu.org>
parents:
diff changeset
413 to those buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
414
Dave Love <fx@gnu.org>
parents:
diff changeset
415 Setting the mark always makes an entry on the current buffer's mark
Dave Love <fx@gnu.org>
parents:
diff changeset
416 ring. If you have switched buffers since the previous mark setting, the
Dave Love <fx@gnu.org>
parents:
diff changeset
417 new mark position makes an entry on the global mark ring also. The
Dave Love <fx@gnu.org>
parents:
diff changeset
418 result is that the global mark ring records a sequence of buffers that
Dave Love <fx@gnu.org>
parents:
diff changeset
419 you have been in, and, for each buffer, a place where you set the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
420
Dave Love <fx@gnu.org>
parents:
diff changeset
421 @kindex C-x C-@key{SPC}
Dave Love <fx@gnu.org>
parents:
diff changeset
422 @findex pop-global-mark
Dave Love <fx@gnu.org>
parents:
diff changeset
423 The command @kbd{C-x C-@key{SPC}} (@code{pop-global-mark}) jumps to
Dave Love <fx@gnu.org>
parents:
diff changeset
424 the buffer and position of the latest entry in the global ring. It also
Dave Love <fx@gnu.org>
parents:
diff changeset
425 rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take
Dave Love <fx@gnu.org>
parents:
diff changeset
426 you to earlier and earlier buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
427
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
428 @ignore
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
429 arch-tag: f35e4d82-911b-4cfc-a3d7-3c87b2abba20
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
430 @end ignore