]> code.delx.au - gnu-emacs/blobdiff - man/mark.texi
(Mail Methods): Fix xref to Message manual.
[gnu-emacs] / man / mark.texi
index 538dea7dd2f491840eddd8d33edd78a65d2ecb6c..414fa47034880de503479211cadba25bad483268 100644 (file)
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
+@c Copyright (C) 1985,86,87,93,94,95,1997,2001 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mark, Killing, Help, Top
 @chapter The Mark and the Region
@@ -14,16 +14,23 @@ end.  The text between point and the mark is called @dfn{the region}.
 Emacs highlights the region whenever there is one, if you enable
 Transient Mark mode (@pxref{Transient Mark}).
 
-  You can move point or the mark to adjust the boundaries of the region.
-It doesn't matter which one is set first chronologically, or which one
-comes earlier in the text.  Once the mark has been set, it remains where
-you put it until you set it again at another place.  Each Emacs buffer
-has its own mark, so that when you return to a buffer that had been
-selected previously, it has the same mark it had before.
+  Certain Emacs commands set the mark; other editing commands do not
+affect it, so the mark remains where you set it last.  Each Emacs
+buffer has its own mark, and setting the mark in one buffer has no
+effect on other buffers' marks.  When you return to a buffer that was
+current earlier, its mark is at the same place as before.
+
+  The ends of the region are always point and the mark.  It doesn't
+matter which of them was put in its current place first, or which one
+comes earlier in the text---the region starts from point or the mark
+(whichever comes first), and ends at point or the mark (whichever
+comes last).  Every time you move point, or set the mark in a new
+place, the region changes.
 
   Many commands that insert text, such as @kbd{C-y} (@code{yank}) and
-@kbd{M-x insert-buffer}, position point and the mark at opposite ends of
-the inserted text, so that the region contains the text just inserted.
+@kbd{M-x insert-buffer}, position point and the mark at opposite ends
+of the inserted text, so that the region consists of the text just
+inserted.
 
   Aside from delimiting the region, the mark is also useful for
 remembering a spot that you may want to go back to.  To make this
@@ -34,6 +41,7 @@ mark in the @dfn{mark ring}.
 * Setting Mark::       Commands to set the mark.
 * Transient Mark::     How to make Emacs highlight the region--
                          when there is one.
+* Momentary Mark::      Enabling Transient Mark mode momentarily.
 * Using Region::       Summary of ways to operate on contents of the region.
 * Marking Objects::    Commands to put region around textual units.
 * Mark Ring::          Previous mark positions saved so you can go back there.
@@ -45,7 +53,6 @@ mark in the @dfn{mark ring}.
 
   Here are some commands for setting the mark:
 
-@c WideCommands
 @table @kbd
 @item C-@key{SPC}
 Set the mark where point is (@code{set-mark-command}).
@@ -94,19 +101,19 @@ with the command @kbd{C-x C-x} (@code{exchange-point-and-mark}) which
 puts the mark where point was and point where the mark was.  The extent
 of the region is unchanged, but the cursor and point are now at the
 previous position of the mark.  In Transient Mark mode, this command
-reactivates the mark.
+also reactivates the mark.
 
   @kbd{C-x C-x} is also useful when you are satisfied with the position
 of point but want to move the other end of the region (where the mark
 is); do @kbd{C-x C-x} to put point at that end of the region, and then
-move it.  A second use of @kbd{C-x C-x}, if necessary, puts the mark at
+move it.  Using @kbd{C-x C-x} a second time, if necessary, puts the mark at
 the new position with point back at its original position.
 
   For more facilities that allow you to go to previously set marks, see
 @ref{Mark Ring}.
 
 @kindex C-@@
-  There is no such character as @kbd{C-@key{SPC}} in ASCII; when you
+  There is no such character as @kbd{C-@key{SPC}} in @acronym{ASCII}; when you
 type @key{SPC} while holding down @key{CTRL}, what you get on most
 ordinary terminals is the character @kbd{C-@@}.  This key is actually
 bound to @code{set-mark-command}.  But unless you are unlucky enough to
@@ -122,41 +129,48 @@ character, but its binding is still @code{set-mark-command}.
 @cindex highlighting region
 @cindex region highlighting
 
