Skip to content

Honor compilation-scroll-output in ghostel-compile - #600

Merged
dakra merged 2 commits into
mainfrom
feat/compilation-scroll-output
Aug 4, 2026
Merged

dakra merged 2 commits into
mainfrom
feat/compilation-scroll-output

Conversation

@dakra

@dakra dakra commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Fixes #599.

ghostel-compile buffers always followed the live output — the buffer stays in ghostel-mode during the run and its windows are re-anchored to the tail on every redraw. compilation-scroll-output now controls this for compilation-style runs, making ghostel-compile a drop-in for M-x compile here too (as suggested by @emil-e in the issue):

  • nil (default): the window stays at the top of the output — a buffer-local ghostel-compile--anchor-inhibit entry on ghostel-inhibit-anchor-functions vetoes output-following, point and window-start are parked at the top like compilation-start does, and finalize leaves point alone. Note this changes the previous always-scroll default; set compilation-scroll-output to t to keep the old behavior.
  • first-error: follows the output during the run; at finalize point lands on the first error message in the compile buffer and the window recenters on it (tail when the run had no errors). The finalize branch also re-establishes the window start — the sentinel-time tail anchor leaves a forced window-start pending, and the next redisplay would otherwise clamp a bare set-window-point back into the tail view. The error search starts one char before the scan marker because compilation-next-error skips a message point is already on.
  • other non-nil: unchanged — follow during the run, tail past the footer at finalize.

Interactive runs (C-u M-x ghostel-compile, MODE=t under the global mode) always follow the live cursor, and C-c C-j now bottom-anchors the window when toggling to interactive mid-run.

evil-ghostel's insert/emacs-state cursor drag (evil-ghostel--around-redraw) is gated on the same veto hook, so it no longer pulls point to the terminal cursor in a nil-scroll compile buffer; its own veto entry returns nil in insert state, so plain terminals are unaffected.

Tests: finalize matrix for all three values (plus interactive-tails and error-at-scan-start edge cases), veto installation across the recompile reuse path, and an end-to-end nil-scroll run keeping point at the top. Also verified live (terminal Emacs, non-selected compile window): nil / t / first-error / interactive, and the evil-ghostel scenarios including normal-state roaming regression guards.

dakra added 2 commits August 4, 2026 23:29
ghostel-compile buffers always followed the live output: the buffer
stays in ghostel-mode during the run and its windows are re-anchored
to the tail on every redraw.  Users coming from M-x compile expect
compilation-scroll-output to control this instead.

Honor the option for compilation-style runs: a new buffer-local
ghostel-compile--anchor-inhibit entry on ghostel-inhibit-anchor-functions
vetoes output-following while the option is nil, with point and
window-start parked at the top of the buffer like compilation-start
does, and finalize leaves point alone.  first-error follows the output
during the run and at finalize lands point on the first error message
in the compile buffer, re-establishing the window start so the
sentinel-time tail anchor's pending forced start cannot clamp it back;
the search begins one char before the scan start because
compilation-next-error skips a message point is already on.  Other
non-nil values keep the previous tail behavior.  Interactive runs (and
the C-c C-j toggle, which now bottom-anchors the window on switch)
always follow the live cursor.

evil-ghostel's insert/emacs-state cursor drag follows the same veto
hook, so it no longer pulls point to the terminal cursor in a
nil-scroll compile buffer.

Fixes #599
A child's exit is recorded asynchronously by SIGCHLD and becomes
visible to process-live-p on read, but sentinels only run inside
accept-process-output.  When the exit landed between one accept call
and the loop's liveness check, the wait failed before the sentinel
could satisfy the predicate — a race that hits hardest for children
that exit without trailing output (no output event pulls the status
change into an accept call), e.g. the raw-mode echo-guard test's
one-byte dd.

When the loop exits with the process dead and the predicate still
false, drain events for up to a second so sentinel-driven predicates
get their chance before the wait fails.
@dakra
dakra merged commit 963f37f into main Aug 4, 2026
28 of 29 checks passed
@dakra
dakra deleted the feat/compilation-scroll-output branch August 4, 2026 22:08

This branch was previously deployed

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

Add a ghostel-compilation-scroll-output option similar to compilation-scroll-output

1 participant