Skip to content

Fix stale [Compiling] modeline and copy-mode trap in ghostel-compile - #607

Merged
dakra merged 3 commits into
mainfrom
fix/compile-kill-and-copy-mode
Aug 7, 2026
Merged

dakra merged 3 commits into
mainfrom
fix/compile-kill-and-copy-mode

Conversation

@dakra

@dakra dakra commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Fixes #605.

Two bugs in compilation-style ghostel-compile buffers:

  1. Stale [Compiling] modeline: killing a compile buffer mid-run fired the sentinel with a dead buffer, which skipped the compilation-in-progress cleanup — the dead process stayed in the list and the global [Compiling] indicator stuck forever.
  2. Copy-mode trap under popper: the deferred point-leave check after the M-x ghostel-compile minibuffer exit fired in the popper-selected popup window and auto-entered copy mode (frozen terminal, no output). Exiting copy mode then restored ghostel-semi-char-mode-map, clobbering ghostel-compile-view-mode-map so C-p/C-n/RET were sent to the PTY until finalize.

One commit per fix:

  • Drain compilation-in-progress when the compile buffer dies mid-run: the sentinel now runs the cleanup in an unwind-protect cleanup form, mirroring stock compilation-sentinel (including its ordering: finalize before the delq, so finish hooks observe stock-compatible state).
  • Suppress automatic copy-mode entry in compilation-style buffers: the point-leave check and mark activation are gated on ghostel--inhibit-insert-forwarding, the existing compilation-style marker. Interactive compile runs (flag nil) keep auto-switching.
  • Restore compilation-style state when exiting copy or Emacs mode: new buffer-local ghostel--readonly-exit-function; when set, ghostel-readonly-exit delegates the post-exit restore to it and the *-and-send exits don't forward the triggering key. Compile buffers install ghostel-compile--restore-compilation-style (view keymap, read-only barrier, :run indicator, redraw-timer restart), set/cleared in lockstep with the inhibit flag through a shared setter. This also covers the remaining paths into copy mode there (explicit M-x ghostel-copy-mode, link follow).

Tests: 8 new (6 elisp, 2 native), including an end-to-end kill-mid-run test and an integration test that goes through ghostel-compile--start → ghostel-copy-mode → exit against the production wiring.

Verified live (Emacs 31, real popper 0.4.8): kill mid-run leaves no [Compiling]; with popper the compile popup opens in semi-char with output streaming and view keys bound; copy-mode exit restores the view state with no byte sent to the PTY.

@dakra
dakra force-pushed the fix/compile-kill-and-copy-mode branch from be69e25 to f0a7cb1 Compare August 6, 2026 16:28
dakra added 3 commits August 6, 2026 18:45
Killing a compile buffer kills its process and fires the sentinel
with a dead buffer, which skipped the compilation-in-progress
cleanup and left the global [Compiling] mode-line indicator stuck
forever.  Run the cleanup in an unwind-protect cleanup form,
mirroring stock compilation-sentinel (which also orders it after
the finalize, so finish hooks observe stock-compatible state).
A compilation-style compile buffer is a log, not a terminal input
surface, but the point-leave check (minibuffer exit, isearch end)
and mark activation still auto-entered copy mode there: point sits
away from the VT cursor by design, so e.g. popper selecting the
freshly created popup froze the terminal in copy mode before any
output rendered.  Gate both switches on
ghostel--inhibit-insert-forwarding, the existing compilation-style
marker.  Interactive compile runs keep the flag nil, so
auto-switching still works where the buffer behaves like a real
terminal.
Exiting a read-only mode always restored a terminal input mode and
its keymap; in a compilation-style compile buffer that clobbered
ghostel-compile-view-mode-map with ghostel-semi-char-mode-map, so
navigation keys were sent to the PTY until finalize.  Add
ghostel--readonly-exit-function: when non-nil, ghostel-readonly-exit
delegates the entire post-exit restore to it, and the *-and-send
exits skip forwarding the triggering key.  Compile buffers install
ghostel-compile--restore-compilation-style, which reinstates the
view keymap, the read-only barrier, and the :run indicator, and
restarts the frozen redraw timer.  The function is set and cleared
in lockstep with the insert-forwarding inhibit flag through a
shared setter.
@dakra
dakra force-pushed the fix/compile-kill-and-copy-mode branch from f0a7cb1 to ddee01b Compare August 6, 2026 16:45
@BrunodaSilvaBelo

BrunodaSilvaBelo commented Aug 6, 2026 •

Copy link
Copy Markdown

I forgot to mention, my emacs version is 32.0.50

@dakra
dakra merged commit ddee01b into main Aug 7, 2026
44 of 53 checks passed
@dakra
dakra deleted the fix/compile-kill-and-copy-mode branch August 7, 2026 06:32

This branch was previously deployed

1 inactive deployment
github-pages — ddee01b8 Deployed Aug 7, 2026 by dakra via deploy #150
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.

Killing compilation buffer before finishes mantain the [compiling] status in modeline and popper interation

2 participants