Something went wrong. Try again.
A rich, featureful, modern, Helix-inspired take on mg
Something went wrong. Try again.
Go 98%
Tree-sitter Query 1%
C <1%
Nix <1%
JavaScript <1%
<1%
Shell <1%
README.md
macroemacs #
Bar. An Emacs-flavored mouse TUI editor on Bubble Tea v2 and Flourish. Foo.
Features #
- Mouse editing. Click to move, drag to select, double-click to expand a word, right-click for a menu.
- Emacs prefix keymap with which-key hints.
- In-app picker for M-x, buffer switching, and file finding. A custom fuzzy + frecency ranker orders the results, so recently used items surface first. No external picker binary is needed.
- M-x command registry.
- Expand region with double-click, M-' and M-".
- Kill ring with cut, copy, and paste.
- Modeline status line.
- 15 statically compiled tree-sitter grammars.
Usage #
Start a dev shell:
nix develop
Run from the dev shell:
go run ./cmd/macroemacs [files...]
Build and run the release binary:
nix build
nix run . -- [files...]
Requirements:
- Nix with flake support.
Keybindings #
Top level:
| Key | Command | Description |
|---|---|---|
| C-g | keyboard-quit | Cancel prefix, prompt, or selection |
| C-space | set-mark-command | Start a selection at the cursor |
| C-z | undo | Undo |
| C-S-z | redo | Redo |
| C-k | kill-line | Delete to end of line |
| C-w | kill-region | Cut selection (or rest of line) |
| M-w | copy-region | Copy selection to kill ring |
| C-y | yank | Paste from kill ring |
| C-d | delete-char | Delete character forward |
| M-DEL | backward-kill-word | Kill word before cursor |
| M-d | kill-word | Kill word after cursor |
| M-' | expand-region | Expand region |
| M-" | expand-region | Expand region |
| M-x | execute-extended-command | Run a command by name |
| C-x | (prefix) | Enter the C-x prefix |
Movement:
| Key | Action |
|---|---|
| C-p / C-n | Previous / next line |
| C-f / C-b | Forward / backward character |
| M-f / M-b | Forward / backward word |
| M-< / M-> | Beginning / end of buffer |
| C-v / M-v | Page down / up |
| C-a / C-e | Beginning / end of line |
C-x prefix:
| Key | Command | Description |
|---|---|---|
| b | switch-to-buffer | Switch buffer |
| C-f | find-file | Find or create a file |
| C-s | save-buffer | Save the active buffer |
| k | kill-buffer | Close the active buffer |
| n | next-buffer | Switch to the next buffer |
| p | previous-buffer | Switch to the previous buffer |
| u | undo | Undo |
| C-c | save-buffers-kill-emacs | Quit, prompting if buffers are unsaved |
M-x commands #
Quit:
- keyboard-quit. Cancel prefix, prompt, or selection.
- save-buffers-kill-emacs. Quit, prompting if buffers are unsaved.
Mark:
- set-mark-command. Start a selection at the cursor.
Kill ring:
- kill-region. Cut selection (or rest of line).
- copy-region. Copy selection to the kill ring.
- yank. Paste the top of the kill ring.
Editing:
- kill-line. Delete from cursor to end of line.
- kill-whole-line. Delete the whole line.
- backward-kill-word. Kill the word before the cursor.
- kill-word. Kill the word after the cursor.
- delete-char. Delete the character after the cursor.
- undo. Undo the last change.
- redo. Redo the last undone change.
Movement:
- previous-line / next-line. Move up / down one line.
- forward-char / backward-char. Move right / left one character.
- forward-word / backward-word. Move forward / backward one word.
- forward-paragraph / backward-paragraph. Move down / up one paragraph.
- beginning-of-line / end-of-line. Move to the line start / end.
- beginning-of-buffer / end-of-buffer. Move to the buffer start / end.
- scroll-up / scroll-down. Page down / up by one viewport.
Selection:
- select-word. Select the word at the cursor.
- select-line. Select the line containing the cursor.
- select-paragraph. Select the paragraph containing the cursor.
- select-all. Select the whole buffer.
- expand-region. Expand word, line, paragraph, then buffer.
Buffers:
- next-buffer. Switch to the next buffer.
- previous-buffer. Switch to the previous buffer.
- switch-to-buffer. Switch buffers with the picker.
- kill-buffer. Close the active buffer.
Files:
- find-file. Open or create a file with the picker.
- save-buffer. Save the active buffer to disk.
Commands:
- execute-extended-command. Run a command by name.
Grammars #
13 grammars come from Go modules:
- bash, css, dart, diff, go, html, javascript, json, lua, python, rust, toml, yaml
Markdown and nix grammars come from nix derivations in nix/grammars.nix. Their C sources are compiled into the binary by cgo. The derivations rename parser.c and scanner.c to markdown_parser.c, markdown_scanner.c, nix_parser.c, and nix_scanner.c. The Go bindings in internal/tsgrammars include them by those names.
A build outside the dev shell needs CGO_CFLAGS. Set CGO_ENABLED=1 and CGO_CFLAGS with -I flags for the grammar source directories.
Architecture #
- cmd/macroemacs. The entry point.
- internal/app. Model, mouse handling, and view.
- internal/buffers. Buffer management.
- internal/commands. The command registry.
- internal/keymap. The nested prefix keymap tree: chords map to nested prefixes or leaf command names, resolved through the command registry.
- internal/rank. Fuzzy matching and frecency ranking with persistence.
- internal/picker. The in-app selection UI used by M-x, buffer switching, and file finding.
- internal/modeline. Status line.
- internal/expand. Expand region logic.
- internal/killring. Kill ring.
- internal/tsgrammars. Tree-sitter grammar bindings.