ghostel-compile: trim trailing blank grid rows#112
Merged
Conversation
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.
04435eb to
d72751e
Compare
…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.
364c9c0 to
a7139d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Short commands like
echo testleft ~24 rows of trailing spaces/newlines in the compile buffer (the unused terminal grid), wedging the footer far below the real output. Matches whatM-x compileproduces.Before
After
Implementation
New helper
ghostel-compile--trim-trailing-blankscalled between--hide-promptsand--teardown-terminal. Skips back frompoint-maxover" \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
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.ghostel-compiletests still pass (116 elisp + 30 evil).