Skip to main content

Module keymap_mode_contributions

Module keymap_mode_contributions 

Source
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 typed KeymapBindings carrying a CommandInvocation. 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 the CommandRegistry at registration time to mint a CommandInvocation; the entry’s doc, source, and parsed chord flow into the resulting KeymapBinding. Entries whose name doesn’t resolve log a tracing::warn! and skip (matches the existing catalog-drift convention); entries with command = None (synthetic actions like PushDigit) skip silently — they’re informational catalog rows for :describe-key and :keymap, not dispatchable bindings.

Functions§

translate_mode_keymap
Translate one mode’s Keymap contribution and push it as a layer. Symmetric with translate_mode_keymaps but scoped to a single mode — the entry point a future plugin host or dynamic ModeRegistry::register call site uses to hot-attach a newly-loaded mode without re-walking the full registry.
translate_mode_keymaps
Walk every mode in registry, call Mode::keymap(), and push each non-empty contribution as a MinorMode(mode_id) layer on handle.