Skip to content

ghostel-compile: trim trailing blank grid rows#112

Merged
dakra merged 3 commits intomainfrom
ghostel-compile-trim-blanks
Apr 15, 2026
Merged

ghostel-compile: trim trailing blank grid rows#112
dakra merged 3 commits intomainfrom
ghostel-compile-trim-blanks

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented Apr 15, 2026

Summary

Short commands like echo test left ~24 rows of trailing spaces/newlines in the compile buffer (the unused terminal grid), wedging the footer far below the real output. Matches what M-x compile produces.

Before

-*- mode: ghostel-compile -*-
Compilation started at …

echo test

test
(many blank lines)

Compilation finished at …, duration …

After

-*- mode: ghostel-compile -*-
Compilation started at …

echo test

test

Compilation finished at …, duration …

Implementation

New helper ghostel-compile--trim-trailing-blanks called between --hide-prompts and --teardown-terminal. Skips back from point-max over " \t\n" in the scan region, deletes whatever's left, and leaves a single trailing newline. The footer's own leading newline then produces a blank separator line between output and footer.

Test plan

  • New ghostel-test-compile-finalize-trims-trailing-blank-rows — seeds 20 blank grid rows after a short output line; asserts the gap between the output and the footer has ≤2 newlines. Verified to fail without the fix.
  • All existing ghostel-compile tests still pass (116 elisp + 30 evil).

dakra added 2 commits April 15, 2026 22:02
The ghostel renderer commits the full terminal grid to the buffer,
so a short command like `echo test' leaves ~24 rows of trailing
spaces and newlines — visually wedging the footer far below the
real output.  `M-x compile' doesn't have this problem because it
only inserts what the subprocess actually writes.

Add `ghostel-compile--trim-trailing-blanks' and call it between
hide-prompts and the major-mode switch.  It skips back from
`point-max' over any whitespace/newlines in the scan region and
deletes whatever's left, replacing it with a single trailing
newline.  The footer's own leading newline then produces a blank
separator line between output and footer, matching `M-x compile'.

Regression test `finalize-trims-trailing-blank-rows' seeds ~20
blank grid rows after a short output line and asserts the gap
between the output and the footer has at most two newlines.

Fixes #111
Match the convention of \[recompile]: `ghostel-recompile' now
takes an optional EDIT-COMMAND argument.  Interactively it's bound
to the prefix arg, so `C-u g' in the view-mode buffer prompts for
the command with the last-run command as the default, using
`compile-history' for history cycling.  The chosen command is
written back to `compile-command' (same as `ghostel-compile')
so it round-trips with \[compile].

Plain `g' (no prefix) still re-runs the last command verbatim.
@dakra dakra force-pushed the ghostel-compile-trim-blanks branch from 04435eb to d72751e Compare April 15, 2026 20:03
…on drift

The exact text boundary where `compile.el' puts
`compilation-line-number' / `compilation-error' face properties
has wobbled across Emacs versions (29.4 / snapshot vs. what I
test locally).  The previous test pinned a single position, so it
was flaky on CI even though parsing itself was working correctly.

Rewrite the test to scan the entire line-number and file-name
match regions for the expected properties, so it tolerates small
face-boundary changes without pretending a regression.
@dakra dakra force-pushed the ghostel-compile-trim-blanks branch from 364c9c0 to a7139d5 Compare April 15, 2026 20:10
@dakra dakra merged commit a7139d5 into main Apr 15, 2026
20 checks passed
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.

1 participant