Skip to content

DIY Make inline code in prose use alternative styles

This is one of our practical examples to override the semantic colors of the Modus themes (Stylistic variants using palette overrides). In the following code block we show how to affect constructs such as Org’s verbatim, code, and macro entries. We also provide mappings for tables, property drawers, tags, and code block delimiters, though we do not show every possible permutation.

emacs-lisp
;; A nuanced accented background, combined with a suitable foreground.
(setq modus-themes-common-palette-overrides
      '((bg-prose-code bg-green-nuanced)
        (fg-prose-code green-cooler)

        (bg-prose-verbatim bg-magenta-nuanced)
        (fg-prose-verbatim magenta-warmer)

        (bg-prose-macro bg-blue-nuanced)
        (fg-prose-macro magenta-cooler)))

;; A more noticeable accented background, combined with a suitable foreground.
(setq modus-themes-common-palette-overrides
      '((bg-prose-code bg-sage)
        (fg-prose-code green-faint)

        (bg-prose-verbatim bg-ochre)
        (fg-prose-verbatim red-faint)

        (bg-prose-macro bg-lavender)
        (fg-prose-macro blue-faint)))

;; Leave the backgrounds without a color and simply make the foregrounds more intense.
(setq modus-themes-common-palette-overrides
      '((bg-prose-code unspecified)
        (fg-prose-code green-intense)

        (bg-prose-verbatim unspecified)
        (fg-prose-verbatim magenta-intense)

        (bg-prose-macro unspecified)
        (fg-prose-macro cyan-intense)))

Reload the theme for changes to take effect.