Expand description
K.2.4 — host translation pass for mode-contributed keymaps.
Walks the ModeRegistry (boot path) or a single newly-
registered mode (dynamic path) and merges each mode’s
[Keymap] contribution into the host’s KeymapHandle
at KeymapLayer::MinorMode(mode.id()).
See keymap-architecture.md §11.3 for the design
contract. The K.2 substrate (K.2.1 chord primitives, K.2.2
BindingMode, K.2.3 real Keymap, K.2.4.A.0.1 catalog
relocation, K.2.4.A.0.2 entry-form Keymap::from_entries)
is in place; this slice is the plumbing that calls
Mode::keymap(), resolves any table-form entries against
the CommandRegistry, and inserts the result into the
matcher trie. Once K.2.5 promotes the multibuffer +
project-search bindings into their owning mode crates, this
pass is what makes those bindings reachable; until then it
runs over the registry without finding any non-default
Keymaps (every mode still returns Keymap::default()).
§Resolution model
Two declaration paths share the same insertion path:
- Chain form (
Keymap::bindings): already typedKeymapBindings carrying aCommandInvocation. Used directly. - Table form (
Keymap::entries): static-catalog rows built via the [keymap_entry!] macro. Each entry carries a canonical command-name string ("motion:line-down", …). The pass resolves the name against theCommandRegistryat registration time to mint aCommandInvocation; the entry’sdoc,source, and parsed chord flow into the resultingKeymapBinding. Entries whose name doesn’t resolve log atracing::warn!and skip (matches the existing catalog-drift convention); entries withcommand = None(synthetic actions likePushDigit) skip silently — they’re informational catalog rows for:describe-keyand:keymap, not dispatchable bindings.
Functions§
- translate_
mode_ keymap - Translate one mode’s
Keymapcontribution and push it as a layer. Symmetric withtranslate_mode_keymapsbut scoped to a single mode — the entry point a future plugin host or dynamicModeRegistry::registercall site uses to hot-attach a newly-loaded mode without re-walking the full registry. - translate_
mode_ keymaps - Walk every mode in
registry, callMode::keymap(), and push each non-empty contribution as aMinorMode(mode_id)layer onhandle.