Zones

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 think of this as enlarging the notion of region. In effect, it can remove the requirement of target text being a contiguous sequence of characters. A set of buffer zones is, in effect, a (typically) noncontiguous “region” of text.

A zone records two buffer positions and an optional list of additional information (whatever you like). Each buffer position can be a marker, which means that a list of zones can specify zones in different buffers.

A position can also be a readable marker, which is a Lisp sexp that can be written to disk (e.g., as part of a bookmark or saved variable), and restored in a later Emacs session by reading the file where it is saved.

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

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-region-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