Extract the inline markdown wrap/unwrap logic from the current Emacs keymap module into a standalone pure function
Handle three cases: wrap selection, unwrap existing symbols, and insert empty symbols with cursor positioning
Ensure no React or hook dependencies — pure CodeMirror state/view operations only
Requirements: 2.1, 2.3
[x] 1.2 (P) Create the line prefix utility
Extract line-prefix insertion logic into a standalone pure function alongside the toggle utility
Support single-line and multi-line selections, toggle-off when all lines already have the prefix
Requirements: 2.1
[x] 1.3 Rewire existing public hooks to delegate to the new shared utilities
Update the insert-markdown-elements hook to become a thin wrapper calling the shared toggle function
Update the insert-prefix hook to delegate to the shared line-prefix function
Verify that existing editor behavior (bold, italic, etc. via toolbar/shortcuts) remains unchanged
Requirements: 2.2, 2.3
[x] 2. Define keymap type system and refactor the dispatcher
[x] 2.1 Define the keymap result interface, factory type, and shortcut category types
Introduce a structured return type that bundles extension, precedence wrapper, and override category declarations
Define the shortcut category union type and the categorized key-bindings grouping type
Place all types in a dedicated types module within the keymaps directory
Requirements: 1.2, 1.4, 3.1
[x] 2.2 Simplify the keymap dispatcher to a thin router
Remove all inline keymap construction logic (default and vscode mode handling) from the dispatcher
Replace with a simple switch that delegates to each mode's factory function
Ensure the dispatcher returns the structured keymap result to callers
Requirements: 1.2, 1.3
[x] 3. Create dedicated keymap modules for each mode
[x] 3.1 (P) Create the default keymap module
Implement as an async factory returning the standard CodeMirror default keymap with low precedence and no overrides
Requirements: 1.1
[x] 3.2 (P) Create the VSCode keymap module
Implement as an async factory returning the VSCode keymap extension with low precedence and no overrides
Requirements: 1.1
[x] 3.3 Refactor the Vim keymap module for structural consistency
Move top-level side effects (key mappings like jj/jk escape, :w ex-command) inside the factory function
Add an idempotency guard to prevent duplicate registration on re-import
Return high precedence and empty overrides (Vim uses its own modal system)
Accept the optional onSave callback and register :w ex-command when provided
Requirements: 1.1, 7.1, 7.2
[x] 4. Build the Emacs keymap module with formatting submodule
[x] 4.1 Create the Emacs module structure and factory entry point
Set up the Emacs subdirectory with an index module that dynamically imports the Emacs extension
The factory composes all submodule registrations, registers save binding, and returns high precedence with formatting and structural overrides declared
Requirements: 1.1, 1.4
[x] 4.2 Implement the formatting bindings submodule
Register C-c C-s prefix bindings for bold, italic, inline code, strikethrough, and code block
Delegate all formatting operations to the shared toggle-markdown-symbol utility
Support both lowercase and uppercase variants where specified (bold: b/B, italic: i/I)
Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
[x] 5. Relocate editor shortcuts and introduce category-based grouping
[x] 5.1 Move the editor-shortcuts directory from the public services layer to services-internal
Physically relocate the directory and update all import paths in the consuming store module (10 imports)
Verify build passes after relocation
Requirements: 3.2
[x] 5.2 Wrap each shortcut group with categorized key-bindings metadata
Group formatting shortcuts (bold, italic, strikethrough, code) under the formatting category
Group structural shortcuts (numbered list, bullet list, blockquote, link) under the structural category
Group always-on shortcuts (multi-cursor) with null category so they are never excluded
Requirements: 3.2, 3.3
[x] 6. Refactor store layer for data-driven shortcut registration
[x] 6.1 Update the editor shortcuts store to use category-based exclusion
Replace the hard-coded emacs mode check with data-driven filtering using the override categories from the keymap result
Change the parameter from keymap mode name to an array of shortcut categories to exclude
Filter categorized binding groups: include groups with null category always, exclude groups whose category appears in the overrides
Requirements: 3.1, 3.2, 3.3
[x] 6.2 Simplify the editor settings store to use keymap result metadata
Remove the standalone precedence-determination function
Apply precedence directly from the keymap result's encapsulated precedence wrapper
Pass the keymap result's override declarations to the editor shortcuts store