Commit 5280db2
committed
Add ghostel-compile and ghostel-recompile
Adds compile.el-style integration on top of ghostel: `M-x
ghostel-compile' runs a shell command in a ghostel terminal buffer
and presents the result like `M-x compile' — header, footer,
error highlighting, and `next-error' navigation — but backed by a
real TTY so programs that probe `isatty(3)' (coloured output,
progress bars, curses tools) behave as they do in a normal shell.
Architecture:
- `ghostel-command-start-functions' / `ghostel-command-finish-
functions' hooks expose OSC 133 C / D semantic prompt markers
from the parser. `ghostel-compile' uses both to track a
pending → armed → fired state machine so that prompt redraws
(which can emit a stale D) don't get treated as the user
command's exit.
- `ghostel-compile-mode' (minor) wires the OSC 133 hooks into a
live ghostel buffer. When the user's command finishes the
shell process and ghostel renderer are torn down, header and
footer text are inserted (matching compile.el byte-for-byte),
the buffer's major mode is switched to a new
`ghostel-compile-view-mode' (derived from `compilation-mode'),
and `compilation--ensure-parse' populates the error list. The
buffer becomes a regular read-only Emacs buffer that never
transitions back to an interactive terminal — recompile
discards it and starts fresh.
- `mode-line-process' shows :run / :exit [N] using the same
`compilation-mode-line-{run,exit,fail}' faces `M-x compile'
uses.
Compile parity:
- `compile-command' / `compile-history' shared with \[compile]
- `compilation-read-command' (prefix arg forces the prompt)
- `compilation-ask-about-save'
- `compilation-auto-jump-to-first-error'
- `compilation-finish-functions'
Ghostel-specific options: `ghostel-compile-buffer-name',
`ghostel-compile-finished-major-mode',
`ghostel-compile-hide-prompts', `ghostel-compile-clear-buffer',
`ghostel-compile-finish-functions', `ghostel-compile-debug'.
Keys in the finished view-mode buffer:
g - ghostel-recompile
n / p - compilation-next-error / -previous-error
RET / mouse-2 - compile-goto-error
M-g n / M-g p - standard next-error / previous-error
Recompile preserves the original `default-directory' (captured at
`ghostel-compile' invocation) so pressing `g' from any buffer
re-runs the command in the right directory.
Bash integration fix: the PROMPT_COMMAND wrapper in
`etc/ghostel.bash' captures `$?' on its first line via
`local $?'. The previous code began with the bare assignment
`__ghostel_in_prompt_command=1' which resets `$?' to 0 in bash,
so OSC 133 D always carried 0 and any consumer reported `:exit
[0]' for every command.
107 new ERT tests across the elisp test suite cover the hook
plumbing, the view-mode switch, error parsing without double
counting, header/footer insertion, prompt hiding, the C-gating
state machine, the bash integration round-trip, default-directory
preservation, and shared `compile-command' / `compile-history'
behaviour.1 parent bfb6e7c commit 5280db2
6 files changed
Lines changed: 1793 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
460 | 565 | | |
461 | 566 | | |
462 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 20 | | |
26 | 21 | | |
27 | 22 | | |
| |||
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | | - | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
0 commit comments