Conversation
77eed19 to
b8f77e9
Compare
b8f77e9 to
8f75b24
Compare
|
Dear Jen-Chieh (@jcs090218), A brief note on the history of this PR, since the force-push hides it:
Yours, Andrea |
…aces docs: theming the gutter column background
|
I forked this repository to alberti42/fork-git-gutter, where I reviewed and merged the 11 pull requests that were open here, the oldest from 2021, and fixed what they still needed. Many of them add real value, and it was a pity to see them sitting here, each on its own branch, while nobody could use them together. The last release here was 0.93 in September 2024, and no pull request from a contributor has been merged since December 2024. Many people use git-gutter in their daily work; the fork gives them a place to send issues and fixes, so that everyone gets them. The fork has released 0.94.0, and I hope to become a co-maintainer of this repository and bring the work back here. This is now merged into the fork (alberti42/fork-git-gutter@55cd451, alberti42/fork-git-gutter@ec7d71b) and released in 0.94.0. |
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.