Skip to content

DIY Make use of alternative styles for code syntax

This is one of our practical examples to override the semantic colors of the Modus themes (Stylistic variants using palette overrides). The idea here is to change how named colors are mapped to code syntax. Each of the following snippets give the modus-themes a different feel while editing code.

Note that my modus-themes and ef-themes do not use the same palettes, so some things are different. If you copy from the latter to the former, double-check that the entries exist in the given Modus theme palette.

Make comments yellow and strings green.

Make code syntax use the old alt-syntax style.

emacs-lisp
;; Mimic `ef-night' theme (from my `ef-themes') for code syntax
;; highlighting, while still using the Modus colors (and other
;; mappings).
(setq modus-themes-common-palette-overrides
      '((builtin green-cooler)
        (comment yellow-faint)
        (constant magenta-cooler)
        (fnname cyan-cooler)
        (keyword blue-warmer)
        (preprocessor red-warmer)
        (docstring cyan-faint)
        (string blue-cooler)
        (type magenta-cooler)
        (variable cyan)))

;; Mimic `ef-summer' theme (from my `ef-themes') for code syntax
;; highlighting, while still using the Modus colors (and other
;; mappings).
(setq modus-themes-common-palette-overrides
      '((builtin magenta)
        (comment yellow-faint)
        (constant red-cooler)
        (fnname magenta-warmer)
        (keyword magenta-cooler)
        (preprocessor green-warmer)
        (docstring cyan-faint)
        (string yellow-warmer)
        (type cyan-warmer)
        (variable blue-warmer)))

;; Mimic `ef-bio' theme (from my `ef-themes') for code syntax
;; highlighting, while still using the Modus colors (and other
;; mappings).
(setq modus-themes-common-palette-overrides
      '((builtin green)
        (comment yellow-faint)
        (constant blue)
        (fnname green-warmer)
        (keyword green-cooler)
        (preprocessor green)
        (docstring green-faint)
        (string magenta-cooler)
        (type cyan-warmer)
        (variable blue-warmer)))

;; Mimic `ef-trio-light' theme (from my `ef-themes') for code syntax
;; highlighting, while still using the Modus colors (and other
;; mappings).
(setq modus-themes-common-palette-overrides
      '((builtin magenta-cooler)
        (comment yellow-faint)
        (constant magenta-warmer)
        (fnname blue-warmer)
        (keyword magenta)
        (preprocessor red-cooler)
        (docstring magenta-faint)
        (string green-cooler)
        (type cyan-cooler)
        (variable cyan-warmer)))

Reload the theme for changes to take effect.