Skip to main content

Module refreshable_view_mode

Module refreshable_view_mode 

Source
Expand description

refreshable-view-mode — the one place gr means “refresh this view”.

§Why a shared minor and not a chord per mode

gr refreshes a synthetic buffer in every synthetic buffer that has one. That is a property of synthetic views as a class, so by the “shared behaviour is a minor mode, never a copied keymap” standing rule the chord belongs here once.

It did not start that way. As of 2026-08-10 three independent copies existed — magit-core-mode (action:magit-refresh), compilation-mode (action:compilation-recompile) and providers::search (action:search-refresh) — and the two synthetic views that landed most recently, *problems* and narrow, had no gr at all. Nobody noticed, because a gap in a copied set does not announce itself. That is the failure this mode closes.

§The split

This mode owns the chord. Each view’s mode owns the body, and declares which of its own actions is the refresh via Mode::refresh_action — a target, not a body, so existing handlers keep working untouched.

Resolution is host-side (Editor::resolve_refresh_action) because it needs the buffer’s active-mode set, which lives on the editor rather than in the ServiceRegistry. Same split as invocation_runner: the mode declares, the host walks and dispatches. action:view-refresh is therefore a generic host action — it carries no per-view logic, it only redirects to whatever the active modes named.

§Activation

Automatic: a mode returning Some from refresh_action() pulls this minor in through the implies cascade (see ModeRegistry::record_implies_cascade). A mode author writes one line and gets the chord — there is no second thing to remember, which matters because forgetting it would kill the chord exactly as silently as the copied keymaps did.

ActivationPolicy::Manual so it never auto-attaches to ordinary buffers: gr in a source buffer is LSP references and must stay that way.

Structs§

RefreshableViewMode
refreshable-view-mode minor. A marker mode: one keymap layer, no per-buffer resources (Guard = ()), and deliberately no action handler — the body it would hold lives in each view’s own mode.

Constants§

VIEW_REFRESH_ACTION
The canonical command name the shared gr resolves to. The host intercepts this id, resolves the active modes’ declared refresh action, and dispatches that.

Functions§

register_refreshable_view_actions
Register action:view-refresh so the mode’s keymap cmd name resolves at boot.
register_refreshable_view_mode
Register RefreshableViewMode in registry. Called by register_foundation_modes; it must be registered for the implies cascade to pull it in (an unregistered shared minor is logged at debug! and the chord simply does not bind).