7.10 Note on prism.el

This package by Adam Porter, aka “alphapapa” or “github-alphapapa”, implements an alternative to the typical coloration of code. Instead of highlighting the syntactic constructs, it applies color to different levels of depth in the code structure.

As prism.el offers a broad range of customizations, we cannot style it directly at the theme level: that would run contrary to the spirit of the package. Instead, we may offer preset color schemes. Those should offer a starting point for users to adapt to their needs.

In the following code snippets, we employ the modus-themes-with-colors macro: Face specs at scale using the themes’ palette.

These are the minimum recommended settings with 16 colors:

(setq prism-num-faces 16)

(prism-set-colors
  :desaturations '(0) ; do not change---may lower the contrast ratio
  :lightens '(0)      ; same
  :colors (modus-themes-with-colors
            (list fg-main
                  magenta
                  cyan-alt-other
                  magenta-alt-other
                  blue
                  magenta-alt
                  cyan-alt
                  red-alt-other
                  green
                  fg-main
                  cyan
                  yellow
                  blue-alt
                  red-alt
                  green-alt-other
                  fg-special-warm)))

With 8 colors:

(setq prism-num-faces 8)

(prism-set-colors
  :desaturations '(0) ; do not change---may lower the contrast ratio
  :lightens '(0)      ; same
  :colors (modus-themes-with-colors
            (list blue
                  magenta
                  magenta-alt-other
                  cyan-alt-other
                  fg-main
                  blue-alt
                  red-alt-other
                  cyan)))

And this is with 4 colors, which produces results that are the closest to the themes’ default aesthetic:

(setq prism-num-faces 4)

(prism-set-colors
  :desaturations '(0) ; do not change---may lower the contrast ratio
  :lightens '(0)      ; same
  :colors (modus-themes-with-colors
            (list blue
                  magenta
                  magenta-alt-other
                  green-alt)))

If you need to apply desaturation and lightening, you can use what the prism.el documentation recommends, like this (adapting to the examples with the 4, 8, 16 colors):

(prism-set-colors
  :desaturations (cl-loop for i from 0 below 16 collect (* i 2.5))
  :lightens (cl-loop for i from 0 below 16 collect (* i 2.5))
  :colors (modus-themes-with-colors
            (list fg-main
                  cyan-alt-other
                  magenta-alt-other
                  magenta)))