-  On a terminal that supports colors, Emacs can highlight the current
-region.  But normally it does not.  Why not?
-
-  Highlighting the region whenever it exists would not be desirable in
-Emacs, because once you have set a mark, there is @emph{always} a
-region (in that buffer).  And highlighting the region all the time
-would be a nuisance.  So normally Emacs highlights the region only
-immediately after you have selected one with the mouse.
-
-  You can turn on region highlighting by enabling Transient Mark mode.
-This is a more rigid mode of operation in which the region ``lasts''
-only temporarily, so you must set up a region for each command that uses
-one.  In Transient Mark mode, most of the time there is no region;
-therefore, highlighting the region when it exists is useful and
-not annoying.
+  On a terminal that supports colors, Emacs has the ability to
+highlight the current region.  But normally it does not.  Why not?
+
+  Once you have set the mark in a buffer, there is @emph{always} a
+region in that buffer.  This is because every command that sets the
+mark also activates it, and nothing ever deactivates it.  Highlighting
+the region all the time would be a nuisance.  So normally Emacs
+highlights the region only immediately after you have selected one
+with the mouse.
+
+  If you want region highlighting, you can use Transient Mark mode.
+This is a more rigid mode of operation in which the region always
+``lasts'' only until you use it; you explicitly must set up a region
+for each command that uses one.  In Transient Mark mode, most of the
+time there is no region; therefore, highlighting the region when it
+exists is useful and not annoying.  When Transient Mark mode is
+enabled, Emacs always highlights the region whenever there is a
+region.
 
 @findex transient-mark-mode
   To enable Transient Mark mode, type @kbd{M-x transient-mark-mode}.
-This command toggles the mode, so you can repeat the command to turn off
-the mode.
+This command toggles the mode; you can use the same command to turn
+the mode off again.
 
   Here are the details of Transient Mark mode:
 
 @itemize @bullet
 @item
 To set the mark, type @kbd{C-@key{SPC}} (@code{set-mark-command}).
-This makes the mark active; as you move point, you will see the region
-highlighting grow and shrink.
+This makes the mark active and thus begins highlighting of the region.
+As you move point, you will see the highlighted region grow and
+shrink.
 
-@item 
+@item
 The mouse commands for specifying the mark also make it active.  So do
 keyboard commands whose purpose is to specify a region, including
 @kbd{M-@@}, @kbd{C-M-@@}, @kbd{M-h}, @kbd{C-M-h}, @kbd{C-x C-p}, and
 @kbd{C-x h}.
 
+@item
+You can tell that the mark is active because the region is highlighted.
+
 @item
 When the mark is active, you can execute commands that operate on the
 region, such as killing, indenting, or writing to a file.
@@ -168,8 +182,11 @@ on a region will get an error and refuse to operate.  You can make the
 region active again by typing @kbd{C-x C-x}.
 
 @item
-Commands like @kbd{M->} and @kbd{C-s} that ``leave the mark behind'' in
-addition to some other primary purpose do not activate the new mark.
+Quitting with @kbd{C-g} deactivates the mark.
+
+@item
+Commands like @kbd{M->} and @kbd{C-s}, that ``leave the mark behind'' in
+addition to some other primary purpose, do not activate the new mark.
 You can activate the new region by executing @kbd{C-x C-x}
 (@code{exchange-point-and-mark}).
 
@@ -177,20 +194,17 @@ You can activate the new region by executing @kbd{C-x C-x}
 @kbd{C-s} when the mark is active does not alter the mark.
 
 @item
-Quitting with @kbd{C-g} deactivates the mark.
-
-@item
-Some commands operate on the region whenever it is active.  For
-instance, @kbd{C-x u} in Transient Mark mode operates on the region
-when there is a region.  Outside Transient Mark mode, you must type
-@kbd{C-u C-x u} if you want it to operate on the region.
-@xref{Undo}.   Other commands that act this way are identified
-in their own documentation.
+Some commands operate on the region if a region is active.  For
+instance, @kbd{C-x u} in Transient Mark mode operates on the region,
+when there is a region.  (Outside Transient Mark mode, you must type
+@kbd{C-u C-x u} if you want it to operate on the region.)
+@xref{Undo}.  Other commands that act this way are identified in their
+own documentation.
 @end itemize
 
