Commit | Line | Data |
---|---|---|
6bf7aab6 | 1 | @c This is part of the Emacs manual. |
acaf905b | 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2012 |
8838673e | 3 | @c Free Software Foundation, Inc. |
6bf7aab6 DL |
4 | @c See file emacs.texi for copying conditions. |
5 | @node Mark, Killing, Help, Top | |
6 | @chapter The Mark and the Region | |
7 | @cindex mark | |
8 | @cindex setting a mark | |
9 | @cindex region | |
10 | ||
11 | Many Emacs commands operate on an arbitrary contiguous part of the | |
12 | current buffer. To specify the text for such a command to operate on, | |
13 | you set @dfn{the mark} at one end of it, and move point to the other | |
14 | end. The text between point and the mark is called @dfn{the region}. | |
0fcca8ee CY |
15 | The region always extends between point and the mark, no matter which |
16 | one comes earlier in the text; each time you move point, the region | |
17 | changes. | |
18 | ||
50b063c3 | 19 | @cindex active region |
623cec4c | 20 | Setting the mark at a position in the text also @dfn{activates} it. |
50b063c3 CY |
21 | When the mark is active, we say also that the region is active; Emacs |
22 | indicates its extent by highlighting the text within it, using the | |
23 | @code{region} face (@pxref{Face Customization}). | |
24 | ||
25 | After certain non-motion commands, including any command that | |
26 | changes the text in the buffer, Emacs automatically @dfn{deactivates} | |
27 | the mark; this turns off the highlighting. You can also explicitly | |
28 | deactivate the mark at any time, by typing @kbd{C-g} | |
29 | (@pxref{Quitting}). | |
30 | ||
31 | The above default behavior is known as Transient Mark mode. | |
32 | Disabling Transient Mark mode switches Emacs to an alternative | |
33 | behavior, in which the region is usually not highlighted. | |
34 | @xref{Disabled Transient Mark}. | |
702b10e1 | 35 | |
a8a31aae | 36 | @vindex highlight-nonselected-windows |
0665a8b0 CY |
37 | Setting the mark in one buffer has no effect on the marks in other |
38 | buffers. When you return to a buffer with an active mark, the mark is | |
39 | at the same place as before. When multiple windows show the same | |
40 | buffer, they can have different values of point, and thus different | |
41 | regions, but they all share one common mark position. @xref{Windows}. | |
42 | Ordinarily, only the selected window highlights its region; however, | |
43 | if the variable @code{highlight-nonselected-windows} is | |
44 | non-@code{nil}, each window highlights its own region. | |
6bf7aab6 DL |
45 | |
46 | @menu | |
e1a3f5b1 CY |
47 | * Setting Mark:: Commands to set the mark. |
48 | * Marking Objects:: Commands to put region around textual units. | |
49 | * Using Region:: Summary of ways to operate on contents of the region. | |
50 | * Mark Ring:: Previous mark positions saved so you can go back there. | |
51 | * Global Mark Ring:: Previous mark positions in various buffers. | |
52 | * Shift Selection:: Using shifted cursor motion keys. | |
53 | * Disabled Transient Mark:: Leaving regions unhighlighted by default. | |
6bf7aab6 DL |
54 | @end menu |
55 | ||
56 | @node Setting Mark | |
57 | @section Setting the Mark | |
58 | ||
59 | Here are some commands for setting the mark: | |
60 | ||
6bf7aab6 DL |
61 | @table @kbd |
62 | @item C-@key{SPC} | |
623cec4c | 63 | Set the mark at point, and activate it (@code{set-mark-command}). |
6bf7aab6 DL |
64 | @item C-@@ |
65 | The same. | |
66 | @item C-x C-x | |
e1a3f5b1 CY |
67 | Set the mark at point, and activate it; then move point where the mark |
68 | used to be (@code{exchange-point-and-mark}). | |
6bf7aab6 DL |
69 | @item Drag-Mouse-1 |
70 | Set point and the mark around the text you drag across. | |
71 | @item Mouse-3 | |
0665a8b0 | 72 | Set the mark at point, then move point to where you click |
6bf7aab6 | 73 | (@code{mouse-save-then-kill}). |
963578d3 CY |
74 | @item @samp{Shifted cursor motion keys} |
75 | Set the mark at point if the mark is inactive, then move point. | |
76 | @xref{Shift Selection}. | |
6bf7aab6 DL |
77 | @end table |
78 | ||
6bf7aab6 | 79 | @kindex C-SPC |
0665a8b0 | 80 | @kindex C-@@ |
6bf7aab6 | 81 | @findex set-mark-command |
a8a31aae | 82 | The most common way to set the mark is with @kbd{C-@key{SPC}} |
623cec4c CY |
83 | (@code{set-mark-command})@footnote{There is no @kbd{C-@key{SPC}} |
84 | character in @acronym{ASCII}; usually, typing @kbd{C-@key{SPC}} on a | |
85 | text terminal gives the character @kbd{C-@@}. This key is also bound | |
86 | to @code{set-mark-command}, so unless you are unlucky enough to have | |
da0bbbc4 | 87 | a text terminal that behaves differently, you might as well think of |
623cec4c CY |
88 | @kbd{C-@@} as @kbd{C-@key{SPC}}.}. This sets the mark where point is, |
89 | and activates it. You can then move point away, leaving the mark | |
90 | behind. | |
a8a31aae CY |
91 | |
92 | For example, suppose you wish to convert part of the buffer to upper | |
e1a3f5b1 CY |
93 | case. To accomplish this, go to one end of the desired text, type |
94 | @kbd{C-@key{SPC}}, and move point until the desired portion of text is | |
95 | highlighted. Now type @kbd{C-x C-u} (@code{upcase-region}). This | |
96 | converts the text in the region to upper case, and then deactivates | |
97 | the mark. | |
98 | ||
99 | Whenever the mark is active, you can deactivate it by typing | |
100 | @kbd{C-g} (@pxref{Quitting}). Most commands that operate on the | |
101 | region also automatically deactivate the mark, like @kbd{C-x C-u} in | |
102 | the above example. | |
103 | ||
104 | Instead of setting the mark in order to operate on a region, you can | |
105 | also use it to ``remember'' a position in the buffer (by typing | |
106 | @kbd{C-@key{SPC} C-@key{SPC}}), and later jump back there (by typing | |
107 | @kbd{C-u C-@key{SPC}}). @xref{Mark Ring}, for details. | |
6bf7aab6 DL |
108 | |
109 | @kindex C-x C-x | |
110 | @findex exchange-point-and-mark | |
0665a8b0 | 111 | The command @kbd{C-x C-x} (@code{exchange-point-and-mark}) exchanges |
e1a3f5b1 CY |
112 | the positions of point and the mark. @kbd{C-x C-x} is useful when you |
113 | are satisfied with the position of point but want to move the other | |
114 | end of the region (where the mark is). Using @kbd{C-x C-x} a second | |
115 | time, if necessary, puts the mark at the new position with point back | |
116 | at its original position. Normally, if the mark is inactive, this | |
117 | command first reactivates the mark wherever it was last set, to ensure | |
118 | that the region is left highlighted. However, if you call it with a | |
119 | prefix argument, it leaves the mark inactive and the region | |
120 | unhighlighted; you can use this to jump to the mark in a manner | |
121 | similar to @kbd{C-u C-@key{SPC}}. | |
0665a8b0 | 122 | |
13abd5e3 CY |
123 | You can also set the mark with the mouse. If you press the left |
124 | mouse button (@kbd{down-mouse-1}) and drag the mouse across a range of | |
e1a3f5b1 CY |
125 | text, this sets the mark where you first pressed the mouse button and |
126 | puts point where you release it. Alternatively, clicking the right | |
127 | mouse button (@kbd{mouse-3}) sets the mark at point and then moves | |
128 | point to where you clicked. @xref{Mouse Commands}, for a more | |
129 | detailed description of these mouse commands. | |
0665a8b0 CY |
130 | |
131 | @cindex shift-selection | |
132 | Finally, you can set the mark by holding down the shift key while | |
133 | typing certain cursor motion commands (such as @kbd{S-@key{right}}, | |
e1a3f5b1 CY |
134 | @kbd{S-C-f}, @kbd{S-C-n}, etc.) This is called @dfn{shift-selection}. |
135 | It sets the mark at point before moving point, but only if there is no | |
136 | active mark set via shift-selection. The mark set by mouse commands | |
137 | and by shift-selection behaves slightly differently from the usual | |
138 | mark: any subsequent unshifted cursor motion command deactivates it | |
139 | automatically. For details, @xref{Shift Selection}. | |
140 | ||
141 | Many commands that insert text, such as @kbd{C-y} (@code{yank}), set | |
142 | the mark at the other end of the inserted text, without activating it. | |
143 | This lets you easily return to that position (@pxref{Mark Ring}). You | |
144 | can tell that a command does this when it shows @samp{Mark set} in the | |
145 | echo area. | |
6bf7aab6 | 146 | |
e1a3f5b1 | 147 | @cindex primary selection |
50b063c3 CY |
148 | Under X, every time the active region changes, Emacs saves the text |
149 | in the region to the @dfn{primary selection}. This lets you insert | |
150 | that text into other X applications with @kbd{mouse-2} clicks. | |
151 | @xref{Primary Selection}. | |
6bf7aab6 DL |
152 | |
153 | @node Marking Objects | |
154 | @section Commands to Mark Textual Objects | |
155 | ||
156 | @cindex marking sections of text | |
e1a3f5b1 | 157 | Here are commands for placing point and the mark around a textual |
a8a31aae | 158 | object such as a word, list, paragraph or page: |
6bf7aab6 DL |
159 | |
160 | @table @kbd | |
161 | @item M-@@ | |
0665a8b0 CY |
162 | Set mark after end of next word (@code{mark-word}). This does not |
163 | move point. | |
6bf7aab6 | 164 | @item C-M-@@ |
0665a8b0 CY |
165 | Set mark after end of following balanced expression |
166 | (@code{mark-sexp}). This does not move point. | |
6bf7aab6 | 167 | @item M-h |
a8a31aae CY |
168 | Move point to the beginning of the current paragraph, and set mark at |
169 | the end (@code{mark-paragraph}). | |
6bf7aab6 | 170 | @item C-M-h |
a8a31aae CY |
171 | Move point to the beginning of the current defun, and set mark at the |
172 | end (@code{mark-defun}). | |
6bf7aab6 | 173 | @item C-x C-p |
a8a31aae CY |
174 | Move point to the beginning of the current page, and set mark at the |
175 | end (@code{mark-page}). | |
0665a8b0 CY |
176 | @item C-x h |
177 | Move point to the beginning of the buffer, and set mark at the end | |
178 | (@code{mark-whole-buffer}). | |
6bf7aab6 DL |
179 | @end table |
180 | ||
e1a3f5b1 | 181 | @kindex M-@@ |
0665a8b0 | 182 | @findex mark-word |
e1a3f5b1 CY |
183 | @kbd{M-@@} (@code{mark-word}) sets the mark at the end of the next |
184 | word (@pxref{Words}, for information about words). Repeated | |
185 | invocations of this command extend the region by advancing the mark | |
186 | one word at a time. As an exception, if the mark is active and | |
187 | located before point, @kbd{M-@@} moves the mark backwards from its | |
188 | current position one word at a time. | |
189 | ||
190 | This command also accepts a numeric argument @var{n}, which tells it | |
191 | to advance the mark by @var{n} words. A negative argument moves the | |
192 | mark back by @var{n} words. | |
193 | ||
194 | @kindex C-M-@@ | |
0665a8b0 | 195 | @findex mark-sexp |
e1a3f5b1 CY |
196 | Similarly, @kbd{C-M-@@} (@code{mark-sexp}) puts the mark at the end |
197 | of the next balanced expression (@pxref{Expressions}). Repeated | |
198 | invocations extend the region to subsequent expressions, while | |
199 | positive or negative numeric arguments move the mark forward or | |
200 | backward by the specified number of expressions. | |
6bf7aab6 | 201 | |
0665a8b0 CY |
202 | The other commands in the above list set both point and mark, so as |
203 | to delimit an object in the buffer. @kbd{M-h} (@code{mark-paragraph}) | |
e1a3f5b1 CY |
204 | marks paragraphs (@pxref{Paragraphs}), @kbd{C-M-h} (@code{mark-defun}) |
205 | marks top-level definitions (@pxref{Moving by Defuns}), and @kbd{C-x | |
206 | C-p} (@code{mark-page}) marks pages (@pxref{Pages}). Repeated | |
207 | invocations again play the same role, extending the region to | |
208 | consecutive objects; similarly, numeric arguments specify how many | |
209 | objects to move the mark by. | |
210 | ||
211 | @kindex C-x h | |
212 | @findex mark-whole-buffer | |
213 | @cindex select all | |
214 | @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire buffer as | |
215 | the region, by putting point at the beginning and the mark at the end. | |
6bf7aab6 | 216 | |
a8a31aae CY |
217 | @node Using Region |
218 | @section Operating on the Region | |
219 | ||
220 | @cindex operations on a marked region | |
221 | Once you have a region, here are some of the ways you can operate on | |
222 | it: | |
223 | ||
224 | @itemize @bullet | |
225 | @item | |
226 | Kill it with @kbd{C-w} (@pxref{Killing}). | |
227 | @item | |
228 | Copy it to the kill ring with @kbd{M-w} (@pxref{Yanking}). | |
229 | @item | |
230 | Convert case with @kbd{C-x C-l} or @kbd{C-x C-u} (@pxref{Case}). | |
231 | @item | |
232 | Undo changes within it using @kbd{C-u C-/} (@pxref{Undo}). | |
233 | @item | |
234 | Replace text within it using @kbd{M-%} (@pxref{Query Replace}). | |
235 | @item | |
236 | Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} (@pxref{Indentation}). | |
237 | @item | |
238 | Fill it as text with @kbd{M-x fill-region} (@pxref{Filling}). | |
239 | @item | |
e1a3f5b1 | 240 | Check the spelling of words within it with @kbd{M-$} (@pxref{Spelling}). |
a8a31aae CY |
241 | @item |
242 | Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}). | |
243 | @item | |
244 | Save it in a register with @kbd{C-x r s} (@pxref{Registers}). | |
245 | @item | |
246 | Save it in a buffer or a file (@pxref{Accumulating Text}). | |
247 | @end itemize | |
248 | ||
0fcca8ee | 249 | Some commands have a default behavior when the mark is inactive, but |
50b063c3 CY |
250 | operate on the region if the mark is active. For example, @kbd{M-$} |
251 | (@code{ispell-word}) normally checks the spelling of the word at | |
252 | point, but it checks the text in the region if the mark is active | |
253 | (@pxref{Spelling}). Normally, such commands use their default | |
0fcca8ee CY |
254 | behavior if the region is empty (i.e., if mark and point are at the |
255 | same position). If you want them to operate on the empty region, | |
256 | change the variable @code{use-empty-active-region} to @code{t}. | |
d01c3d68 | 257 | |
50b063c3 CY |
258 | @vindex delete-active-region |
259 | As described in @ref{Erasing}, the @key{DEL} | |
260 | (@code{backward-delete-char}) and @key{delete} | |
261 | (@code{delete-forward-char}) commands also act this way. If the mark | |
262 | is active, they delete the text in the region. (As an exception, if | |
263 | you supply a numeric argument @var{n}, where @var{n} is not one, these | |
264 | commands delete @var{n} characters regardless of whether the mark is | |
265 | active). If you change the variable @code{delete-active-region} to | |
266 | @code{nil}, then these commands don't act differently when the mark is | |
267 | active. If you change the value to @code{kill}, these commands | |
268 | @dfn{kill} the region instead of deleting it (@pxref{Killing}). | |
269 | ||
e1a3f5b1 | 270 | @vindex mark-even-if-inactive |
50b063c3 CY |
271 | Other commands always operate on the region, and have no default |
272 | behavior. Such commands usually have the word @code{region} in their | |
273 | names, like @kbd{C-w} (@code{kill-region}) and @code{C-x C-u} | |
e1a3f5b1 CY |
274 | (@code{upcase-region}). If the mark is inactive, they operate on the |
275 | ``inactive region''---that is, on the text between point and the | |
276 | position at which the mark was last set (@pxref{Mark Ring}). To | |
277 | disable this behavior, change the variable | |
278 | @code{mark-even-if-inactive} to @code{nil}. Then these commands will | |
279 | instead signal an error if the mark is inactive. | |
280 | ||
1e680ac9 CY |
281 | @cindex Delete Selection mode |
282 | @cindex mode, Delete Selection | |
283 | @findex delete-selection-mode | |
e1a3f5b1 CY |
284 | By default, text insertion occurs normally even if the mark is |
285 | active---for example, typing @kbd{a} inserts the character @samp{a}, | |
286 | then deactivates the mark. If you enable Delete Selection mode, a | |
287 | minor mode, then inserting text while the mark is active causes the | |
288 | text in the region to be deleted first. To toggle Delete Selection | |
289 | mode on or off, type @kbd{M-x delete-selection-mode}. | |
1e680ac9 | 290 | |
0665a8b0 CY |
291 | @node Mark Ring |
292 | @section The Mark Ring | |
293 | ||
294 | @cindex mark ring | |
e1a3f5b1 CY |
295 | Each buffer remembers previous locations of the mark, in the |
296 | @dfn{mark ring}. Commands that set the mark also push the old mark | |
297 | onto this ring. One of the uses of the mark ring is to remember spots | |
298 | that you may want to go back to. | |
0665a8b0 CY |
299 | |
300 | @table @kbd | |
301 | @item C-@key{SPC} C-@key{SPC} | |
302 | Set the mark, pushing it onto the mark ring, without activating it. | |
303 | @item C-u C-@key{SPC} | |
304 | Move point to where the mark was, and restore the mark from the ring | |
305 | of former marks. | |
306 | @end table | |
307 | ||
308 | @kindex C-SPC C-SPC | |
e1a3f5b1 CY |
309 | The command @kbd{C-@key{SPC} C-@key{SPC}} is handy when you want to |
310 | use the mark to remember a position to which you may wish to return. | |
311 | It pushes the current point onto the mark ring, without activating the | |
0665a8b0 CY |
312 | mark (which would cause Emacs to highlight the region). This is |
313 | actually two consecutive invocations of @kbd{C-@key{SPC}} | |
314 | (@code{set-mark-command}); the first @kbd{C-@key{SPC}} sets the mark, | |
315 | and the second @kbd{C-@key{SPC}} deactivates it. (When Transient Mark | |
e1a3f5b1 CY |
316 | mode is off, @kbd{C-@key{SPC} C-@key{SPC}} instead activates Transient |
317 | Mark mode temporarily; @pxref{Disabled Transient Mark}.) | |
0665a8b0 CY |
318 | |
319 | @kindex C-u C-SPC | |
320 | To return to a marked position, use @code{set-mark-command} with a | |
321 | prefix argument: @kbd{C-u C-@key{SPC}}. This moves point to where the | |
322 | mark was, and deactivates the mark if it was active. Each subsequent | |
323 | @kbd{C-u C-@key{SPC}} jumps to a prior position stored in the mark | |
324 | ring. The positions you move through in this way are not lost; they | |
325 | go to the end of the ring. | |
326 | ||
327 | @vindex set-mark-command-repeat-pop | |
328 | If you set @code{set-mark-command-repeat-pop} to non-@code{nil}, | |
329 | then immediately after you type @kbd{C-u C-@key{SPC}}, you can type | |
330 | @kbd{C-@key{SPC}} instead of @kbd{C-u C-@key{SPC}} to cycle through | |
331 | the mark ring. By default, @code{set-mark-command-repeat-pop} is | |
332 | @code{nil}. | |
333 | ||
334 | Each buffer has its own mark ring. All editing commands use the | |
335 | current buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}} | |
336 | always stays in the same buffer. | |
337 | ||
338 | @vindex mark-ring-max | |
339 | The variable @code{mark-ring-max} specifies the maximum number of | |
e1a3f5b1 CY |
340 | entries to keep in the mark ring. This defaults to 16 entries. If |
341 | that many entries exist and another one is pushed, the earliest one in | |
342 | the list is discarded. Repeating @kbd{C-u C-@key{SPC}} cycles through | |
343 | the positions currently in the ring. | |
0665a8b0 CY |
344 | |
345 | If you want to move back to the same place over and over, the mark | |
346 | ring may not be convenient enough. If so, you can record the position | |
a30ed87b LMI |
347 | in a register for later retrieval (@pxref{Position Registers,, Saving |
348 | Positions in Registers}). | |
0665a8b0 CY |
349 | |
350 | @node Global Mark Ring | |
351 | @section The Global Mark Ring | |
352 | @cindex global mark ring | |
353 | ||
c7588364 | 354 | @vindex global-mark-ring-max |
0665a8b0 CY |
355 | In addition to the ordinary mark ring that belongs to each buffer, |
356 | Emacs has a single @dfn{global mark ring}. Each time you set a mark, | |
0cbaa1d5 CY |
357 | this is recorded in the global mark ring in addition to the current |
358 | buffer's own mark ring, if you have switched buffers since the | |
359 | previous mark setting. Hence, the global mark ring records a sequence | |
360 | of buffers that you have been in, and, for each buffer, a place where | |
361 | you set the mark. The length of the global mark ring is controlled by | |
362 | @code{global-mark-ring-max}, and is 16 by default. | |
0665a8b0 CY |
363 | |
364 | @kindex C-x C-@key{SPC} | |
365 | @findex pop-global-mark | |
366 | The command @kbd{C-x C-@key{SPC}} (@code{pop-global-mark}) jumps to | |
367 | the buffer and position of the latest entry in the global ring. It also | |
368 | rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take | |
369 | you to earlier buffers and mark positions. | |
370 | ||
13abd5e3 CY |
371 | @node Shift Selection |
372 | @section Shift Selection | |
0665a8b0 CY |
373 | @cindex shift-selection |
374 | ||
375 | If you hold down the shift key while typing a cursor motion command, | |
376 | this sets the mark before moving point, so that the region extends | |
e1a3f5b1 CY |
377 | from the original position of point to its new position. This feature |
378 | is referred to as @dfn{shift-selection}. It is similar to the way | |
379 | text is selected in other editors. | |
0665a8b0 CY |
380 | |
381 | The mark set via shift-selection behaves a little differently from | |
382 | what we have described above. Firstly, in addition to the usual ways | |
383 | of deactivating the mark (such as changing the buffer text or typing | |
384 | @kbd{C-g}), the mark is deactivated by any @emph{unshifted} cursor | |
385 | motion command. Secondly, any subsequent @emph{shifted} cursor motion | |
386 | command avoids setting the mark anew. Therefore, a series of shifted | |
e1a3f5b1 | 387 | cursor motion commands will continuously adjust the region. |
0665a8b0 CY |
388 | |
389 | Shift-selection only works if the shifted cursor motion key is not | |
390 | already bound to a separate command (@pxref{Customization}). For | |
391 | example, if you bind @kbd{S-C-f} to another command, typing | |
392 | @kbd{S-C-f} runs that command instead of performing a shift-selected | |
393 | version of @kbd{C-f} (@code{forward-char}). | |
394 | ||
395 | A mark set via mouse commands behaves the same as a mark set via | |
396 | shift-selection (@pxref{Setting Mark}). For example, if you specify a | |
397 | region by dragging the mouse, you can continue to extend the region | |
398 | using shifted cursor motion commands. In either case, any unshifted | |
399 | cursor motion command deactivates the mark. | |
400 | ||
401 | To turn off shift-selection, set @code{shift-select-mode} to | |
e1a3f5b1 | 402 | @code{nil}. Doing so does not disable setting the mark via mouse |
0665a8b0 CY |
403 | commands. |
404 | ||
e1a3f5b1 CY |
405 | @node Disabled Transient Mark |
406 | @section Disabling Transient Mark Mode | |
a8a31aae CY |
407 | @cindex mode, Transient Mark |
408 | @cindex Transient Mark mode | |
409 | @cindex highlighting region | |
410 | @cindex region highlighting | |
411 | @cindex Zmacs mode | |
0fcca8ee | 412 | @findex transient-mark-mode |
a8a31aae | 413 | |
e1a3f5b1 CY |
414 | The default behavior of the mark and region, in which setting the |
415 | mark activates it and highlights the region, is called Transient Mark | |
416 | mode. This is a minor mode that is enabled by default. It can be | |
417 | toggled with @kbd{M-x transient-mark-mode}, or with the @samp{Active | |
418 | Region Highlighting} menu item in the @samp{Options} menu. Turning it | |
419 | off switches Emacs to an alternative mode of operation: | |
a8a31aae CY |
420 | |
421 | @itemize @bullet | |
422 | @item | |
e1a3f5b1 CY |
423 | Setting the mark, with commands like @kbd{C-@key{SPC}} or @kbd{C-x |
424 | C-x}, does not highlight the region. Therefore, you can't tell by | |
425 | looking where the mark is located; you have to remember. | |
a8a31aae | 426 | |
e1a3f5b1 CY |
427 | The usual solution to this problem is to set the mark and then use it |
428 | soon, before you forget where it is. You can also check where the | |
429 | mark is by using @kbd{C-x C-x}, which exchanges the positions of the | |
430 | point and the mark (@pxref{Setting Mark}). | |
a8a31aae CY |
431 | |
432 | @item | |
433 | Many commands that move point long distances, like @kbd{M-<} and | |
434 | @kbd{C-s}, first set the mark where point was. | |
435 | ||
436 | @item | |
e59c4233 CY |
437 | Some commands, which ordinarily act on the region when the mark is |
438 | active, no longer do so. For example, normally @kbd{M-%} | |
439 | (@code{query-replace}) performs replacements within the region, if the | |
440 | mark is active. When Transient Mark mode is off, it always operates | |
441 | from point to the end of the buffer. Commands that act this way are | |
442 | identified in their own documentation. | |
a8a31aae CY |
443 | @end itemize |
444 | ||
445 | While Transient Mark mode is off, you can activate it temporarily | |
446 | using @kbd{C-@key{SPC} C-@key{SPC}} or @kbd{C-u C-x C-x}. | |
447 | ||
448 | @table @kbd | |
449 | @item C-@key{SPC} C-@key{SPC} | |
450 | @kindex C-@key{SPC} C-@key{SPC} | |
451 | Set the mark at point (like plain @kbd{C-@key{SPC}}) and enable | |
452 | Transient Mark mode just once, until the mark is deactivated. (This | |
453 | is not really a separate command; you are using the @kbd{C-@key{SPC}} | |
454 | command twice.) | |
455 | ||
456 | @item C-u C-x C-x | |
457 | @kindex C-u C-x C-x | |
e59c4233 CY |
458 | Activate the mark and enable Transient Mark mode temporarily, until |
459 | the mark is next deactivated. (This is the @kbd{C-x C-x} command, | |
460 | @code{exchange-point-and-mark}, with a prefix argument.) | |
a8a31aae CY |
461 | @end table |
462 | ||
463 | These commands set or activate the mark, and enable Transient Mark | |
464 | mode only until the mark is deactivated. One reason you may want to | |
465 | use them is that some commands operate on the entire buffer instead of | |
466 | the region when Transient Mark mode is off. Enabling Transient Mark | |
467 | mode momentarily gives you a way to use these commands on the region. | |
e1a3f5b1 CY |
468 | |
469 | When you specify a region with the mouse (@pxref{Setting Mark}), or | |
470 | with shift-selection (@pxref{Shift Selection}), this likewise | |
471 | activates Transient Mark mode temporarily and highlights the region. |