Skip to content

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: Use theme colors in code with modus-themes-with-colors.

These are the minimum recommended settings with 16 colors:

emacs-lisp
(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-cooler
                  magenta-cooler
                  blue
                  magenta-warmer
                  cyan-warmer
                  red-cooler
                  green
                  fg-main
                  cyan
                  yellow
                  blue-warmer
                  red-warmer
                  green-cooler
                  yellow-faint)))

With 8 colors:

emacs-lisp
(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-cooler
                  cyan-cooler
                  fg-main
                  blue-warmer
                  red-cooler
                  cyan)))

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

emacs-lisp
(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-cooler
                  green-warmer)))

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):

emacs-lisp
(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-cooler
                  magenta-cooler
                  magenta)))