-  Highlighting of the region uses the @code{region} face; you can
-customize how the region is highlighted by changing this face.
-@xref{Face Customization}.
+  The highlighting of the region uses the @code{region} face; you can
+customize the appearance of the highlighted region by changing this
+face.  @xref{Face Customization}.
 
 @vindex highlight-nonselected-windows
   When multiple windows show the same buffer, they can have different
@@ -199,23 +213,55 @@ all share one common mark position).  Ordinarily, only the selected
 window highlights its region (@pxref{Windows}).  However, if the
 variable @code{highlight-nonselected-windows} is non-@code{nil}, then
 each window highlights its own region (provided that Transient Mark mode
-is enabled and the window's buffer's mark is active).
-
-  When Transient Mark mode is not enabled, every command that sets the
-mark also activates it, and nothing ever deactivates it.
+is enabled and the mark in the window's buffer is active).
 
 @vindex mark-even-if-inactive
   If the variable @code{mark-even-if-inactive} is non-@code{nil} in
 Transient Mark mode, then commands can use the mark and the region
-even when it is inactive.  Region highlighting appears and disappears 
+even when it is inactive.  Region highlighting appears and disappears
 just as it normally does in Transient Mark mode, but the mark doesn't
-really go away when the highlighting disappears.
+really go away when the highlighting disappears, so you can still use
+region commands.
 
 @cindex Zmacs mode
   Transient Mark mode is also sometimes known as ``Zmacs mode''
 because the Zmacs editor on the MIT Lisp Machine handled the mark in a
 similar way.
 
+@node Momentary Mark
+@section Using Transient Mark Mode Momentarily
+
+  If you don't like Transient Mark mode in general, you might still
+want to use it once in a while.  To do this, type @kbd{C-@key{SPC}
+C-@key{SPC}} or @kbd{C-u C-x C-x}.  These commands set or activate the
+mark, and enable Transient Mark mode only until the mark is
+deactivated.
+
+@table @kbd
+@item C-@key{SPC} C-@key{SPC}
+@kindex C-@key{SPC} C-@key{SPC}
+Set the mark at point (like plain @kbd{C-@key{SPC}}), and enable
+Transient Mark mode just once until the mark is deactivated.  (This is
+not really a separate command; you are using the @kbd{C-@key{SPC}}
+command twice.)
+
+@item C-u C-x C-x
+@kindex C-u C-x C-x
+Activate the mark without changing it, enable Transient Mark mode just
+once until the mark is deactivated.  (This is the @kbd{C-x C-x} command,
+@code{exchange-point-and-mark}, with a prefix argument.)
+@end table
+
+  One of the secondary features of Transient Mark mode is that certain
+commands operate on the region when there is an active region.  If you
+don't use Transient Mark mode, the region once set never becomes
+inactive, so there is no way these commands to make such a
+distinction.  Enabling Transient Mark mode momentarily gives you a way
+to use these commands on the region.
+
+  The other way momentarily use of Transient Mark mode is useful
+is that it highlights the region for the time being.
+
 @node Using Region
 @section Operating on the Region
 
@@ -242,8 +288,8 @@ Print hardcopy with @kbd{M-x print-region} (@pxref{Hardcopy}).
 Evaluate it as Lisp code with @kbd{M-x eval-region} (@pxref{Lisp Eval}).
 @end itemize
 
-  Most commands that operate on the text in the
-region have the word @code{region} in their names.
+  Most commands that operate on the text in the region have the word
+@code{region} in their names.
 
 @node Marking Objects
 @section Commands to Mark Textual Objects
@@ -261,9 +307,9 @@ Set mark after end of following balanced expression (@code{mark-sexp}).
 @item M-h
 Put region around current paragraph (@code{mark-paragraph}).
 @item C-M-h
-Put region around current Lisp defun (@code{mark-defun}).
+Put region around current defun (@code{mark-defun}).
 @item C-x h
-Put region around entire buffer (@code{mark-whole-buffer}).
+Put region around the entire buffer (@code{mark-whole-buffer}).
 @item C-x C-p
 Put region around current page (@code{mark-page}).
 @end table
