Skip to content

evil-ghostel: follow terminal cursor in emacs-state#135

Merged
dakra merged 1 commit intodakra:mainfrom
Cianidos:fix/follow-cursor-in-emacs-state
Apr 18, 2026
Merged

evil-ghostel: follow terminal cursor in emacs-state#135
dakra merged 1 commit intodakra:mainfrom
Cianidos:fix/follow-cursor-in-emacs-state

Conversation

@Cianidos
Copy link
Copy Markdown
Contributor

Problem

evil-ghostel--around-redraw freezes point in every evil state except
insert, so entering emacs-state (the vanilla-Emacs escape hatch,
typically reached via C-z) leaves the cursor stuck wherever it was
when the state changed while the TUI keeps redrawing elsewhere. The
TUI's own rendered cursor (e.g. Claude Code's white prompt block)
moves, but Emacs's point doesn't, so cursor-sensitive operations and
on-screen feedback go out of sync.

Insert-state is the "follow cursor" state today — and emacs-state has
the same expectation from the user's perspective: it means "turn evil
off and behave like vanilla", which in a terminal context should mean
"follow the terminal cursor".

Reproduction

In any ghostel buffer with evil-ghostel-mode active, press C-z
to enter emacs-state. The Emacs cursor stays frozen while the
terminal keeps updating; moving the point manually is the only way
to "unstick" it. Switching back to insert-state re-enables the sync.

Fix

  • Broaden the evil-ghostel--around-redraw freeze-exclusion from
    (not (eq evil-state 'insert)) to
    (not (memq evil-state '(insert emacs))) so redraws move point to
    the terminal cursor in both states.
  • Add evil-ghostel--insert-state-entry to evil-emacs-state-entry-hook
    so switching into emacs-state syncs point immediately, matching the
    behaviour already in place for insert-state.

Includes a regression test
(evil-ghostel-test-redraw-moves-point-emacs-state) that enters
emacs-state, moves point away from the terminal cursor, forces a
redraw, and asserts point snaps back to the cursor column. Verified
to fail against upstream/main and pass on this branch.

@dakra dakra force-pushed the fix/follow-cursor-in-emacs-state branch from 36f9d34 to a67cf2b Compare April 18, 2026 21:53
emacs-state is evil's vanilla-Emacs escape hatch; users expect it to
behave like a normal terminal, which means point should track the
terminal cursor just like in insert-state.  Extend the around-redraw
freeze-exclusion and the state-entry sync hook to cover both states.
@dakra dakra force-pushed the fix/follow-cursor-in-emacs-state branch from a67cf2b to f05e0db Compare April 18, 2026 21:57
@dakra dakra merged commit f05e0db into dakra:main Apr 18, 2026
14 checks passed
@dakra
Copy link
Copy Markdown
Owner

dakra commented Apr 18, 2026

Thanks

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.

2 participants