Skip to content

Add eat.el-like input modes (char, emacs, mode switching)#65

Open
dakra wants to merge 1 commit intomainfrom
worktree-input-modes
Open

Add eat.el-like input modes (char, emacs, mode switching)#65
dakra wants to merge 1 commit intomainfrom
worktree-input-modes

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented Apr 9, 2026

Summary

Implements four input modes inspired by eat.el, addressing #40:

  • Semi-char (default): most keys go to terminal, C-c prefix reserved for Emacs
  • Char (C-c M-d): all keys sent to terminal, M-RET sole escape hatch
  • Copy (C-c C-t): frozen viewport for text selection (existing, unchanged)
  • Emacs (C-c C-e): full scrollback loaded as read-only Emacs buffer (isearch, occur, etc.)

C-c C-j returns to semi-char from any mode. Typing a character in copy/emacs mode auto-switches to semi-char and sends the key.

Architecture changes

  • Split ghostel-mode-map into base (C-c prefix only) + ghostel-semi-char-mode-map (terminal bindings, parent inheritance)
  • New ghostel-char-mode-map (captures everything) and ghostel-emacs-mode-map (minimal, falls through to Emacs)
  • Replace ghostel--copy-mode-active / ghostel--copy-mode-full-buffer with single ghostel--input-mode state variable
  • ghostel-copy-mode-load-all now switches to emacs mode (full scrollback = emacs mode)
  • Extract ghostel--define-terminal-keys / ghostel--define-mouse-keys helpers to share bindings
  • Move clear-scrollback from C-c C-l to C-c M-l (reserving C-c C-l for future line mode)

Line mode

Line mode (comint-like live terminal with editable input area) is planned as a separate follow-up PR due to its complexity.

Test plan

  • All 48 existing tests pass
  • Clean byte-compile (no warnings)
  • Manual: M-x ghostel, verify semi-char works as before
  • Manual: C-c M-d enters char mode, all keys go to terminal, M-RET exits
  • Manual: C-c C-e enters emacs mode, full scrollback loads, isearch works, q exits
  • Manual: C-c C-t enters copy mode, C-c C-e from copy switches to emacs
  • Manual: mode-line shows :Char, :Copy, :Emacs indicators
  • Manual: C-c C-j returns to semi-char from all modes

Closes #40

Implement four input modes inspired by eat.el (issue #40):

- Semi-char (default): most keys go to terminal, C-c prefix reserved
- Char (C-c M-d): all keys sent to terminal, M-RET to exit
- Copy (C-c C-t): frozen viewport for text selection (existing)
- Emacs (C-c C-e): full scrollback loaded as read-only Emacs buffer

Architecture changes:
- Split ghostel-mode-map into base (C-c prefix) + ghostel-semi-char-mode-map
  (terminal bindings with parent inheritance)
- Replace ghostel--copy-mode-active/ghostel--copy-mode-full-buffer with
  single ghostel--input-mode state variable
- Extract ghostel--define-terminal-keys and ghostel--define-mouse-keys
  helpers to share bindings across semi-char and char keymaps
- Refactor copy-mode-load-all to switch to emacs mode
- Add ghostel--frozen-p / ghostel--full-scrollback-p predicates
- Move clear-scrollback binding from C-c C-l to C-c M-l
- C-c C-j returns to semi-char from any mode
@dakra dakra force-pushed the worktree-input-modes branch from 4db55ec to 82255fe Compare April 9, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project plans in relation to eat.el-like input modes

1 participant