docs: theming the gutter column background#247
Open
alberti42 wants to merge 1 commit into
Open
Conversation
77eed19 to
b8f77e9
Compare
b8f77e9 to
8f75b24
Compare
Author
|
Dear Jen-Chieh (@jcs090218), A brief note on the history of this PR, since the force-push hides it:
Yours, Andrea |
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
This PR adds a new section to the README, "Theming the gutter column
background", explaining how to make git-gutter's gutter column blend
visually with the line-number column used by modern Emacs themes. It
documents both the recommended approach on Emacs 31.1+ (using the new
marginface) and the fallback approach for Emacs ≤30.x.Motivation
Many popular themes, including the built-in
modus-operandiandmodus-vivendi, give the line-number column a distinct background color.git-gutter draws its change indicators next to that column, so without
coordination the result is a visually broken gutter: diff-indicator rows
have one background, while unchanged rows bleed through to the default
frame or terminal background.
How this is fixed differs sharply by Emacs version:
marginbasic face(bug #80693).
The display engine fills every empty margin cell with this face's
background automatically — no git-gutter configuration needed. This is
also cheap on large files.
marginface does not exist, so the only way tofill empty cells is to force git-gutter to write something into them
via
git-gutter:unchanged-signorgit-gutter:separator-sign, then setthe corresponding face backgrounds. This works but installs an overlay
on every line of the buffer, which becomes prohibitive on very large
files.
Both paths share the same root issue — the reserved-but-unwritten margin
cell — but the user-facing recommendation is different, and the older path
should now be presented as a fallback rather than the default advice.
A personal note on why this documentation matters
Tracking down the root cause took me an embarrassingly long time. The
symptom, a visually inconsistent gutter column, looked like a bug in how
git-gutter applies faces to the left margin in terminal frames. I went
down the wrong path: I suspected that TTY rendering was silently dropping
symbolic face backgrounds, wrote a workaround that resolved faces eagerly
before passing them to the display engine, and spent considerable time
debugging Emacs's C display code to confirm or refute the hypothesis.
None of that was needed. The actual cause is a subtle but simple gotcha:
git-gutter:window-widthreserves a column for every buffer, but cellson unchanged rows are never written unless a sign is configured for
them. An unwritten cell falls back to the default frame background,
regardless of any face setting. Hopefully this section saves someone
else those hours.
The investigation also led to upstream bug #80693, which introduces the
marginface that now makes the fix one line on Emacs 31.1+.What the documentation covers
marginface; asnippet to derive it from
line-numberautomatically.avoided on large files, and how to get a visual gap between the gutter
and buffer text by widening
git-gutter:window-widthinstead.content, clearly labeled as version-gated.
History
The original commit covered only the ≤30.x approach. After the
marginface landed upstream in May 2026 it became the recommended path; the PR
has been force-pushed with a single revised commit and this PR description
was correspondingly updated, since the branch has not yet been reviewed.