@@ -271,21 +317,33 @@ Put region around current page (@code{mark-page}).
 @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next
 word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the
 next balanced expression (@pxref{Expressions}).  These commands handle
-arguments just like @kbd{M-f} and @kbd{C-M-f}.
+arguments just like @kbd{M-f} and @kbd{C-M-f}.  If you repeat these
+commands, the region is extended.  For example, you can type either
+@kbd{C-u 2 M-@@} or @kbd{M-@@ M-@@} to mark the next two words.
 
 @kindex C-x h
 @findex mark-whole-buffer
    Other commands set both point and mark, to delimit an object in the
 buffer.  For example, @kbd{M-h} (@code{mark-paragraph}) moves point to
-the beginning of the paragraph that surrounds or follows point, and puts
-the mark at the end of that paragraph (@pxref{Paragraphs}).  It prepares
-the region so you can indent, case-convert, or kill a whole paragraph.
-
-  @kbd{C-M-h} (@code{mark-defun}) similarly puts point before and the
-mark after the current or following defun (@pxref{Moving by Defuns}).
-@kbd{C-x C-p} (@code{mark-page}) puts point before the current page,
-and mark at the end (@pxref{Pages}).  The mark goes after the
-terminating page delimiter (to include it), while point goes after the
+the beginning of the paragraph that surrounds or follows point, and
+puts the mark at the end of that paragraph (@pxref{Paragraphs}).  It
+prepares the region so you can indent, case-convert, or kill a whole
+paragraph.  With prefix argument, if the argument's value is positive,
+@kbd{M-h} marks that many paragraphs starting with the one surrounding
+point.  If the prefix argument is @minus{}@var{n}, @kbd{M-h} also
+marks @var{n} paragraphs, running back form the one surrounding point.
+In that last case, point moves forward to the end of that paragraph,
+and the mark goes at the start of the region.  The @kbd{M-h} command
+also supports the extension of the region, similar to @kbd{M-@@} and
+@kbd{C-M-@@}.
+
+  @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the
+mark after, the current (or following) major top-level definition, or
+defun (@pxref{Moving by Defuns}).  (Currently it only marks one defun,
+but repeating it marks more defuns, like for @kbd{M-@@}.)  @kbd{C-x
+C-p} (@code{mark-page}) puts point before the current page, and mark
+at the end (@pxref{Pages}).  The mark goes after the terminating page
+delimiter (to include it in the region), while point goes after the
 preceding page delimiter (to exclude it).  A numeric argument
 specifies a later page (if positive) or an earlier page (if negative)
 instead of the current page.
@@ -310,9 +368,12 @@ old mark onto this ring.  To return to a marked location, use @kbd{C-u
 C-@key{SPC}} (or @kbd{C-u C-@@}); this is the command
 @code{set-mark-command} given a numeric argument.  It moves point to
 where the mark was, and restores the mark from the ring of former
-marks.  Thus, repeated use of this command moves point to all of the old
-marks on the ring, one by one.  The mark positions you move through in
-this way are not lost; they go to the end of the ring.
+marks.
+
+  If you repeat the character @kbd{C-@key{SPC}}, after typing @kbd{C-u
+C-@key{SPC}}, each repetition moves point to a previous mark position
+from the ring.  The mark positions you move through in this way are
+not lost; they go to the end of the ring.
 
   Each buffer has its own mark ring.  All editing commands use the current
 buffer's mark ring.  In particular, @kbd{C-u C-@key{SPC}} always stays in
@@ -333,7 +394,7 @@ Registers}).
 @vindex mark-ring-max
   The variable @code{mark-ring-max} specifies the maximum number of
 entries to keep in the mark ring.  If that many entries exist and
-another one is pushed, the last one in the list is discarded.  Repeating
+another one is pushed, the earliest one in the list is discarded.  Repeating
 @kbd{C-u C-@key{SPC}} cycles through the positions currently in the
 ring.
 
@@ -364,3 +425,6 @@ the buffer and position of the latest entry in the global ring.  It also
 rotates the ring, so that successive uses of @kbd{C-x C-@key{SPC}} take
 you to earlier and earlier buffers.
 
+@ignore
+   arch-tag: f35e4d82-911b-4cfc-a3d7-3c87b2abba20
+@end ignore