DIY Make diffs use only a foreground
This is one of our practical examples to override the semantic colors of the Modus themes (Stylistic variants using palette overrides). In this section we show how to change diff buffers (e.g. in magit) to only use color-coded text without any added background. What we basically do is to disable the applicable backgrounds and then intensify the foregrounds. Since the deuteranopia-optimized themes do not use the red-green color coding, we make an extra set of adjustments for them by overriding their palettes directly instead of just using the “common” overrides.
emacs-lisp
;; Diffs with only foreground colors. Word-wise ("refined") diffs
;; have a gray background to draw attention to themselves.
(setq modus-themes-common-palette-overrides
'((bg-added unspecified)
(bg-added-faint unspecified)
(bg-added-refine bg-inactive)
(fg-added green)
(fg-added-intense green-intense)
(bg-changed unspecified)
(bg-changed-faint unspecified)
(bg-changed-refine bg-inactive)
(fg-changed yellow)
(fg-changed-intense yellow-intense)
(bg-removed unspecified)
(bg-removed-faint unspecified)
(bg-removed-refine bg-inactive)
(fg-removed red)
(fg-removed-intense red-intense)
(bg-diff-context unspecified)))
;; Because deuteranopia cannot use the typical red-yellow-green
;; combination, we need to arrange for a yellow-purple-blue sequence.
;; Notice that the above covers the "common" overrides, so we do not
;; need to reproduce the whole list of them.
(setq modus-operandi-deuteranopia-palette-overrides
'((fg-added blue)
(fg-added-intense blue-intense)
(fg-changed magenta-cooler)
(fg-changed-intense magenta-intense)
(fg-removed yellow-warmer)
(fg-removed-intense yellow-intense)))
(setq modus-vivendi-deuteranopia-palette-overrides
'((fg-added blue)
(fg-added-intense blue-intense)
(fg-changed magenta-cooler)
(fg-changed-intense magenta-intense)
(fg-removed yellow)
(fg-removed-intense yellow-intense)))Reload the theme for changes to take effect.