annotate man/mark.texi @ 36213:0a4768a84aab

(image-file-name-extensions): Add "tif".
author Miles Bader <miles@gnu.org>
date Tue, 20 Feb 2001 01:35:00 +0000
parents 7ae44c5a0404
children 33c7ddaf02c6
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.
Dave Love <fx@gnu.org>
parents:
diff changeset
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
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
Dave Love <fx@gnu.org>
parents:
diff changeset
17 You can move point or the mark to adjust the boundaries of the region.
Dave Love <fx@gnu.org>
parents:
diff changeset
18 It doesn't matter which one is set first chronologically, or which one
Dave Love <fx@gnu.org>
parents:
diff changeset
19 comes earlier in the text. Once the mark has been set, it remains where
Dave Love <fx@gnu.org>
parents:
diff changeset
20 you put it until you set it again at another place. Each Emacs buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
21 has its own mark, so that when you return to a buffer that had been
Dave Love <fx@gnu.org>
parents:
diff changeset
22 selected previously, it has the same mark it had before.
Dave Love <fx@gnu.org>
parents:
diff changeset
23
Dave Love <fx@gnu.org>
parents:
diff changeset
24 Many commands that insert text, such as @kbd{C-y} (@code{yank}) and
Dave Love <fx@gnu.org>
parents:
diff changeset
25 @kbd{M-x insert-buffer}, position point and the mark at opposite ends of
Dave Love <fx@gnu.org>
parents:
diff changeset
26 the inserted text, so that the region contains the text just inserted.
Dave Love <fx@gnu.org>
parents:
diff changeset
27
Dave Love <fx@gnu.org>
parents:
diff changeset
28 Aside from delimiting the region, the mark is also useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
29 remembering a spot that you may want to go back to. To make this
Dave Love <fx@gnu.org>
parents:
diff changeset
30 feature more useful, each buffer remembers 16 previous locations of the
Dave Love <fx@gnu.org>
parents:
diff changeset
31 mark in the @dfn{mark ring}.
Dave Love <fx@gnu.org>
parents:
diff changeset
32
Dave Love <fx@gnu.org>
parents:
diff changeset
33 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
34 * Setting Mark:: Commands to set the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
35 * Transient Mark:: How to make Emacs highlight the region--
Dave Love <fx@gnu.org>
parents:
diff changeset
36 when there is one.
Dave Love <fx@gnu.org>
parents:
diff changeset
37 * Using Region:: Summary of ways to operate on contents of the region.
Dave Love <fx@gnu.org>
parents:
diff changeset
38 * Marking Objects:: Commands to put region around textual units.
Dave Love <fx@gnu.org>
parents:
diff changeset
39 * Mark Ring:: Previous mark positions saved so you can go back there.
Dave Love <fx@gnu.org>
parents:
diff changeset
40 * Global Mark Ring:: Previous mark positions in various buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
41 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
42
Dave Love <fx@gnu.org>
parents:
diff changeset
43 @node Setting Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
44 @section Setting the Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
45
Dave Love <fx@gnu.org>
parents:
diff changeset
46 Here are some commands for setting the mark:
Dave Love <fx@gnu.org>
parents:
diff changeset
47
Dave Love <fx@gnu.org>
parents:
diff changeset
48 @c WideCommands
Dave Love <fx@gnu.org>
parents:
diff changeset
49 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
50 @item C-@key{SPC}
Dave Love <fx@gnu.org>
parents:
diff changeset
51 Set the mark where point is (@code{set-mark-command}).
Dave Love <fx@gnu.org>
parents:
diff changeset
52 @item C-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
53 The same.
Dave Love <fx@gnu.org>
parents:
diff changeset
54 @item C-x C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
55 Interchange mark and point (@code{exchange-point-and-mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
56 @item Drag-Mouse-1
Dave Love <fx@gnu.org>
parents:
diff changeset
57 Set point and the mark around the text you drag across.
Dave Love <fx@gnu.org>
parents:
diff changeset
58 @item Mouse-3
Dave Love <fx@gnu.org>
parents:
diff changeset
59 Set the mark where point is, then move point to where you click
Dave Love <fx@gnu.org>
parents:
diff changeset
60 (@code{mouse-save-then-kill}).
Dave Love <fx@gnu.org>
parents:
diff changeset
61 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
62
Dave Love <fx@gnu.org>
parents:
diff changeset
63 For example, suppose you wish to convert part of the buffer to
Dave Love <fx@gnu.org>
parents:
diff changeset
64 upper case, using the @kbd{C-x C-u} (@code{upcase-region}) command,
Dave Love <fx@gnu.org>
parents:
diff changeset
65 which operates on the text in the region. You can first go to the
Dave Love <fx@gnu.org>
parents:
diff changeset
66 beginning of the text to be capitalized, type @kbd{C-@key{SPC}} to put
Dave Love <fx@gnu.org>
parents:
diff changeset
67 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
68 can set the mark at the end of the text, move to the beginning, and then
Dave Love <fx@gnu.org>
parents:
diff changeset
69 type @kbd{C-x C-u}.
Dave Love <fx@gnu.org>
parents:
diff changeset
70
Dave Love <fx@gnu.org>
parents:
diff changeset
71 @kindex C-SPC
Dave Love <fx@gnu.org>
parents:
diff changeset
72 @findex set-mark-command
Dave Love <fx@gnu.org>
parents:
diff changeset
73 The most common way to set the mark is with the @kbd{C-@key{SPC}} command
Dave Love <fx@gnu.org>
parents:
diff changeset
74 (@code{set-mark-command}). This sets the mark where point is. Then you
Dave Love <fx@gnu.org>
parents:
diff changeset
75 can move point away, leaving the mark behind.
Dave Love <fx@gnu.org>
parents:
diff changeset
76
Dave Love <fx@gnu.org>
parents:
diff changeset
77 There are two ways to set the mark with the mouse. You can drag mouse
Dave Love <fx@gnu.org>
parents:
diff changeset
78 button one across a range of text; that puts point where you release the
Dave Love <fx@gnu.org>
parents:
diff changeset
79 mouse button, and sets the mark at the other end of that range. Or you
Dave Love <fx@gnu.org>
parents:
diff changeset
80 can click mouse button three, which sets the mark at point (like
Dave Love <fx@gnu.org>
parents:
diff changeset
81 @kbd{C-@key{SPC}}) and then moves point (like @kbd{Mouse-1}). Both of
Dave Love <fx@gnu.org>
parents:
diff changeset
82 these methods copy the region into the kill ring in addition to setting
Dave Love <fx@gnu.org>
parents:
diff changeset
83 the mark; that gives behavior consistent with other window-driven
Dave Love <fx@gnu.org>
parents:
diff changeset
84 applications, but if you don't want to modify the kill ring, you must
Dave Love <fx@gnu.org>
parents:
diff changeset
85 use keyboard commands to set the mark. @xref{Mouse Commands}.
Dave Love <fx@gnu.org>
parents:
diff changeset
86
Dave Love <fx@gnu.org>
parents:
diff changeset
87 @kindex C-x C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
88 @findex exchange-point-and-mark
Dave Love <fx@gnu.org>
parents:
diff changeset
89 Ordinary terminals have only one cursor, so there is no way for Emacs
Dave Love <fx@gnu.org>
parents:
diff changeset
90 to show you where the mark is located. You have to remember. The usual
Dave Love <fx@gnu.org>
parents:
diff changeset
91 solution to this problem is to set the mark and then use it soon, before
Dave Love <fx@gnu.org>
parents:
diff changeset
92 you forget where it is. Alternatively, you can see where the mark is
Dave Love <fx@gnu.org>
parents:
diff changeset
93 with the command @kbd{C-x C-x} (@code{exchange-point-and-mark}) which
Dave Love <fx@gnu.org>
parents:
diff changeset
94 puts the mark where point was and point where the mark was. The extent
Dave Love <fx@gnu.org>
parents:
diff changeset
95 of the region is unchanged, but the cursor and point are now at the
Dave Love <fx@gnu.org>
parents:
diff changeset
96 previous position of the mark. In Transient Mark mode, this command
Dave Love <fx@gnu.org>
parents:
diff changeset
97 reactivates the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
98
Dave Love <fx@gnu.org>
parents:
diff changeset
99 @kbd{C-x C-x} is also useful when you are satisfied with the position
Dave Love <fx@gnu.org>
parents:
diff changeset
100 of point but want to move the other end of the region (where the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
101 is); do @kbd{C-x C-x} to put point at that end of the region, and then
Dave Love <fx@gnu.org>
parents:
diff changeset
102 move it. A second use of @kbd{C-x C-x}, if necessary, puts the mark at
Dave Love <fx@gnu.org>
parents:
diff changeset
103 the new position with point back at its original position.
Dave Love <fx@gnu.org>
parents:
diff changeset
104
Dave Love <fx@gnu.org>
parents:
diff changeset
105 @kindex C-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
106 There is no such character as @kbd{C-@key{SPC}} in ASCII; when you
Dave Love <fx@gnu.org>
parents:
diff changeset
107 type @key{SPC} while holding down @key{CTRL}, what you get on most
Dave Love <fx@gnu.org>
parents:
diff changeset
108 ordinary terminals is the character @kbd{C-@@}. This key is actually
Dave Love <fx@gnu.org>
parents:
diff changeset
109 bound to @code{set-mark-command}. But unless you are unlucky enough to
Dave Love <fx@gnu.org>
parents:
diff changeset
110 have a terminal where typing @kbd{C-@key{SPC}} does not produce
Dave Love <fx@gnu.org>
parents:
diff changeset
111 @kbd{C-@@}, you might as well think of this character as
Dave Love <fx@gnu.org>
parents:
diff changeset
112 @kbd{C-@key{SPC}}. Under X, @kbd{C-@key{SPC}} is actually a distinct
Dave Love <fx@gnu.org>
parents:
diff changeset
113 character, but its binding is still @code{set-mark-command}.
Dave Love <fx@gnu.org>
parents:
diff changeset
114
Dave Love <fx@gnu.org>
parents:
diff changeset
115 @node Transient Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
116 @section Transient Mark Mode
Dave Love <fx@gnu.org>
parents:
diff changeset
117 @cindex mode, Transient Mark
Dave Love <fx@gnu.org>
parents:
diff changeset
118 @cindex Transient Mark mode
Dave Love <fx@gnu.org>
parents:
diff changeset
119 @cindex highlighting region
Dave Love <fx@gnu.org>
parents:
diff changeset
120 @cindex region highlighting
Dave Love <fx@gnu.org>
parents:
diff changeset
121
36164
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
122 On a terminal that supports colors, Emacs can highlight the current
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
123 region. But normally it does not. Why not?
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
124
36164
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
125 Highlighting the region whenever it exists would not be desirable in
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
126 Emacs, because once you have set a mark, there is @emph{always} a
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
127 region (in that buffer). And highlighting the region all the time
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
128 would be a nuisance. So normally Emacs highlights the region only
36165
7ae44c5a0404 One more small cleanup.
Richard M. Stallman <rms@gnu.org>
parents: 36164
diff changeset
129 immediately after you have selected one with the mouse.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
130
Dave Love <fx@gnu.org>
parents:
diff changeset
131 You can turn on region highlighting by enabling Transient Mark mode.
Dave Love <fx@gnu.org>
parents:
diff changeset
132 This is a more rigid mode of operation in which the region ``lasts''
Dave Love <fx@gnu.org>
parents:
diff changeset
133 only temporarily, so you must set up a region for each command that uses
Dave Love <fx@gnu.org>
parents:
diff changeset
134 one. In Transient Mark mode, most of the time there is no region;
36164
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
135 therefore, highlighting the region when it exists is useful and
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
136 not annoying.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
137
Dave Love <fx@gnu.org>
parents:
diff changeset
138 @findex transient-mark-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
139 To enable Transient Mark mode, type @kbd{M-x transient-mark-mode}.
Dave Love <fx@gnu.org>
parents:
diff changeset
140 This command toggles the mode, so you can repeat the command to turn off
Dave Love <fx@gnu.org>
parents:
diff changeset
141 the mode.
Dave Love <fx@gnu.org>
parents:
diff changeset
142
Dave Love <fx@gnu.org>
parents:
diff changeset
143 Here are the details of Transient Mark mode:
Dave Love <fx@gnu.org>
parents:
diff changeset
144
Dave Love <fx@gnu.org>
parents:
diff changeset
145 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
146 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
147 To set the mark, type @kbd{C-@key{SPC}} (@code{set-mark-command}).
Dave Love <fx@gnu.org>
parents:
diff changeset
148 This makes the mark active; as you move point, you will see the region
Dave Love <fx@gnu.org>
parents:
diff changeset
149 highlighting grow and shrink.
Dave Love <fx@gnu.org>
parents:
diff changeset
150
Dave Love <fx@gnu.org>
parents:
diff changeset
151 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
152 The mouse commands for specifying the mark also make it active. So do
Dave Love <fx@gnu.org>
parents:
diff changeset
153 keyboard commands whose purpose is to specify a region, including
Dave Love <fx@gnu.org>
parents:
diff changeset
154 @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
155 @kbd{C-x h}.
Dave Love <fx@gnu.org>
parents:
diff changeset
156
Dave Love <fx@gnu.org>
parents:
diff changeset
157 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
158 When the mark is active, you can execute commands that operate on the
Dave Love <fx@gnu.org>
parents:
diff changeset
159 region, such as killing, indenting, or writing to a file.
Dave Love <fx@gnu.org>
parents:
diff changeset
160
Dave Love <fx@gnu.org>
parents:
diff changeset
161 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
162 Any change to the buffer, such as inserting or deleting a character,
Dave Love <fx@gnu.org>
parents:
diff changeset
163 deactivates the mark. This means any subsequent command that operates
Dave Love <fx@gnu.org>
parents:
diff changeset
164 on a region will get an error and refuse to operate. You can make the
Dave Love <fx@gnu.org>
parents:
diff changeset
165 region active again by typing @kbd{C-x C-x}.
Dave Love <fx@gnu.org>
parents:
diff changeset
166
Dave Love <fx@gnu.org>
parents:
diff changeset
167 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
168 Commands like @kbd{M->} and @kbd{C-s} that ``leave the mark behind'' in
Dave Love <fx@gnu.org>
parents:
diff changeset
169 addition to some other primary purpose do not activate the new mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
170 You can activate the new region by executing @kbd{C-x C-x}
Dave Love <fx@gnu.org>
parents:
diff changeset
171 (@code{exchange-point-and-mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
172
Dave Love <fx@gnu.org>
parents:
diff changeset
173 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
174 @kbd{C-s} when the mark is active does not alter the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
175
Dave Love <fx@gnu.org>
parents:
diff changeset
176 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
177 Quitting with @kbd{C-g} deactivates the mark.
36164
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
178
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
179 @item
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
180 Some commands operate on the region whenever it is active. For
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
181 instance, @kbd{C-x u} in Transient Mark mode operates on the region
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
182 when there is a region. Outside Transient Mark mode, you must type
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
183 @kbd{C-u C-x u} if you want it to operate on the region.
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
184 @xref{Undo}. Other commands that act this way are identified
d97455a119bb Clean up intro to Transient Mark mode.
Richard M. Stallman <rms@gnu.org>
parents: 27215
diff changeset
185 in their own documentation.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
186 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
187
Dave Love <fx@gnu.org>
parents:
diff changeset
188 Highlighting of the region uses the @code{region} face; you can
Dave Love <fx@gnu.org>
parents:
diff changeset
189 customize how the region is highlighted by changing this face.
Dave Love <fx@gnu.org>
parents:
diff changeset
190 @xref{Face Customization}.
Dave Love <fx@gnu.org>
parents:
diff changeset
191
Dave Love <fx@gnu.org>
parents:
diff changeset
192 @vindex highlight-nonselected-windows
Dave Love <fx@gnu.org>
parents:
diff changeset
193 When multiple windows show the same buffer, they can have different
Dave Love <fx@gnu.org>
parents:
diff changeset
194 regions, because they can have different values of point (though they
Dave Love <fx@gnu.org>
parents:
diff changeset
195 all share one common mark position). Ordinarily, only the selected
Dave Love <fx@gnu.org>
parents:
diff changeset
196 window highlights its region (@pxref{Windows}). However, if the
Dave Love <fx@gnu.org>
parents:
diff changeset
197 variable @code{highlight-nonselected-windows} is non-@code{nil}, then
Dave Love <fx@gnu.org>
parents:
diff changeset
198 each window highlights its own region (provided that Transient Mark mode
Dave Love <fx@gnu.org>
parents:
diff changeset
199 is enabled and the window's buffer's mark is active).
Dave Love <fx@gnu.org>
parents:
diff changeset
200
Dave Love <fx@gnu.org>
parents:
diff changeset
201 When Transient Mark mode is not enabled, every command that sets the
Dave Love <fx@gnu.org>
parents:
diff changeset
202 mark also activates it, and nothing ever deactivates it.
Dave Love <fx@gnu.org>
parents:
diff changeset
203
Dave Love <fx@gnu.org>
parents:
diff changeset
204 @vindex mark-even-if-inactive
Dave Love <fx@gnu.org>
parents:
diff changeset
205 If the variable @code{mark-even-if-inactive} is non-@code{nil} in
Dave Love <fx@gnu.org>
parents:
diff changeset
206 Transient Mark mode, then commands can use the mark and the region
Dave Love <fx@gnu.org>
parents:
diff changeset
207 even when it is inactive. Region highlighting appears and disappears
Dave Love <fx@gnu.org>
parents:
diff changeset
208 just as it normally does in Transient Mark mode, but the mark doesn't
Dave Love <fx@gnu.org>
parents:
diff changeset
209 really go away when the highlighting disappears.
Dave Love <fx@gnu.org>
parents:
diff changeset
210
Dave Love <fx@gnu.org>
parents:
diff changeset
211 @cindex Zmacs mode
Dave Love <fx@gnu.org>
parents:
diff changeset
212 Transient Mark mode is also sometimes known as ``Zmacs mode''
Dave Love <fx@gnu.org>
parents:
diff changeset
213 because the Zmacs editor on the MIT Lisp Machine handled the mark in a
Dave Love <fx@gnu.org>
parents:
diff changeset
214 similar way.
Dave Love <fx@gnu.org>
parents:
diff changeset
215
Dave Love <fx@gnu.org>
parents:
diff changeset
216 @node Using Region
Dave Love <fx@gnu.org>
parents:
diff changeset
217 @section Operating on the Region
Dave Love <fx@gnu.org>
parents:
diff changeset
218
Dave Love <fx@gnu.org>
parents:
diff changeset
219 @cindex operations on a marked region
Dave Love <fx@gnu.org>
parents:
diff changeset
220 Once you have a region and the mark is active, here are some of the
Dave Love <fx@gnu.org>
parents:
diff changeset
221 ways you can operate on the region:
Dave Love <fx@gnu.org>
parents:
diff changeset
222
Dave Love <fx@gnu.org>
parents:
diff changeset
223 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
224 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
225 Kill it with @kbd{C-w} (@pxref{Killing}).
Dave Love <fx@gnu.org>
parents:
diff changeset
226 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
227 Save it in a register with @kbd{C-x r s} (@pxref{Registers}).
Dave Love <fx@gnu.org>
parents:
diff changeset
228 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
229 Save it in a buffer or a file (@pxref{Accumulating Text}).
Dave Love <fx@gnu.org>
parents:
diff changeset
230 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
231 Convert case with @kbd{C-x C-l} or @kbd{C-x C-u} (@pxref{Case}).
Dave Love <fx@gnu.org>
parents:
diff changeset
232 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
233 Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} (@pxref{Indentation}).
Dave Love <fx@gnu.org>
parents:
diff changeset
234 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
235 Fill it as text with @kbd{M-x fill-region} (@pxref{Filling}).
Dave Love <fx@gnu.org>
parents:
diff changeset
236 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
237 Print hardcopy with @kbd{M-x print-region} (@pxref{Hardcopy}).
Dave Love <fx@gnu.org>
parents:
diff changeset
238 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
239 Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}).
Dave Love <fx@gnu.org>
parents:
diff changeset
240 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
241
Dave Love <fx@gnu.org>
parents:
diff changeset
242 Most commands that operate on the text in the
Dave Love <fx@gnu.org>
parents:
diff changeset
243 region have the word @code{region} in their names.
Dave Love <fx@gnu.org>
parents:
diff changeset
244
Dave Love <fx@gnu.org>
parents:
diff changeset
245 @node Marking Objects
Dave Love <fx@gnu.org>
parents:
diff changeset
246 @section Commands to Mark Textual Objects
Dave Love <fx@gnu.org>
parents:
diff changeset
247
Dave Love <fx@gnu.org>
parents:
diff changeset
248 @cindex marking sections of text
Dave Love <fx@gnu.org>
parents:
diff changeset
249 Here are the commands for placing point and the mark around a textual
Dave Love <fx@gnu.org>
parents:
diff changeset
250 object such as a word, list, paragraph or page.
Dave Love <fx@gnu.org>
parents:
diff changeset
251
Dave Love <fx@gnu.org>
parents:
diff changeset
252 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
253 @item M-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
254 Set mark after end of next word (@code{mark-word}). This command and
Dave Love <fx@gnu.org>
parents:
diff changeset
255 the following one do not move point.
Dave Love <fx@gnu.org>
parents:
diff changeset
256 @item C-M-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
257 Set mark after end of next Lisp expression (@code{mark-sexp}).
Dave Love <fx@gnu.org>
parents:
diff changeset
258 @item M-h
Dave Love <fx@gnu.org>
parents:
diff changeset
259 Put region around current paragraph (@code{mark-paragraph}).
Dave Love <fx@gnu.org>
parents:
diff changeset
260 @item C-M-h
Dave Love <fx@gnu.org>
parents:
diff changeset
261 Put region around current Lisp defun (@code{mark-defun}).
Dave Love <fx@gnu.org>
parents:
diff changeset
262 @item C-x h
Dave Love <fx@gnu.org>
parents:
diff changeset
263 Put region around entire buffer (@code{mark-whole-buffer}).
Dave Love <fx@gnu.org>
parents:
diff changeset
264 @item C-x C-p
Dave Love <fx@gnu.org>
parents:
diff changeset
265 Put region around current page (@code{mark-page}).
Dave Love <fx@gnu.org>
parents:
diff changeset
266 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
267
Dave Love <fx@gnu.org>
parents:
diff changeset
268 @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next word,
Dave Love <fx@gnu.org>
parents:
diff changeset
269 while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the next Lisp
Dave Love <fx@gnu.org>
parents:
diff changeset
270 expression. These commands handle arguments just like @kbd{M-f} and
Dave Love <fx@gnu.org>
parents:
diff changeset
271 @kbd{C-M-f}.
Dave Love <fx@gnu.org>
parents:
diff changeset
272
Dave Love <fx@gnu.org>
parents:
diff changeset
273 @kindex C-x h
Dave Love <fx@gnu.org>
parents:
diff changeset
274 @findex mark-whole-buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
275 Other commands set both point and mark, to delimit an object in the
Dave Love <fx@gnu.org>
parents:
diff changeset
276 buffer. For example, @kbd{M-h} (@code{mark-paragraph}) moves point to
Dave Love <fx@gnu.org>
parents:
diff changeset
277 the beginning of the paragraph that surrounds or follows point, and puts
Dave Love <fx@gnu.org>
parents:
diff changeset
278 the mark at the end of that paragraph (@pxref{Paragraphs}). It prepares
Dave Love <fx@gnu.org>
parents:
diff changeset
279 the region so you can indent, case-convert, or kill a whole paragraph.
Dave Love <fx@gnu.org>
parents:
diff changeset
280
Dave Love <fx@gnu.org>
parents:
diff changeset
281 @kbd{C-M-h} (@code{mark-defun}) similarly puts point before and the
Dave Love <fx@gnu.org>
parents:
diff changeset
282 mark after the current or following defun (@pxref{Defuns}). @kbd{C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
283 C-p} (@code{mark-page}) puts point before the current page, and mark at
Dave Love <fx@gnu.org>
parents:
diff changeset
284 the end (@pxref{Pages}). The mark goes after the terminating page
Dave Love <fx@gnu.org>
parents:
diff changeset
285 delimiter (to include it), while point goes after the preceding page
Dave Love <fx@gnu.org>
parents:
diff changeset
286 delimiter (to exclude it). A numeric argument specifies a later page
Dave Love <fx@gnu.org>
parents:
diff changeset
287 (if positive) or an earlier page (if negative) instead of the current
Dave Love <fx@gnu.org>
parents:
diff changeset
288 page.
Dave Love <fx@gnu.org>
parents:
diff changeset
289
Dave Love <fx@gnu.org>
parents:
diff changeset
290 Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire
Dave Love <fx@gnu.org>
parents:
diff changeset
291 buffer as the region, by putting point at the beginning and the mark at
Dave Love <fx@gnu.org>
parents:
diff changeset
292 the end.
Dave Love <fx@gnu.org>
parents:
diff changeset
293
Dave Love <fx@gnu.org>
parents:
diff changeset
294 In Transient Mark mode, all of these commands activate the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
295
Dave Love <fx@gnu.org>
parents:
diff changeset
296 @node Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
297 @section The Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
298
Dave Love <fx@gnu.org>
parents:
diff changeset
299 @kindex C-u C-SPC
Dave Love <fx@gnu.org>
parents:
diff changeset
300 @cindex mark ring
Dave Love <fx@gnu.org>
parents:
diff changeset
301 @kindex C-u C-@@
Dave Love <fx@gnu.org>
parents:
diff changeset
302 Aside from delimiting the region, the mark is also useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
303 remembering a spot that you may want to go back to. To make this
Dave Love <fx@gnu.org>
parents:
diff changeset
304 feature more useful, each buffer remembers 16 previous locations of the
Dave Love <fx@gnu.org>
parents:
diff changeset
305 mark, in the @dfn{mark ring}. Commands that set the mark also push the
Dave Love <fx@gnu.org>
parents:
diff changeset
306 old mark onto this ring. To return to a marked location, use @kbd{C-u
Dave Love <fx@gnu.org>
parents:
diff changeset
307 C-@key{SPC}} (or @kbd{C-u C-@@}); this is the command
Dave Love <fx@gnu.org>
parents:
diff changeset
308 @code{set-mark-command} given a numeric argument. It moves point to
Dave Love <fx@gnu.org>
parents:
diff changeset
309 where the mark was, and restores the mark from the ring of former
Dave Love <fx@gnu.org>
parents:
diff changeset
310 marks. Thus, repeated use of this command moves point to all of the old
Dave Love <fx@gnu.org>
parents:
diff changeset
311 marks on the ring, one by one. The mark positions you move through in
Dave Love <fx@gnu.org>
parents:
diff changeset
312 this way are not lost; they go to the end of the ring.
Dave Love <fx@gnu.org>
parents:
diff changeset
313
Dave Love <fx@gnu.org>
parents:
diff changeset
314 Each buffer has its own mark ring. All editing commands use the current
Dave Love <fx@gnu.org>
parents:
diff changeset
315 buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}} always stays in
Dave Love <fx@gnu.org>
parents:
diff changeset
316 the same buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
317
Dave Love <fx@gnu.org>
parents:
diff changeset
318 Many commands that can move long distances, such as @kbd{M-<}
Dave Love <fx@gnu.org>
parents:
diff changeset
319 (@code{beginning-of-buffer}), start by setting the mark and saving the
Dave Love <fx@gnu.org>
parents:
diff changeset
320 old mark on the mark ring. This is to make it easier for you to move
Dave Love <fx@gnu.org>
parents:
diff changeset
321 back later. Searches set the mark if they move point. You can tell
Dave Love <fx@gnu.org>
parents:
diff changeset
322 when a command sets the mark because it displays @samp{Mark Set} in the
Dave Love <fx@gnu.org>
parents:
diff changeset
323 echo area.
Dave Love <fx@gnu.org>
parents:
diff changeset
324
Dave Love <fx@gnu.org>
parents:
diff changeset
325 If you want to move back to the same place over and over, the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
326 ring may not be convenient enough. If so, you can record the position
Dave Love <fx@gnu.org>
parents:
diff changeset
327 in a register for later retrieval (@pxref{RegPos}).
Dave Love <fx@gnu.org>
parents:
diff changeset
328
Dave Love <fx@gnu.org>
parents:
diff changeset
329 @vindex mark-ring-max
Dave Love <fx@gnu.org>
parents:
diff changeset
330 The variable @code{mark-ring-max} specifies the maximum number of
Dave Love <fx@gnu.org>
parents:
diff changeset
331 entries to keep in the mark ring. If that many entries exist and
Dave Love <fx@gnu.org>
parents:
diff changeset
332 another one is pushed, the last one in the list is discarded. Repeating
Dave Love <fx@gnu.org>
parents:
diff changeset
333 @kbd{C-u C-@key{SPC}} cycles through the positions currently in the
Dave Love <fx@gnu.org>
parents:
diff changeset
334 ring.
Dave Love <fx@gnu.org>
parents:
diff changeset
335
Dave Love <fx@gnu.org>
parents:
diff changeset
336 @vindex mark-ring
Dave Love <fx@gnu.org>
parents:
diff changeset
337 The variable @code{mark-ring} holds the mark ring itself, as a list of
Dave Love <fx@gnu.org>
parents:
diff changeset
338 marker objects, with the most recent first. This variable is local in
Dave Love <fx@gnu.org>
parents:
diff changeset
339 every buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
340
Dave Love <fx@gnu.org>
parents:
diff changeset
341 @node Global Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
342 @section The Global Mark Ring
Dave Love <fx@gnu.org>
parents:
diff changeset
343 @cindex global mark ring
Dave Love <fx@gnu.org>
parents:
diff changeset
344
Dave Love <fx@gnu.org>
parents:
diff changeset
345 In addition to the ordinary mark ring that belongs to each buffer,
Dave Love <fx@gnu.org>
parents:
diff changeset
346 Emacs has a single @dfn{global mark ring}. It records a sequence of
Dave Love <fx@gnu.org>
parents:
diff changeset
347 buffers in which you have recently set the mark, so you can go back
Dave Love <fx@gnu.org>
parents:
diff changeset
348 to those buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
349
Dave Love <fx@gnu.org>
parents:
diff changeset
350 Setting the mark always makes an entry on the current buffer's mark
Dave Love <fx@gnu.org>
parents:
diff changeset
351 ring. If you have switched buffers since the previous mark setting, the
Dave Love <fx@gnu.org>
parents:
diff changeset
352 new mark position makes an entry on the global mark ring also. The
Dave Love <fx@gnu.org>
parents:
diff changeset
353 result is that the global mark ring records a sequence of buffers that
Dave Love <fx@gnu.org>
parents:
diff changeset
354 you have been in, and, for each buffer, a place where you set the mark.
Dave Love <fx@gnu.org>
parents:
diff changeset
355
Dave Love <fx@gnu.org>
parents:
diff changeset
356 @kindex C-x C-@key{SPC}
Dave Love <fx@gnu.org>
parents:
diff changeset
357 @findex pop-global-mark
Dave Love <fx@gnu.org>
parents:
diff changeset
358 The command @kbd{C-x C-@key{SPC}} (@code{pop-global-mark}) jumps to
Dave Love <fx@gnu.org>
parents:
diff changeset
359 the buffer and position of the latest entry in the global ring. It also
Dave Love <fx@gnu.org>
parents:
diff changeset
360 rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take
Dave Love <fx@gnu.org>
parents:
diff changeset
361 you to earlier and earlier buffers.
Dave Love <fx@gnu.org>
parents:
diff changeset
362