# Lumacs Roadmap - Emacs Foundation ## Current Status ✅ ### Core Editing - ✅ Basic text insertion/deletion - ✅ Character and line operations - ✅ Undo/Redo (100 levels) - ✅ Find text ### Buffer System - ✅ Multiple buffers - ✅ Buffer creation/loading - ✅ File save/save-as - ✅ Modification tracking - ✅ Event system (BeforeChange, AfterChange, etc.) ### Window Management - ✅ Split windows (horizontal/vertical) - ✅ Close windows - ✅ Navigate between windows (C-w) - ✅ Multi-window layout tree ### Mode System - ✅ Major mode framework - ✅ Minor mode framework - ✅ Auto-activation by file pattern - ✅ Mode-specific keybindings - ✅ Mode-specific syntax highlighting - ✅ lua-mode implemented ### Movement - ✅ Arrow keys - ✅ C-n, C-p, C-f, C-b (line/char navigation) - ✅ C-a, C-e (beginning/end of line) - ✅ Home/End - ✅ M-ArrowUp/Down (line swapping) ### Keybindings - ✅ Meta key support (M-) - ✅ Control key support (C-) - ✅ Prefix sequences (C-x) - ✅ Global and mode-specific bindings ### Other - ✅ Syntax highlighting - ✅ Message system - ✅ Minibuffer (basic) --- ## Missing Core Emacs Features ### HIGH PRIORITY - Essential Emacs DNA #### 1. Kill Ring System ⭐⭐⭐ **Why:** The kill ring is fundamental to Emacs' copy/paste workflow **Implementation needed:** - Kill ring data structure (circular buffer) - `C-w` (kill-region) - cut selection - `M-w` (kill-ring-save) - copy selection - `C-y` (yank) - paste - `M-y` (yank-pop) - cycle through kill ring - `C-k` (kill-line) - kill from cursor to end of line - Append kills when consecutive **C++ API needed:** ```cpp class KillRing { std::vector ring_; size_t max_size_ = 60; size_t yank_index_ = 0; public: void push(std::string text); std::string yank(); std::string yank_pop(); }; ``` #### 2. Mark and Region ⭐⭐⭐ **Why:** Emacs' selection system is mark-based, not mouse-based **Implementation needed:** - Mark position storage - `C-SPC` or `C-@` (set-mark-command) - set mark - `C-x C-x` (exchange-point-and-mark) - swap cursor and mark - `C-x h` (mark-whole-buffer) - select all - Visual indication of active region - Region-based operations (kill, copy, etc.) **C++ API needed:** ```cpp class Buffer { std::optional mark_; bool mark_active_ = false; public: void set_mark(Position pos); void deactivate_mark(); std::optional get_region() const; bool has_active_region() const; }; ``` #### 3. Buffer Management ⭐⭐⭐ **Why:** Need to work with multiple files efficiently **Implementation needed:** - `C-x b` (switch-to-buffer) - switch buffer with prompt - `C-x C-b` (list-buffers) - show buffer list - `C-x k` (kill-buffer) - close buffer - Buffer name completion in minibuffer - Show buffer list in special buffer **Lua API:** ```lua function list_buffers() function switch_to_buffer(name) function kill_buffer(name) ``` #### 4. Advanced Movement ⭐⭐ **Why:** Efficient navigation is key to productivity **Implementation needed:** - `M-f` (forward-word) - move forward by word - `M-b` (backward-word) - move backward by word - `C-v` (scroll-up) - page down - `M-v` (scroll-down) - page up - `M-<` (beginning-of-buffer) - go to start - `M->` (end-of-buffer) - go to end - `M-g M-g` or `M-g g` (goto-line) - jump to line number **C++ API needed:** ```cpp void move_forward_word(); void move_backward_word(); void page_up(); void page_down(); void goto_beginning(); void goto_end(); void goto_line(size_t line); ``` #### 5. Incremental Search ⭐⭐ **Why:** The Emacs way of searching **Implementation needed:** - `C-s` (isearch-forward) - incremental search - `C-r` (isearch-backward) - reverse incremental search - Show search matches highlighted - `C-s` again to find next - `C-g` to cancel search - Search history **Mode:** Requires a search mode/state ### MEDIUM PRIORITY - Greatly Enhance Usability #### 6. Word Operations ⭐⭐ - `M-d` (kill-word) - delete word forward - `M-DEL` (backward-kill-word) - delete word backward - `M-t` (transpose-words) - swap words - `C-t` (transpose-chars) - swap characters #### 7. Case Conversion ⭐⭐ - `M-u` (upcase-word) - uppercase word - `M-l` (downcase-word) - lowercase word - `M-c` (capitalize-word) - capitalize word - `C-x C-u` (upcase-region) - uppercase selection - `C-x C-l` (downcase-region) - lowercase selection #### 8. Comment/Uncomment ⭐⭐ - `M-;` (comment-dwim) - comment or uncomment region - Should use mode's comment syntax #### 9. Auto-Indentation ⭐⭐ - `TAB` - indent current line - `C-j` (newline-and-indent) - insert newline and indent - Mode-specific indentation rules #### 10. Better Minibuffer ⭐ - Completion support - History (M-p, M-n) - Better prompting system - Tab completion ### LOWER PRIORITY - Nice to Have #### 11. Fill/Wrap Text - `M-q` (fill-paragraph) - reflow text to column width - Auto-fill mode #### 12. Registers - `C-x r s` (copy-to-register) - `C-x r i` (insert-register) - Named storage slots #### 13. Rectangle Operations - `C-x r k` (kill-rectangle) - `C-x r y` (yank-rectangle) - `C-x r t` (string-rectangle) #### 14. Macros - `C-x (` (start-kbd-macro) - `C-x )` (end-kbd-macro) - `C-x e` (call-last-kbd-macro) #### 15. Point Mark Ring - `C-u C-SPC` - jump to previous mark - Mark ring for navigation history #### 16. Dired (Directory Editor) - Browse directories - File operations in a buffer --- ## Implementation Strategy ### Phase 1: Core Emacs Feel (2-3 days) Focus on making the editor feel like Emacs: 1. Kill ring system (C-w, M-w, C-y, C-k) 2. Mark and region (C-SPC, C-x C-x) 3. Basic word movement (M-f, M-b) 4. Page scrolling (C-v, M-v) ### Phase 2: Buffer Management (1-2 days) Make working with multiple files practical: 1. Buffer switching (C-x b) 2. Buffer list (C-x C-b) 3. Kill buffer (C-x k) ### Phase 3: Enhanced Editing (2-3 days) Add the editing commands power users expect: 1. Word operations (M-d, M-DEL) 2. Case conversion (M-u, M-l, M-c) 3. Incremental search (C-s, C-r) 4. Comment toggle (M-;) ### Phase 4: Polish (1-2 days) Refinements and quality of life: 1. Better minibuffer with completion 2. Auto-indentation 3. More modes (python-mode, etc.) --- ## Architecture Improvements Needed ### 1. Kill Ring (C++ Core) Add to `EditorCore`: ```cpp class KillRing; std::unique_ptr kill_ring_; ``` ### 2. Mark Support (C++ Core) Add to `Buffer`: ```cpp std::optional mark_; bool mark_active_; ``` ### 3. Buffer List (C++ Core) Already have `std::list> buffers_` but need: - Buffer switching API - Buffer naming/identification - Active buffer tracking per window ### 4. Search State (C++ Core) Add search state machine for incremental search ### 5. Word Navigation (C++ Core) Add word boundary detection to `Buffer`: ```cpp Position find_word_boundary_forward(Position pos); Position find_word_boundary_backward(Position pos); ``` --- ## Quick Wins (Can implement today) 1. **C-k (kill-line)** - Just delete from cursor to end of line 2. **M-<, M->** - Jump to start/end of buffer (trivial) 3. **C-x h** - Select all (set mark to 0, cursor to end) 4. **M-g g** - Goto line (already have goto_line helper) 5. **Better movement** - C-v/M-v page scrolling --- ## Measuring Progress **Emacs Compatibility Score:** - ✅ Current: ~30/100 - 🎯 After Phase 1: ~55/100 - 🎯 After Phase 2: ~70/100 - 🎯 After Phase 3: ~85/100 - 🎯 After Phase 4: ~95/100 The goal is not 100% compatibility, but capturing the essential Emacs workflow and feeling.