Skip to main content

Module narrow

Module narrow 

Source
Expand description

N.1.1 (2026-06-10): narrow mode — a focused, editable one-excerpt multibuffer view of a region. Unlike search, narrow is a first-class built-in (no cargo feature gate): no async scan, no service, no per-view state beyond the excerpt. N.1.1 (2026-06-10): narrow mode — a focused, editable one-excerpt multibuffer view of a region of a source buffer.

Design: docs/dev/architecture/narrow-mode.md. Slice plan: docs/dev/operations/slice-plans/narrow-mode.md (N.1.1).

Narrow is a one-excerpt multibuffer + a marker minor mode. There is no BufferKind::Narrow — the view is a regular BufferKind::Multibuffer and reuses every M-series primitive (M.3 edit propagation, M.4 live source updates, K.4.7 per-excerpt syntax). Edits in the narrow view propagate to the source buffer; :widen closes the view, leaving the source (with its edits) open.

Unlike providers::search, narrow is not feature-gated — it’s a first-class built-in primitive — and it carries no async scan, no service, and no per-view state beyond the excerpt itself.

Entry is the :narrow [{range}] ex-command (and, from N.1.3, the zn operator). The ex-command emits AppEffect::NarrowTrigger; the host arm resolves the range, fetches the active buffer’s handle, and calls [create_narrow_view].

Structs§

NarrowMode
narrow-mode — the provider-minor activated on a narrow view. In N.1.1 it is a pure identity marker: a multibuffer with this minor active IS a narrow view (distinguished from search / diff multibuffers), which the host’s :widen guard and N.1.5’s stacking logic read.
NarrowModeGuard
RAII guard for NarrowMode. Unit in N.1.1 (no subscriptions / action handlers yet); becomes a Vec of ActionHandlerRegistration when the q / :w surface lands.

Functions§

create_narrow_view
Allocate a one-excerpt multibuffer view over [start_line, end_line] (inclusive, 0-based) of source_id and activate NarrowMode on it. Returns the new view’s BufferId.
register_narrow_ex_commands
Boot helper — register the :narrow + :widen ex-commands.
register_narrow_mode
Boot helper — register the narrow provider-minor mode. Called from lattice-host::editor_boot alongside the other multibuffer mode registrations.
register_narrow_operator
N.1.3 (2026-06-10): register the zn narrow operator into the grammar’s CommandRegistry and return its OperatorId.