diff options
| author | Chong Yidong | 2008-03-28 19:02:43 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-03-28 19:02:43 +0000 |
| commit | a8a31aaeea47f6872900df5bba1c832a95fe3f1c (patch) | |
| tree | cbbadc27ae8cda6153eb821f2f28a143222086af | |
| parent | 7186a830349cf13b0b695d5bd84fb2b6db464ba8 (diff) | |
| download | emacs-a8a31aaeea47f6872900df5bba1c832a95fe3f1c.tar.gz emacs-a8a31aaeea47f6872900df5bba1c832a95fe3f1c.zip | |
(Mark): Rearrange nodes.
(Persistent Mark): Rename from Transient Mark.
(Mark, Setting Mark, Marking Objects, Persistent Mark, Mark Ring):
Describe Transient Mark mode as the default.
| -rw-r--r-- | doc/emacs/mark.texi | 552 |
1 files changed, 251 insertions, 301 deletions
diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi index 2c8ee05201b..cf131d32b2e 100644 --- a/doc/emacs/mark.texi +++ b/doc/emacs/mark.texi | |||
| @@ -12,39 +12,40 @@ | |||
| 12 | current buffer. To specify the text for such a command to operate on, | 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 | 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}. | 14 | end. The text between point and the mark is called @dfn{the region}. |
| 15 | Emacs highlights the region whenever there is one, if you enable | ||
| 16 | Transient Mark mode (@pxref{Transient Mark}). | ||
| 17 | |||
| 18 | Certain Emacs commands set the mark; other editing commands do not | ||
| 19 | affect it, so the mark remains where you set it last. Each Emacs | ||
| 20 | buffer has its own mark, and setting the mark in one buffer has no | ||
| 21 | effect on other buffers' marks. When you return to a buffer that was | ||
| 22 | current earlier, its mark is at the same place as before. | ||
| 23 | |||
| 24 | The ends of the region are always point and the mark. It doesn't | ||
| 25 | matter which of them was put in its current place first, or which one | ||
| 26 | comes earlier in the text---the region starts from point or the mark | ||
| 27 | (whichever comes first), and ends at point or the mark (whichever | ||
| 28 | comes last). Every time you move point, or set the mark in a new | ||
| 29 | place, the region changes. | ||
| 30 | |||
| 31 | Many commands that insert text, such as @kbd{C-y} (@code{yank}) and | ||
| 32 | @kbd{M-x insert-buffer}, position point and the mark at opposite ends | ||
| 33 | of the inserted text, so that the region consists of the text just | ||
| 34 | inserted. | ||
| 35 | 15 | ||
| 36 | Aside from delimiting the region, the mark is also useful for | 16 | The region always extends between point and the mark, no matter |
| 37 | remembering a spot that you may want to go back to. To make this | 17 | which one comes earlier in the text---the region starts from point or |
| 38 | feature more useful, each buffer remembers 16 previous locations of the | 18 | the mark (whichever comes first), and ends at point or the mark |
| 39 | mark in the @dfn{mark ring}. | 19 | (whichever comes last). Every time you move point, the region |
| 20 | changes. When a region is active, Emacs highlights it using the | ||
| 21 | @code{region} face. You can customize the appearance of the | ||
| 22 | highlighting by changing this face (@pxref{Face Customization}). | ||
| 23 | |||
| 24 | The region persists only until you use it. The mark is | ||
| 25 | automatically @dfn{deactivated} after certain non-motion commands, | ||
| 26 | including any command that changes the text in the buffer. You can | ||
| 27 | also explicitly deactivate the mark at any time, by typing @kbd{C-g} | ||
| 28 | (@pxref{Quitting}). | ||
| 29 | |||
| 30 | @vindex highlight-nonselected-windows | ||
| 31 | Each Emacs buffer has its own mark, and setting the mark in one | ||
| 32 | buffer has no effect on other buffers' marks. When you return to a | ||
| 33 | buffer with an active mark, the mark is at the same place as before. | ||
| 34 | When multiple windows show the same buffer, they can have different | ||
| 35 | values of point, and thus different regions (though they all share one | ||
| 36 | common mark position). @xref{Windows}. Ordinarily, only the selected | ||
| 37 | window highlights its region, if a region exists; however, if the | ||
| 38 | variable @code{highlight-nonselected-windows} is non-@code{nil}, each | ||
| 39 | window highlights its own region. | ||
| 40 | |||
| 41 | If Delete Selection mode is enabled, some commands delete the region | ||
| 42 | when used while the mark is active. @xref{Mouse Commands}. | ||
| 40 | 43 | ||
| 41 | @menu | 44 | @menu |
| 42 | * Setting Mark:: Commands to set the mark. | 45 | * Setting Mark:: Commands to set the mark. |
| 43 | * Transient Mark:: How to make Emacs highlight the region-- | ||
| 44 | when there is one. | ||
| 45 | * Momentary Mark:: Enabling Transient Mark mode momentarily. | ||
| 46 | * Using Region:: Summary of ways to operate on contents of the region. | ||
| 47 | * Marking Objects:: Commands to put region around textual units. | 46 | * Marking Objects:: Commands to put region around textual units. |
| 47 | * Using Region:: Summary of ways to operate on contents of the region. | ||
| 48 | * Persistent Mark:: Keeping the mark active all the time. | ||
| 48 | * Mark Ring:: Previous mark positions saved so you can go back there. | 49 | * Mark Ring:: Previous mark positions saved so you can go back there. |
| 49 | * Global Mark Ring:: Previous mark positions in various buffers. | 50 | * Global Mark Ring:: Previous mark positions in various buffers. |
| 50 | @end menu | 51 | @end menu |
| @@ -60,7 +61,8 @@ Set the mark where point is (@code{set-mark-command}). | |||
| 60 | @item C-@@ | 61 | @item C-@@ |
| 61 | The same. | 62 | The same. |
| 62 | @item C-x C-x | 63 | @item C-x C-x |
| 63 | Interchange mark and point (@code{exchange-point-and-mark}). | 64 | Set the mark where point was, and move point where the mark was |
| 65 | (@code{exchange-point-and-mark}). | ||
| 64 | @item Drag-Mouse-1 | 66 | @item Drag-Mouse-1 |
| 65 | Set point and the mark around the text you drag across. | 67 | Set point and the mark around the text you drag across. |
| 66 | @item Mouse-3 | 68 | @item Mouse-3 |
| @@ -68,252 +70,65 @@ Set the mark where point is, then move point to where you click | |||
| 68 | (@code{mouse-save-then-kill}). | 70 | (@code{mouse-save-then-kill}). |
| 69 | @end table | 71 | @end table |
| 70 | 72 | ||
| 71 | For example, suppose you wish to convert part of the buffer to | ||
| 72 | upper case, using the @kbd{C-x C-u} (@code{upcase-region}) command, | ||
| 73 | which operates on the text in the region. You can first go to the | ||
| 74 | beginning of the text to be capitalized, type @kbd{C-@key{SPC}} to put | ||
| 75 | the mark there, move to the end, and then type @kbd{C-x C-u}. Or, you | ||
| 76 | can set the mark at the end of the text, move to the beginning, and then | ||
| 77 | type @kbd{C-x C-u}. | ||
| 78 | |||
| 79 | @kindex C-SPC | 73 | @kindex C-SPC |
| 80 | @findex set-mark-command | 74 | @findex set-mark-command |
| 81 | The most common way to set the mark is with the @kbd{C-@key{SPC}} command | 75 | The most common way to set the mark is with @kbd{C-@key{SPC}} |
| 82 | (@code{set-mark-command}). This sets the mark where point is. Then you | 76 | (@code{set-mark-command}). This sets the mark where point is. You |
| 83 | can move point away, leaving the mark behind. | 77 | can then move point away, leaving the mark behind. |
| 84 | 78 | ||
| 85 | There are two ways to set the mark with the mouse. You can drag mouse | 79 | For example, suppose you wish to convert part of the buffer to upper |
| 86 | button one across a range of text; that puts point where you release the | 80 | case. To accomplish this, first go to the beginning of the text to be |
| 87 | mouse button, and sets the mark at the other end of that range. Or you | 81 | capitalized, type @kbd{C-@key{SPC}}, and move point until the desired |
| 88 | can click mouse button three, which sets the mark at point (like | 82 | portion of text is highlighted. You can now type @kbd{C-x C-u} |
| 89 | @kbd{C-@key{SPC}}) and then moves point where you clicked (like | 83 | (@code{upcase-region}), which converts the text in the region to upper |
| 90 | @kbd{Mouse-1}). | 84 | case. This also automatically deactivates the mark. (Alternatively, |
| 91 | 85 | you could set the mark at the end, move to the beginning, and do | |
| 92 | Using the mouse to mark a region copies the region into the kill | 86 | @kbd{C-x C-u}.) |
| 93 | ring in addition to setting the mark; that gives behavior consistent | ||
| 94 | with other window-driven applications. If you don't want to modify | ||
| 95 | the kill ring, you must use keyboard commands to set the mark. | ||
| 96 | @xref{Mouse Commands}. | ||
| 97 | 87 | ||
| 98 | @kindex C-x C-x | 88 | @kindex C-x C-x |
| 99 | @findex exchange-point-and-mark | 89 | @findex exchange-point-and-mark |
| 100 | When Emacs was developed, terminals had only one cursor, so Emacs | 90 | The command @kbd{C-x C-x} (@code{exchange-point-and-mark}) puts the |
| 101 | does not show where the mark is located--you have to remember. If you | 91 | mark where point was and moves point where the mark was, keeping the |
| 102 | enable Transient Mark mode (see below), then the region is highlighted | 92 | region unchanged. If no mark is active, Emacs reactivates the mark at |
| 103 | when it is active; you can tell mark is at the other end of the | 93 | the position where it was last set. @kbd{C-x C-x} is useful when you |
| 104 | highlighted region. But this only applies when the mark is active. | 94 | are satisfied with the position of point but want to move the other |
| 105 | 95 | end of the region (where the mark is); do @kbd{C-x C-x} to put point | |
| 106 | The usual solution to this problem is to set the mark and then use | 96 | at that end of the region, and then move it. Using @kbd{C-x C-x} a |
| 107 | it soon, before you forget where it is. Alternatively, you can see | 97 | second time, if necessary, puts the mark at the new position with |
| 108 | where the mark is with the command @kbd{C-x C-x} | 98 | point back at its original position. |
| 109 | (@code{exchange-point-and-mark}) which puts the mark where point was | 99 | |
| 110 | and point where the mark was. The extent of the region is unchanged, | 100 | You can also set the mark with the mouse. In fact, there are two |
| 111 | but the cursor and point are now at the previous position of the mark. | 101 | ways to do this. You can press the left mouse button |
| 112 | In Transient Mark mode, this command also reactivates the mark. | 102 | (@kbd{down-mouse-1}) and drag the mouse across a range of text while |
| 113 | 103 | holding down the button; this sets the mark where you first pressed | |
| 114 | @kbd{C-x C-x} is also useful when you are satisfied with the position | 104 | the mouse button, and point where you release it. Alternatively, you |
| 115 | of point but want to move the other end of the region (where the mark | 105 | can click the right mouse button (@kbd{mouse-3}), which sets the mark |
| 116 | is); do @kbd{C-x C-x} to put point at that end of the region, and then | 106 | at point and then moves point to where you clicked. |
| 117 | move it. Using @kbd{C-x C-x} a second time, if necessary, puts the mark at | 107 | |
| 118 | the new position with point back at its original position. | 108 | Using the mouse to mark a region also copies the region into the |
| 119 | 109 | kill ring (@pxref{Kill Ring}). If you don't want to modify the kill | |
| 120 | For more facilities that allow you to go to previously set marks, see | 110 | ring, you must use keyboard commands to set the mark. @xref{Mouse |
| 121 | @ref{Mark Ring}. | 111 | Commands}. |
| 122 | 112 | ||
| 123 | @kindex C-@@ | 113 | @kindex C-@@ |
| 124 | There is no such character as @kbd{C-@key{SPC}} in @acronym{ASCII}; | 114 | There is no such character as @kbd{C-@key{SPC}} in @acronym{ASCII}; |
| 125 | when you type @key{SPC} while holding down @key{CTRL} on a text | 115 | when you type @key{SPC} while holding down @key{CTRL} on a text |
| 126 | terminal, what you get is the character @kbd{C-@@}. This key is also | 116 | terminal, what you get is the character @kbd{C-@@}. This key is also |
| 127 | bound to @code{set-mark-command}--so unless you are unlucky enough to | 117 | bound to @code{set-mark-command}---so unless you are unlucky enough to |
| 128 | have a text terminal where typing @kbd{C-@key{SPC}} does not produce | 118 | have a text terminal where typing @kbd{C-@key{SPC}} does not produce |
| 129 | @kbd{C-@@}, you might as well think of this character as | 119 | @kbd{C-@@}, you might as well think of this character as |
| 130 | @kbd{C-@key{SPC}}. | 120 | @kbd{C-@key{SPC}}. |
| 131 | 121 | ||
| 132 | @node Transient Mark | 122 | Whenever the mark is active, you can deactivate it by typing |
| 133 | @section Transient Mark Mode | 123 | @kbd{C-g} (@pxref{Quitting}). The mark is also automatically |
| 134 | @cindex mode, Transient Mark | 124 | deactivated after certain non-motion commands. |
| 135 | @cindex Transient Mark mode | ||
| 136 | @cindex highlighting region | ||
| 137 | @cindex region highlighting | ||
| 138 | |||
| 139 | On a terminal that supports colors, Emacs has the ability to | ||
| 140 | highlight the current region. But normally it does not. Why not? | ||
| 141 | |||
| 142 | In the normal mode of use, every command that sets the mark also | ||
| 143 | activates it, and nothing ever deactivates it. Thus, once you have | ||
| 144 | set the mark in a buffer, there is @emph{always} a region in that | ||
| 145 | buffer. Highlighting the region all the time would be a nuisance. So | ||
| 146 | normally Emacs highlights the region only immediately after you have | ||
| 147 | selected one with the mouse. | ||
| 148 | |||
| 149 | If you want region highlighting, you can use Transient Mark mode. | ||
| 150 | This is a more rigid mode of operation in which the region ``lasts'' | ||
| 151 | only until you use it; operating on the region text deactivates the | ||
| 152 | mark, so there is no region any more. Therefore, you must explicitly | ||
| 153 | set up a region for each command that uses one. | ||
| 154 | |||
| 155 | When Transient Mark mode is enabled, Emacs highlights the region, | ||
| 156 | whenever there is a region. In Transient Mark mode, most of the time | ||
| 157 | there is no region; therefore, highlighting the region when it exists | ||
| 158 | is useful and not annoying. | ||
| 159 | |||
| 160 | @findex transient-mark-mode | ||
| 161 | To enable Transient Mark mode, type @kbd{M-x transient-mark-mode}. | ||
| 162 | This command toggles the mode; you can use the same command to turn | ||
| 163 | the mode off again. | ||
| 164 | |||
| 165 | Here are the details of Transient Mark mode: | ||
| 166 | |||
| 167 | @itemize @bullet | ||
| 168 | @item | ||
| 169 | To set the mark, type @kbd{C-@key{SPC}} (@code{set-mark-command}). | ||
| 170 | This makes the mark active and thus begins highlighting of the region. | ||
| 171 | As you move point, you will see the highlighted region grow and | ||
| 172 | shrink. | ||
| 173 | |||
| 174 | @item | ||
| 175 | The mouse commands for specifying the mark also make it active. So do | ||
| 176 | keyboard commands whose purpose is to specify a region, including | ||
| 177 | @kbd{M-@@}, @kbd{C-M-@@}, @kbd{M-h}, @kbd{C-M-h}, @kbd{C-x C-p}, and | ||
| 178 | @kbd{C-x h}. | ||
| 179 | |||
| 180 | @item | ||
| 181 | You can tell that the mark is active because the region is highlighted. | ||
| 182 | |||
| 183 | @item | ||
| 184 | When the mark is active, you can execute commands that operate on the | ||
| 185 | region, such as killing, indenting, or writing to a file. | ||
| 186 | |||
| 187 | @item | ||
| 188 | Any change to the buffer, such as inserting or deleting a character, | ||
| 189 | deactivates the mark. This means any subsequent command that operates | ||
| 190 | on a region will get an error and refuse to operate. You can make the | ||
| 191 | region active again by typing @kbd{C-x C-x}. | ||
| 192 | |||
| 193 | @item | ||
| 194 | If Delete Selection mode is also enabled, some commands delete the | ||
| 195 | region when used while the mark is active. @xref{Mouse Commands}. | ||
| 196 | |||
| 197 | @item | ||
| 198 | Quitting with @kbd{C-g} deactivates the mark. | ||
| 199 | |||
| 200 | @item | ||
| 201 | Commands like @kbd{M->} and @kbd{C-s}, that ``leave the mark behind'' in | ||
| 202 | addition to some other primary purpose, do not activate the new mark. | ||
| 203 | You can activate the new region by executing @kbd{C-x C-x} | ||
| 204 | (@code{exchange-point-and-mark}). | ||
| 205 | |||
| 206 | @item | ||
| 207 | Commands that normally set the mark before moving long distances (like | ||
| 208 | @kbd{M-<} and @kbd{C-s}) do not alter the mark in Transient Mark mode | ||
| 209 | when the mark is active. | ||
| 210 | |||
| 211 | @item | ||
| 212 | Some commands operate on the region if a region is active. For | ||
| 213 | instance, @kbd{C-x u} in Transient Mark mode operates on the region, | ||
| 214 | when there is a region. (Outside Transient Mark mode, you must type | ||
| 215 | @kbd{C-u C-x u} if you want it to operate on the region.) | ||
| 216 | @xref{Undo}. Other commands that act this way are identified in their | ||
| 217 | own documentation. | ||
| 218 | @end itemize | ||
| 219 | |||
| 220 | The highlighting of the region uses the @code{region} face; you can | ||
| 221 | customize the appearance of the highlighted region by changing this | ||
| 222 | face. @xref{Face Customization}. | ||
| 223 | |||
| 224 | @vindex highlight-nonselected-windows | ||
| 225 | When multiple windows show the same buffer, they can have different | ||
| 226 | regions, because they can have different values of point (though they | ||
| 227 | all share one common mark position). Ordinarily, only the selected | ||
| 228 | window highlights its region (@pxref{Windows}). However, if the | ||
| 229 | variable @code{highlight-nonselected-windows} is non-@code{nil}, then | ||
| 230 | each window highlights its own region (provided that Transient Mark mode | ||
| 231 | is enabled and the mark in the window's buffer is active). | ||
| 232 | |||
| 233 | @vindex mark-even-if-inactive | ||
| 234 | If the variable @code{mark-even-if-inactive} is non-@code{nil} in | ||
| 235 | Transient Mark mode, then commands can use the mark and the region | ||
| 236 | even when it is inactive. Region highlighting appears and disappears | ||
| 237 | just as it normally does in Transient Mark mode, but the mark doesn't | ||
| 238 | really go away when the highlighting disappears, so you can still use | ||
| 239 | region commands. | ||
| 240 | |||
| 241 | @cindex Zmacs mode | ||
| 242 | Transient Mark mode is also sometimes known as ``Zmacs mode'' | ||
| 243 | because the Zmacs editor on the MIT Lisp Machine handled the mark in a | ||
| 244 | similar way. | ||
| 245 | |||
| 246 | @node Momentary Mark | ||
| 247 | @section Using Transient Mark Mode Momentarily | ||
| 248 | |||
| 249 | If you don't like Transient Mark mode in general, you might still | ||
| 250 | want to use it once in a while. To do this, type @kbd{C-@key{SPC} | ||
| 251 | C-@key{SPC}} or @kbd{C-u C-x C-x}. These commands set or activate the | ||
| 252 | mark, and enable Transient Mark mode only until the mark is | ||
| 253 | deactivated. | ||
| 254 | |||
| 255 | @table @kbd | ||
| 256 | @item C-@key{SPC} C-@key{SPC} | ||
| 257 | @kindex C-@key{SPC} C-@key{SPC} | ||
| 258 | Set the mark at point (like plain @kbd{C-@key{SPC}}), and enable | ||
| 259 | Transient Mark mode just once until the mark is deactivated. (This is | ||
| 260 | not really a separate command; you are using the @kbd{C-@key{SPC}} | ||
| 261 | command twice.) | ||
| 262 | |||
| 263 | @item C-u C-x C-x | ||
| 264 | @kindex C-u C-x C-x | ||
| 265 | Activate the mark without changing it; enable Transient Mark mode just | ||
| 266 | once, until the mark is deactivated. (This is the @kbd{C-x C-x} | ||
| 267 | command, @code{exchange-point-and-mark}, with a prefix argument.) | ||
| 268 | @end table | ||
| 269 | |||
| 270 | One of the secondary features of Transient Mark mode is that certain | ||
| 271 | commands operate only on the region, when there is an active region. | ||
| 272 | If you don't use Transient Mark mode, the region once set never | ||
| 273 | becomes inactive, so there is no way for these commands to make such a | ||
| 274 | distinction. Enabling Transient Mark mode momentarily gives you a way | ||
| 275 | to use these commands on the region. | ||
| 276 | |||
| 277 | Momentary use of Transient Mark mode is also a way to highlight the | ||
| 278 | region for the time being. | ||
| 279 | |||
| 280 | @node Using Region | ||
| 281 | @section Operating on the Region | ||
| 282 | |||
| 283 | @cindex operations on a marked region | ||
| 284 | Once you have a region and the mark is active, here are some of the | ||
| 285 | ways you can operate on the region: | ||
| 286 | |||
| 287 | @itemize @bullet | ||
| 288 | @item | ||
| 289 | Kill it with @kbd{C-w} (@pxref{Killing}). | ||
| 290 | @item | ||
| 291 | Save it in a register with @kbd{C-x r s} (@pxref{Registers}). | ||
| 292 | @item | ||
| 293 | Save it in a buffer or a file (@pxref{Accumulating Text}). | ||
| 294 | @item | ||
| 295 | Convert case with @kbd{C-x C-l} or @kbd{C-x C-u} (@pxref{Case}). | ||
| 296 | @item | ||
| 297 | Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} (@pxref{Indentation}). | ||
| 298 | @item | ||
| 299 | Fill it as text with @kbd{M-x fill-region} (@pxref{Filling}). | ||
| 300 | @item | ||
| 301 | Print hardcopy with @kbd{M-x print-region} (@pxref{Printing}). | ||
| 302 | @item | ||
| 303 | Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}). | ||
| 304 | @item | ||
| 305 | Undo changes within it using @kbd{C-u C-x u} (@pxref{Undo}). | ||
| 306 | @end itemize | ||
| 307 | |||
| 308 | Most commands that operate on the text in the region have the word | ||
| 309 | @code{region} in their names. | ||
| 310 | 125 | ||
| 311 | @node Marking Objects | 126 | @node Marking Objects |
| 312 | @section Commands to Mark Textual Objects | 127 | @section Commands to Mark Textual Objects |
| 313 | 128 | ||
| 314 | @cindex marking sections of text | 129 | @cindex marking sections of text |
| 315 | Here are the commands for placing point and the mark around a textual | 130 | Here are the commands for placing point and the mark around a textual |
| 316 | object such as a word, list, paragraph or page. | 131 | object such as a word, list, paragraph or page: |
| 317 | 132 | ||
| 318 | @table @kbd | 133 | @table @kbd |
| 319 | @item M-@@ | 134 | @item M-@@ |
| @@ -322,23 +137,23 @@ the following one do not move point. | |||
| 322 | @item C-M-@@ | 137 | @item C-M-@@ |
| 323 | Set mark after end of following balanced expression (@code{mark-sexp}). | 138 | Set mark after end of following balanced expression (@code{mark-sexp}). |
| 324 | @item M-h | 139 | @item M-h |
| 325 | Put region around current paragraph (@code{mark-paragraph}). | 140 | Move point to the beginning of the current paragraph, and set mark at |
| 141 | the end (@code{mark-paragraph}). | ||
| 326 | @item C-M-h | 142 | @item C-M-h |
| 327 | Put region around current defun (@code{mark-defun}). | 143 | Move point to the beginning of the current defun, and set mark at the |
| 144 | end (@code{mark-defun}). | ||
| 328 | @item C-x h | 145 | @item C-x h |
| 329 | Put region around the entire buffer (@code{mark-whole-buffer}). | 146 | Move point to the beginning of the buffer, and set mark at the end |
| 147 | (@code{mark-whole-buffer}). | ||
| 330 | @item C-x C-p | 148 | @item C-x C-p |
| 331 | Put region around current page (@code{mark-page}). | 149 | Move point to the beginning of the current page, and set mark at the |
| 150 | end (@code{mark-page}). | ||
| 332 | @end table | 151 | @end table |
| 333 | 152 | ||
| 334 | @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next | 153 | @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next |
| 335 | word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the | 154 | word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the |
| 336 | next balanced expression (@pxref{Expressions}). These commands handle | 155 | next balanced expression (@pxref{Expressions}). These commands handle |
| 337 | arguments just like @kbd{M-f} and @kbd{C-M-f}. Repeating these | 156 | arguments just like @kbd{M-f} and @kbd{C-M-f}. |
| 338 | commands extends the region. For example, you can type either | ||
| 339 | @kbd{C-u 2 M-@@} or @kbd{M-@@ M-@@} to mark the next two words. These | ||
| 340 | commands also extend the region in Transient Mark mode, regardless of | ||
| 341 | the last command. | ||
| 342 | 157 | ||
| 343 | @kindex C-x h | 158 | @kindex C-x h |
| 344 | @findex mark-whole-buffer | 159 | @findex mark-whole-buffer |
| @@ -352,8 +167,7 @@ paragraph. With a prefix argument, if the argument's value is positive, | |||
| 352 | point. If the prefix argument is @minus{}@var{n}, @kbd{M-h} also | 167 | point. If the prefix argument is @minus{}@var{n}, @kbd{M-h} also |
| 353 | marks @var{n} paragraphs, running back form the one surrounding point. | 168 | marks @var{n} paragraphs, running back form the one surrounding point. |
| 354 | In that last case, point moves forward to the end of that paragraph, | 169 | In that last case, point moves forward to the end of that paragraph, |
| 355 | and the mark goes at the start of the region. Repeating the @kbd{M-h} | 170 | and the mark goes at the start of the region. |
| 356 | command extends the region to subsequent paragraphs. | ||
| 357 | 171 | ||
| 358 | @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the | 172 | @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the |
| 359 | mark after, the current (or following) major top-level definition, or | 173 | mark after, the current (or following) major top-level definition, or |
| @@ -367,51 +181,182 @@ goes after the preceding page delimiter (to exclude it). A numeric | |||
| 367 | argument specifies a later page (if positive) or an earlier page (if | 181 | argument specifies a later page (if positive) or an earlier page (if |
| 368 | negative) instead of the current page. | 182 | negative) instead of the current page. |
| 369 | 183 | ||
| 184 | While the mark is active, repeating the above commands extends the | ||
| 185 | region accordingly. For example, you can type either @kbd{C-u 2 M-@@} | ||
| 186 | or @kbd{M-@@ M-@@} to mark the next two words. Similarly, repeating | ||
| 187 | the @kbd{M-h} command extends the region to subsequent paragraphs. | ||
| 188 | |||
| 370 | Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire | 189 | Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire |
| 371 | buffer as the region, by putting point at the beginning and the mark at | 190 | buffer as the region, by putting point at the beginning and the mark at |
| 372 | the end. (In some programs this is called ``select all.'') | 191 | the end. (In some programs this is called ``select all.'') |
| 373 | 192 | ||
| 374 | In Transient Mark mode, all of these commands activate the mark. | 193 | @node Using Region |
| 194 | @section Operating on the Region | ||
| 195 | |||
| 196 | @cindex operations on a marked region | ||
| 197 | Once you have a region, here are some of the ways you can operate on | ||
| 198 | it: | ||
| 199 | |||
| 200 | @itemize @bullet | ||
| 201 | @item | ||
| 202 | Kill it with @kbd{C-w} (@pxref{Killing}). | ||
| 203 | @item | ||
| 204 | Copy it to the kill ring with @kbd{M-w} (@pxref{Yanking}). | ||
| 205 | @item | ||
| 206 | Convert case with @kbd{C-x C-l} or @kbd{C-x C-u} (@pxref{Case}). | ||
| 207 | @item | ||
| 208 | Undo changes within it using @kbd{C-u C-/} (@pxref{Undo}). | ||
| 209 | @item | ||
| 210 | Replace text within it using @kbd{M-%} (@pxref{Query Replace}). | ||
| 211 | @item | ||
| 212 | Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} (@pxref{Indentation}). | ||
| 213 | @item | ||
| 214 | Fill it as text with @kbd{M-x fill-region} (@pxref{Filling}). | ||
| 215 | @item | ||
| 216 | Print hardcopy with @kbd{M-x print-region} (@pxref{Printing}). | ||
| 217 | @item | ||
| 218 | Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}). | ||
| 219 | @item | ||
| 220 | Save it in a register with @kbd{C-x r s} (@pxref{Registers}). | ||
| 221 | @item | ||
| 222 | Save it in a buffer or a file (@pxref{Accumulating Text}). | ||
| 223 | @end itemize | ||
| 224 | |||
| 225 | Most commands that operate on the text in the region have the word | ||
| 226 | @code{region} in their names. | ||
| 227 | |||
| 228 | @node Persistent Mark | ||
| 229 | @section Persistent Marks | ||
| 230 | @cindex mode, Transient Mark | ||
| 231 | @cindex Transient Mark mode | ||
| 232 | @cindex highlighting region | ||
| 233 | @cindex region highlighting | ||
| 234 | @cindex Zmacs mode | ||
| 235 | |||
| 236 | By default, the region is highlighted whenever it exists, and it | ||
| 237 | disappears once you use it or explicitly deactivate the mark. This | ||
| 238 | behavior is called Transient Mark mode@footnote{It is also sometimes | ||
| 239 | called @dfn{Zmacs mode}, because the Zmacs editor on the MIT Lisp | ||
| 240 | Machine handled the mark in a similar way.}. | ||
| 241 | |||
| 242 | @findex transient-mark-mode | ||
| 243 | Turning off Transient Mark mode switches Emacs to an alternative | ||
| 244 | mode of operation, which was the default prior to Emacs 23. When | ||
| 245 | Transient Mark mode is off, the mark is persistent: it is @emph{never} | ||
| 246 | deactivated, but can be set to different locations using commands such | ||
| 247 | as @kbd{C-@key{SPC}}. After the first time you set the mark in a | ||
| 248 | buffer, there is always a region in that buffer. Emacs will not | ||
| 249 | highlight the region, because that would be a nuisance. As an | ||
| 250 | exception, the region is temporarily highlighted after it is set with | ||
| 251 | the mouse. | ||
| 252 | |||
| 253 | To turn off Transient Mark mode, type @kbd{M-x transient-mark-mode}. | ||
| 254 | This command toggles the mode; you can use the same command to turn | ||
| 255 | Transient Mark mode on again. You can also toggle Transient Mark mode | ||
| 256 | using the menu bar: in the @samp{Options} menu, use the @samp{Active | ||
| 257 | Region Highlighting} menu item. | ||
| 258 | |||
| 259 | Here are the details of how Emacs behaves when Transient Mark mode | ||
| 260 | is off: | ||
| 261 | |||
| 262 | @itemize @bullet | ||
| 263 | @item | ||
| 264 | Emacs does not show where the mark is located---you have to remember. | ||
| 265 | The usual solution to this problem is to set the mark and then use it | ||
| 266 | soon, before you forget where it is. Alternatively, you can check the | ||
| 267 | location of the mark by using @kbd{C-x C-x}, which exchanges the | ||
| 268 | positions of the point and the mark (@pxref{Setting Mark}). | ||
| 269 | |||
| 270 | @item | ||
| 271 | Many commands that insert text, such as @kbd{C-y} (@code{yank}), | ||
| 272 | position point and the mark at opposite ends of the inserted text, so | ||
| 273 | that the region consists of the text just inserted. You can tell when | ||
| 274 | a command sets the mark because it displays @samp{Mark set} in the | ||
| 275 | echo area. | ||
| 276 | |||
| 277 | @item | ||
| 278 | Many commands that move point long distances, like @kbd{M-<} and | ||
| 279 | @kbd{C-s}, first set the mark where point was. | ||
| 280 | |||
| 281 | @item | ||
| 282 | Some commands that ordinarily operate on the region, if one exists, | ||
| 283 | act instead on the entire buffer. For instance, @kbd{C-x u} normally | ||
| 284 | reverses changes within the region if one exists; when Transient Mark | ||
| 285 | mode is off, it acts on the entire buffer. However, you can type | ||
| 286 | @kbd{C-u C-x u} to make it operate on the region. @xref{Undo}. Other | ||
| 287 | commands that act this way are identified in their own documentation. | ||
| 288 | @end itemize | ||
| 289 | |||
| 290 | While Transient Mark mode is off, you can activate it temporarily | ||
| 291 | using @kbd{C-@key{SPC} C-@key{SPC}} or @kbd{C-u C-x C-x}. | ||
| 292 | |||
| 293 | @table @kbd | ||
| 294 | @item C-@key{SPC} C-@key{SPC} | ||
| 295 | @kindex C-@key{SPC} C-@key{SPC} | ||
| 296 | Set the mark at point (like plain @kbd{C-@key{SPC}}) and enable | ||
| 297 | Transient Mark mode just once, until the mark is deactivated. (This | ||
| 298 | is not really a separate command; you are using the @kbd{C-@key{SPC}} | ||
| 299 | command twice.) | ||
| 300 | |||
| 301 | @item C-u C-x C-x | ||
| 302 | @kindex C-u C-x C-x | ||
| 303 | Activate the mark without changing it; enable Transient Mark mode just | ||
| 304 | once, until the mark is deactivated. (This is the @kbd{C-x C-x} | ||
| 305 | command, @code{exchange-point-and-mark}, with a prefix argument.) | ||
| 306 | @end table | ||
| 307 | |||
| 308 | These commands set or activate the mark, and enable Transient Mark | ||
| 309 | mode only until the mark is deactivated. One reason you may want to | ||
| 310 | use them is that some commands operate on the entire buffer instead of | ||
| 311 | the region when Transient Mark mode is off. Enabling Transient Mark | ||
| 312 | mode momentarily gives you a way to use these commands on the region. | ||
| 375 | 313 | ||
| 376 | @node Mark Ring | 314 | @node Mark Ring |
| 377 | @section The Mark Ring | 315 | @section The Mark Ring |
| 378 | 316 | ||
| 379 | @kindex C-u C-SPC | ||
| 380 | @cindex mark ring | 317 | @cindex mark ring |
| 381 | @kindex C-u C-@@ | ||
| 382 | Aside from delimiting the region, the mark is also useful for | 318 | Aside from delimiting the region, the mark is also useful for |
| 383 | remembering a spot that you may want to go back to. To make this | 319 | remembering spots that you may want to go back to. Each buffer |
| 384 | feature more useful, each buffer remembers 16 previous locations of the | 320 | remembers 16 previous locations of the mark, in the @dfn{mark ring}. |
| 385 | mark, in the @dfn{mark ring}. Commands that set the mark also push the | 321 | Commands that set the mark also push the old mark onto this ring. |
| 386 | old mark onto this ring. To return to a marked location, use @kbd{C-u | 322 | |
| 387 | C-@key{SPC}} (or @kbd{C-u C-@@}); this is the command | 323 | @table @kbd |
| 388 | @code{set-mark-command} given a numeric argument. It moves point to | 324 | @item C-@key{SPC} C-@key{SPC} |
| 389 | where the mark was, and restores the mark from the ring of former | 325 | Set the mark, pushing it onto the mark ring, without activating it. |
| 390 | marks. | 326 | @item C-u C-@key{SPC} |
| 327 | Move point to where the mark was, and restore the mark from the ring | ||
| 328 | of former marks. | ||
| 329 | @end table | ||
| 330 | |||
| 331 | @kindex C-SPC C-SPC | ||
| 332 | The command C-@key{SPC} C-@key{SPC} is handy when you want to use | ||
| 333 | the mark to remember a position to which you may want to return. It | ||
| 334 | pushes the current point onto the mark ring, without activating the | ||
| 335 | mark (which would cause Emacs to highlight the region). This is | ||
| 336 | actually two consecutive invocations of @kbd{C-@key{SPC}} | ||
| 337 | (@code{set-mark-command}); the first @kbd{C-@key{SPC}} sets the mark, | ||
| 338 | and the second @kbd{C-@key{SPC}} deactivates it. (When Transient Mark | ||
| 339 | mode is off, C-@key{SPC} C-@key{SPC} instead activates Transient Mark | ||
| 340 | mode temporarily. @xref{Persistent Mark}.) | ||
| 341 | |||
| 342 | @kindex C-u C-SPC | ||
| 343 | To return to a marked position, use @code{set-mark-command} with a | ||
| 344 | prefix argument: @kbd{C-u C-@key{SPC}}. This moves point to where the | ||
| 345 | mark was, and deactivates the mark if it was active. Each subsequent | ||
| 346 | @kbd{C-u C-@key{SPC}} jumps to a prior position stored in the mark | ||
| 347 | ring. The positions you move through in this way are not lost; they | ||
| 348 | go to the end of the ring. | ||
| 391 | 349 | ||
| 392 | @vindex set-mark-command-repeat-pop | 350 | @vindex set-mark-command-repeat-pop |
| 393 | If you set @code{set-mark-command-repeat-pop} to non-@code{nil}, | 351 | If you set @code{set-mark-command-repeat-pop} to non-@code{nil}, |
| 394 | then when you repeat the character @kbd{C-@key{SPC}} after typing | 352 | then immediately after you type @kbd{C-u C-@key{SPC}}, you can type |
| 395 | @kbd{C-u C-@key{SPC}}, each repetition moves point to a previous mark | 353 | @kbd{C-@key{SPC}} instead of @kbd{C-u C-@key{SPC}} to cycle through |
| 396 | position from the ring. The mark positions you move through in this | 354 | the mark ring. By default, @code{set-mark-command-repeat-pop} is |
| 397 | way are not lost; they go to the end of the ring. | 355 | @code{nil}. |
| 398 | |||
| 399 | Each buffer has its own mark ring. All editing commands use the current | ||
| 400 | buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}} always stays in | ||
| 401 | the same buffer. | ||
| 402 | |||
| 403 | Many commands that can move long distances, such as @kbd{M-<} | ||
| 404 | (@code{beginning-of-buffer}), start by setting the mark and saving the | ||
| 405 | old mark on the mark ring. This is to make it easier for you to move | ||
| 406 | back later. Searches set the mark if they move point. However, in | ||
| 407 | Transient Mark mode, these commands do not set the mark when the mark | ||
| 408 | is already active. You can tell when a command sets the mark because | ||
| 409 | it displays @samp{Mark set} in the echo area. | ||
| 410 | 356 | ||
| 411 | If you want to move back to the same place over and over, the mark | 357 | Each buffer has its own mark ring. All editing commands use the |
| 412 | ring may not be convenient enough. If so, you can record the position | 358 | current buffer's mark ring. In particular, @kbd{C-u C-@key{SPC}} |
| 413 | in a register for later retrieval (@pxref{RegPos,, Saving Positions in | 359 | always stays in the same buffer. |
| 414 | Registers}). | ||
| 415 | 360 | ||
| 416 | @vindex mark-ring-max | 361 | @vindex mark-ring-max |
| 417 | The variable @code{mark-ring-max} specifies the maximum number of | 362 | The variable @code{mark-ring-max} specifies the maximum number of |
| @@ -420,10 +365,15 @@ another one is pushed, the earliest one in the list is discarded. Repeating | |||
| 420 | @kbd{C-u C-@key{SPC}} cycles through the positions currently in the | 365 | @kbd{C-u C-@key{SPC}} cycles through the positions currently in the |
| 421 | ring. | 366 | ring. |
| 422 | 367 | ||
| 423 | @vindex mark-ring | 368 | @vindex mark-even-if-inactive |
| 424 | The variable @code{mark-ring} holds the mark ring itself, as a list of | 369 | If the variable @code{mark-even-if-inactive} is @code{nil}, commands |
| 425 | marker objects, with the most recent first. This variable is local in | 370 | can only use the mark and the region when it is active. This variable |
| 426 | every buffer. | 371 | is non-@code{nil} by default. |
| 372 | |||
| 373 | If you want to move back to the same place over and over, the mark | ||
| 374 | ring may not be convenient enough. If so, you can record the position | ||
| 375 | in a register for later retrieval (@pxref{RegPos,, Saving Positions in | ||
| 376 | Registers}). | ||
| 427 | 377 | ||
| 428 | @node Global Mark Ring | 378 | @node Global Mark Ring |
| 429 | @section The Global Mark Ring | 379 | @section The Global Mark Ring |