Rewrite evil-ghostel from advice to command-remap architecture#264
Rewrite evil-ghostel from advice to command-remap architecture#264dakra wants to merge 1 commit into
Conversation
|
@dakra Thanks a lot. I didn't have time to test thoroughly. I'll test tomorrow but couldn't find any major problems with basic use. Here are two things:
|
872b853 to
fc7f17f
Compare
|
@noctuid Thanks. I fixed the 2 bugs you mentioned. |
fc7f17f to
4228dc0
Compare
|
I still haven't seen any more issues with editing/operators, though I'm seeing similar issues to the appending one. Sometimes the cursor will jump to the right side of the window when appending.
I saw weird point warping a couple of times but can't reliably reproduce. |
Replaces ~13 advice-add hooks on evil-* commands with proper evil-define-operator / evil-define-motion definitions bound via evil-ghostel-mode-map for normal and visual states. Adds a public input-region API in ghostel core that integrations can build on. ghostel.el (new public API): - ghostel-input-start-point, ghostel-cursor-point, ghostel-cursor-row-end-point (strips trailing whitespace so renderer padding doesn't count as input) - ghostel-point-on-cursor-row-p, ghostel-point-in-input-p - ghostel-clamp-to-input — trims an operator's range to the live input region. Clamps END to row-end on forward overshoot so dw on the last input word no longer over-deletes into blank renderer rows below the prompt - ghostel-goto-input-position — moves the terminal cursor via arrow keys, with vterm-style recovery for literal ^[[C echo and bash-autosuggest accept-on-right-arrow - ghostel-delete-input-region, ghostel-replace-input-region evil-ghostel.el: - New commands: evil-ghostel-delete, -delete-line, -delete-char, -delete-backward-char, -change, -change-line, -substitute, -substitute-line, -replace, -paste-after, -paste-before, -insert, -insert-line, -append, -append-line, -beginning-of-line, -first-non-blank, -forward-word-begin/-WORD-begin/-word-end/-WORD-end, -undo, -redo - Bound in evil-ghostel-mode-map; forward-word motions are normal-only so operator-pending (dw, cw) uses vanilla motion + operator clamp - Drops the shadow-cursor model and all advice on evil-* commands. Keeps advice on ghostel--redraw / ghostel--set-cursor-style and the insert-state-entry hook (essential plumbing) - Lifts evil-ghostel--cursor-to-point / --delete-region / --meaningful-length into ghostel core as the public API Tests: - 16 new ghostel-core API tests - 4 new evil-ghostel regression tests covering the dw-overshoot bug and the w-stays-on-input-row behavior - Existing tests updated to call evil-ghostel-* directly and mock ghostel-goto-input-position instead of the removed internals Net: 370 elisp + 173 native + 76 evil-ghostel tests pass.
4228dc0 to
22ae308
Compare
Summary
advice-addhooks onevil-*commands withevil-define-operator/evil-define-motiondefinitions bound viaevil-ghostel-mode-mapfor normal and visual states (vterm-collection-style).ghostel.el(ghostel-input-start-point,ghostel-cursor-point,ghostel-cursor-row-end-point,ghostel-point-on-cursor-row-p,ghostel-point-in-input-p,ghostel-clamp-to-input,ghostel-goto-input-position,ghostel-delete-input-region,ghostel-replace-input-region) that integrations can build on. Lifts what was internalevil-ghostel--cursor-to-point/--delete-region/--meaningful-lengthinto ghostel core.ghostel--cursor-posdirectly each call and the existingsync-inhibitflag already covers the double-call scenarios the shadow was defending against.dwon the last input word no longer over-deletes into the blank renderer rows below the prompt. End-of-typed-input is detected by stripping trailing whitespace on the cursor row; works for shells without OSC 133.w,W,e,E) clamped in normal state only sowfrom the last input word stays on the cursor row. Operator-pending state uses vanilla motions sodw/cwranges can overshoot and get trimmed by the operator clamp.ghostel-goto-input-positionincludes vterm-style recovery for literal^[[Cecho (inner program doesn't interpret arrow keys) and for bash-autosuggest accept-on-right-arrow.Test plan
make -j4 all test-evilclean: 370 elisp + 173 native + 76 evil-ghostel tests, 0 unexpected, 2 unrelated skips, lint clean.evil-ghostel-test-delete-word-on-last-word-clamps-overshoot), w-stays-on-input-row (evil-ghostel-test-forward-word-stops-at-input-end), w-falls-through-in-scrollback (evil-ghostel-test-forward-word-falls-through-off-cursor-row).Emacs -Qagainstzsh -fi(no OSC 133):word word word<esc>bbcw→ correct,wstays on cursor row,dwon last word deletes it,0/^/$work.bbcw3× consecutively in zsh and pi to confirm no regressions.Notes for reviewers
evil-ghostel.elends up at 852 LOC vs evil-collection-vterm's 308. The delta is dominated byevil-ghostel--around-redraw(79 LOC — ghostel's renderer wipes the viewport region, vterm doesn't need this), the cursor↔point sync helpers (~50 LOC — viewport-row math), the insert-state-entry hook (45 LOC — vterm's cursor is the buffer cursor), and the three-way ESC routing (auto/terminal/evil).ghostel-*input-region functions become public contract.