What about a macro and a loop that works with the display of ↔ colors suffixes:
(defmacro brian-def-char-face (letter backgrnd foregrnd) `(defface ,(intern (concat "brian-char-face-" letter)) '((((type tty) (class color)) (:background ,backgrnd :foreground ,foregrnd)) (((type tty) (class color)) (:inverse-video t)) (((class color) (background dark)) (:foreground ,foregrnd :background ,backgrnd)) (((class color) (background light)) (:foreground ,foregrnd :background ,backgrnd)) (t (:background "gray"))) ,(concat "Face for marking up " (upcase letter) "'s"))) (let ((letcol-alist '((s . (white black)) (t . (black yellow)) (u . (green pink))))) (loop for elem in letcol-alist for l = (format "%s" (car elem)) for back = (format "%s" (cadr elem)) for fore = (format "%s" (caddr elem)) do (eval (macroexpand `(brian-def-char-face ,l ,back ,fore)))))
Gives you new facets:
brian-char-face-s , brian-char-face-t and brian-char-face-u
Now you just need to save the list of letters ↔ color matching and, possibly, expand the macro to support other facial properties (if desired).
source share