This page is about library zones.el, which lets you easily define and subsequently act on multiple zones of buffer text — in effect, multiple regions.

You can get zones.el from Emacs Wiki or GNU ELPA:

The instance on Emacs Wiki might sometimes be more recent, but major changes (named versions) are posted to GNU ELPA.

(If you use Emacs 20 or 21 then you can use zones20.el instead. It has a subset of the zones.el features.)

You can think of zones as enlarging the notion of region. A set of buffer zones is, in effect, a (typically) noncontiguous “region” of text.

The content of a zone is any contiguous stretch of buffer text.

A set of zones differs from what Emacs calls a noncontiguous region in these ways:

Commands that use zones typically act on izones, which are just zones that are labeled with a numeric identifier (a negative integer).

Zones have even more in common with Emacs overlays than they do with segments of a noncontiguous region. An overlay has an associated buffer, two limits (start and end), and an optional list of properties.

Zones differ from overlays in these ways:

You can create zones from overlays, and vice versa. You can also unite (coalesce) overlays or zones that overlap or are adjacent.

When creating zones from overlays, the overlay property list becomes the EXTRA information of the resulting zone: (LIMIT1 LIMIT2 . EXTRA).

When creating overlays from zones, any list of EXTRA zone information is used as the property list of the resulting overlay.

You can do the following with a list of zones:

Many of the commands that manipulate zones are bound on keymap ‘narrow-map’. They are available on prefix key ‘C-x n’, along with the narrowing/widening keys ‘C-x n d’, ‘C-x n n’, ‘C-x n p’, and ‘C-x n w’:

The above descriptions speak of the “current list” of zones. You can have any number of variables whose value is a list of zones, and you can switch among them. The variables can be buffer-local or global (e.g., with positions recorded from multiple buffers).

Most zone commands let you use a prefix argument to be prompted for a different zones variable to use from the current one (the value of variable ‘zz-izones-var’). The use can be just for the current command (e.g., add a zone to the list of zones in a particular variable). Or it can be also for subsequent zone commands, by making the variable you entered the current one (setting ‘zz-izones-var’ to it).

If you use library Icicles then you can use commands ‘icicle-select-zone’, to select a zone as the region, and ‘icicle-buffer-narrowing’, to choose a narrowing (buffer restriction) and apply it. They let you cycle zones, like ‘zz-select-zone-repeat’ and ‘zz-narrow-repeat’, but you can, in addition, pick zones by name (composed of the zone limits and a zone-text prefix) using completion. The candidate zones can be from multiple buffers.

(Library zones.el supersedes library wide-n.el, which is obsolete as of 2015-08-16.)

CategoryRegion MultipleModes MultipleNarrowings