Commit e7164ec
committed
Rewrite ghostel-compile: spawn directly, add opt-in global mode
The old ghostel-compile typed its command into an already-running
interactive shell via `ghostel--flush-output'. That made every
embedded newline in a multi-line shell paragraph look like a RET
press, so scripts broke. It also tied completion detection to OSC 133
D markers, making shell-integration a hard requirement.
Spawn the command directly. Each invocation runs
`shell-file-name -c COMMAND' via `make-process' through a PTY owned
by the ghostel renderer — no shell between the command and the user.
Multi-line scripts pass through verbatim. The process sentinel
reports the real exit status, so shell-integration is no longer
required. The header ("Compilation started at ...") is written into
the VT terminal before spawn so the user sees the banner live, not
only after finalize. During the run the buffer stays plain
`ghostel-mode' — keystrokes reach the process, which is what makes
interactive programs like `htop', `less', or read prompts work.
When the process exits the sentinel flushes output, trims trailing
grid padding, appends the footer, parses errors over the run's own
output region, and switches the buffer to `ghostel-compile-view-mode'
(read-only, `g'/`n'/`p' bindings, standard error navigation).
Add `ghostel-compile-global-mode', an opt-in global minor mode that
advises `compilation-start' so every caller — `compile', `recompile',
`project-compile', and any other command that goes through
`compilation-start' — automatically runs in a ghostel buffer. Falls
through to the stock implementation for `grep-mode' (output-parser
conflict), `mode=t' (comint), and non-nil `continue' (append
semantics this design can't honour). The excluded set is
customisable via `ghostel-compile-global-mode-excluded-modes'.
`ghostel-recompile' now re-runs into the CURRENT buffer whenever it
holds a local `ghostel-compile--command' — so pressing `g' in a
`*compilation*' buffer (produced by the advice) reuses that buffer and
its window, matching `M-x recompile's behaviour. Previously it always
targeted `*ghostel-compile*', which produced a second unfocused window
side-by-side. `ghostel-compile--prepare-buffer' also resets the
buffer in place (interrupts the old process, erases content, rebuilds
the terminal) rather than killing and recreating it, so the existing
window stays attached across recompiles.
Other details worth noting:
- No more hot shell in `--prepare-buffer'. The previous version
routed through `ghostel--init-buffer' which spawns a shell and in
TRAMP buffers does a full remote-integration round-trip (uploads
temp files and plumbs env); we then killed it immediately, leaking
the remote temp files. Creates the terminal directly now.
- `ghostel--managed-buffer-name' is pinned to a sentinel so an OSC 2
title sequence from the compile command can't rename the buffer
mid-run.
- The scan marker anchors to the end of the rendered header — not
`point-max' of the post-render grid — so `--trim-trailing-blanks'
actually trims the VT grid's blank-row padding between output and
the footer (this padding scales with window height).
- Dropped customs/state that no longer apply: `ghostel-compile-mode'
(and its keymap + `--owns-compilation-minor-mode' flag),
`ghostel-compile-hide-prompts', `ghostel-compile-clear-buffer',
`ghostel-compile--on-start' and `--on-finish' (OSC 133 hooks), the
`--running' state machine, `--finalize-timer' gating, the
`--header-marker' / `--footer-marker' buffer-locals and the
`--clear-markers' helper, and a bash shell-integration exit-status
test.
Tests rewritten to match the new flow. End-to-end native test drives
`ghostel-compile--start' with a multi-line paragraph and asserts
output + exit status. Interactive-input test drives `cat' and asserts
keystrokes round-trip. Global-mode tests cover advice add/remove,
routing, and all three fall-through cases (grep-mode, mode=t,
continue, plus custom-excluded mode).1 parent 9846c64 commit e7164ec
3 files changed
Lines changed: 886 additions & 1003 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
476 | 483 | | |
477 | 484 | | |
478 | 485 | | |
| |||
481 | 488 | | |
482 | 489 | | |
483 | 490 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
488 | 496 | | |
489 | 497 | | |
490 | 498 | | |
| |||
499 | 507 | | |
500 | 508 | | |
501 | 509 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
512 | 519 | | |
513 | 520 | | |
514 | 521 | | |
| |||
538 | 545 | | |
539 | 546 | | |
540 | 547 | | |
541 | | - | |
542 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
543 | 567 | | |
544 | 568 | | |
545 | 569 | | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
558 | 577 | | |
559 | 578 | | |
560 | 579 | | |
| |||
0 commit comments