9.6.4 Active Regions
By default, both the text you select in an Emacs buffer using the
click-and-drag mechanism and text you select by setting point and the
mark is highlighted. You can use Emacs region commands as well as the
Cut and Copy commands on the highlighted region you selected with the
If you prefer, you can make a distinction between text selected with
the mouse and text selected with point and the mark by setting the
variable `zmacs-regions' to `nil'. In that case:
* The text selected with the mouse becomes both the X selection and
the Emacs selected region. You can use menu-bar commands as well
as Emacs region commands on it.
* The text selected with point and the mark is not highlighted. You
can only use Emacs region commands on it, not the menu-bar items.
Active regions originally come from Zmacs, the Lisp Machine editor.
The idea behind them is that commands can only operate on a region when
the region is in an "active" state. Put simply, you can only operate on
a region that is highlighted.
The variable `zmacs-regions' checks whether LISPM-style active
regions should be used. This means that commands that operate on the
region (the area between point and the mark) only work while the region
is in the active state, which is indicated by highlighting. Most
commands causes the region to not be in the active state; for example,
`C-w' only works immediately after activating the region.
* Commands that operate on the region only work if the region is
* Only a very small set of commands causes the region to become
active-- those commands whose semantics are to mark an area, such
* The region is deactivated after each command that is executed,
except that motion commands do not change whether the region is
active or not.
`set-mark-command' (`C-SPC') pushes a mark and activates the region.
Moving the cursor with normal motion commands (`C-n', `C-p', etc.) will
cause the region between point and the recently-pushed mark to be
highlighted. It will remain highlighted until some non-motion command
`exchange-point-and-mark' (`C-x C-x') activates the region. So if
you mark a region and execute a command that operates on it, you can
reactivate the same region with `C-x C-x' (or perhaps `C-x C-x C-x
C-x') to operate on it again.
Generally, commands that push marks as a means of navigation, such as
`beginning-of-buffer' (`M-<') and `end-of-buffer' (`M->'), do not
activate the region. However, commands that push marks as a means of
marking an area of text, such as `mark-defun' (`M-C-h'), `mark-word'
(`M-@'), and `mark-whole-buffer' (`C-x h'), do activate the region.
When `zmacs-regions' is `t', there is no distinction between the
primary X selection and the active region selected by point and the
mark. To see this, set the mark (<C-SPC>) and move the cursor with any
cursor-motion command: the region between point and mark is
highlighted, and you can watch it grow and shrink as you move the
Any other commands besides cursor-motion commands (such as inserting
or deleting text) will cause the region to no longer be active; it will
no longer be highlighted, and will no longer be the primary selection.
Region can be explicitly deactivated with `C-g'.
Commands that require a region (such as `C-w') signal an error if
the region is not active. Certain commands cause the region to be in
its active state. The most common ones are `push-mark' (<C-SPC>) and
`exchange-point-and-mark' (`C-x C-x').
When `zmacs-regions' is `t', programs can be non-intrusive on the
state of the region by setting the variable `zmacs-region-stays' to a
non-`nil' value. If you are writing a new Emacs command that is
conceptually a "motion" command and should not interfere with the
current highlightedness of the region, then you may set this variable.
It is reset to `nil' after each user command is executed.
When `zmacs-regions' is `t', programs can make the region between
point and mark go into the active (highlighted) state by using the
function `zmacs-activate-region'. Only a small number of commands
should ever do this.
When `zmacs-regions' is `t', programs can deactivate the region
between point and the mark by using `zmacs-deactivate-region'. Note:
you should not have to call this function; the command loop calls it
automatically generated by info2www version 126.96.36.199