Skip to content

Switch input mode when point leaves the live input point#428

Merged
dakra merged 1 commit into
mainfrom
feat/auto-leave-on-point-move
Jun 20, 2026
Merged

Switch input mode when point leaves the live input point#428
dakra merged 1 commit into
mainfrom
feat/auto-leave-on-point-move

Conversation

@dakra

@dakra dakra commented Jun 20, 2026

Copy link
Copy Markdown
Owner

What

The keyboard analog of the existing mouse/mark mode-switch: in semi-char mode, when point moves off the live terminal cursor, ghostel switches to a read-only mode (ghostel-point-leave-input-mode, default copy) so the navigated position is stable instead of the next redraw yanking point back to the prompt.

Details

  • New defcustom ghostel-point-leave-input-mode (copy/emacs/nil), a sibling of ghostel-mouse-drag-input-mode and ghostel-mark-activation-input-mode.
  • New public command ghostel-maybe-leave-input — a no-op unless point has left the live cursor in semi-char; ignores its args so it works as a hook function or :after advice.
  • Wired into isearch-mode-end-hook and (deferred) minibuffer-exit-hook (covers consult-line and other minibuffer jumps). Packages with no hook of their own (avy, flash) add ghostel-maybe-leave-input themselves — documented in the README.
  • The deferred minibuffer-exit re-anchor now skips copy/Emacs buffers, so a minibuffer jump that switched modes isn't snapped back to the live cursor; semi-char/char/line still re-anchor as before. The guard lives on the auto-follow path rather than in ghostel--anchor-window, which intentionally anchors Emacs mode for deliberate input like paste (covered by ghostel-test-emacs-mode-yank-scrolls-to-live-cursor).

Testing

  • New ERT tests in ghostel-modes-test.el; make -j8 all green.
  • Live-verified under elate (real shell in a ghostel buffer) across both copy and emacs targets for isearch, consult-line (deep + near-bottom), avy, and flash, plus the no-false-positive typing path.

README and CHANGELOG updated.

Comment thread lisp/ghostel.el Outdated
(dolist (entry anchored)
(let ((win (car entry))
(buffer (cdr entry)))
;; Guard lives here, not in `ghostel--anchor-window',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it maybe is still better to have this guard in ghostel--anchor-window? Then it won't get triggered in the redraw path also, and we can remove that specific guard there. We could then maybe have a force parameter for the places where we explicitly want to anchor, such as input.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@dakra
dakra force-pushed the feat/auto-leave-on-point-move branch from c1bb2cf to 77f97cd Compare June 20, 2026 19:17
The keyboard analog of the mouse/mark mode-switch: in semi-char mode,
when point moves off the live terminal cursor, switch to a read-only
mode so the navigated position is stable instead of the next redraw
yanking point back to the prompt.

- Add `ghostel-point-leave-input-mode' (copy default, emacs, or nil)
  and the public command `ghostel-maybe-leave-input'.
- Wire it into `isearch-mode-end-hook' and (deferred) `minibuffer-exit-hook'
  (consult-line and other minibuffer jumps).  Other jump packages with
  no hook (avy, flash) add it as a hook or `:after' advice.
- Guard the minibuffer-exit re-anchor so it skips copy/Emacs buffers,
  keeping a jump target from being snapped back to the live cursor;
  semi-char/char/line still re-anchor as before.

Tests in ghostel-modes-test.el; README and CHANGELOG updated.
@dakra
dakra force-pushed the feat/auto-leave-on-point-move branch from 77f97cd to 98ae769 Compare June 20, 2026 19:33
@dakra
dakra merged commit 98ae769 into main Jun 20, 2026
19 checks passed
@dakra
dakra deleted the feat/auto-leave-on-point-move branch June 20, 2026 19:34
@dakra
dakra temporarily deployed to github-pages June 20, 2026 19:35 — with GitHub Actions Inactive
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