The theme modus-vivendi
exports an alist of named colors:
(deftheme modus-vivendi
"Elegant, highly legible and customizable dark theme.
Conforms with the highest legibility standard for color contrast
between background and foreground in any given piece of text,
which corresponds to a minimum contrast in relative luminance of
7:1 (WCAG AAA standard).")
(defconst modus-vivendi-palette
'(
;;; Basic values
(bg-main "#000000")
(bg-dim "#1e1e1e")
(fg-main "#ffffff")
(fg-dim "#989898")
(fg-alt "#c6daff")
...
I am trying to access these colors by name so that I can use them in some face specifications. Here is the working code that I came up with:
(let-alist modus-vivendi-palette
(let ((code-bg (car .bg-blue-nuanced)))
(custom-set-faces
`(org-block-begin-line ((t (:background ,code-bg :extend t))))
`(org-block-end-line ((t (:background ,code-bg :extend t))))
`(org-block ((t (:background ,code-bg :extend t))))
)))
I am a new Lisp programmer who is used to languages such as Python, Java and JavaScript. This solution feels wrong to me because it requires a lot of work just to get some data from the equivalent of a Python dictionary. Is there a better way to implement this code, or is this considered idiomatic?
dash.el
useful. It's in both the Gnu and MELPA repos. The downside is that you've introduced a dependency and your code is no longer portable/vanilla elisp, butdash
is very widely known and used, so that's not a big risk. It's a library of functional list-processing functions and Lisp macros. You may find you already have it installed as lots of packages use it. Anyway, the-let
macro fromdash.el
could condense your first two lines into one.let
(or-let
) to assign that expression to a variable named saymy-face-def
. You then assemble each face redefinition thus:`(org-block ,my-face-def)