How to put the value of :face into a variable/list/hash in emacs lisp?

41 views Asked by At

I am sorry I am not familiar with emacs-lisp.

I wrote a config file as follows, but it did not work correctly.

So how could I put the value of :face in svg-tag-tags into a variable (here is todo-faces-a)?

(custom-set-faces
   '(todo-faces-a '(:background "red"  :distant-foreground "red"  :foreground  "white"   :height 0.7  :weight bold) )
   )

(setq svg-tag-tags
      `(
    ;; TODO / DONE
    ("TODO" . ((lambda (tag) (svg-tag-make "TODO" :face 'todo-faces-a
                           :inverse nil :margin 0 :padding 0 :ascent 0 :height 0 ))))
))
1

There are 1 answers

0
user23165029 On

defface doesn't create the variable todo-faces-a. Instead, it adds a property named face-defface-spec to the property list of 'todo-faces-a:

(get 'todo-faces-a 'face-defface-spec)
    => ((t :foreground "black" :background "gray95" :box "gray90"))

So in order to access it in a backquoted form, this should do:

(setq svg-tag-tags
    `(.... ,(cdar (get 'todo-faces-a 'face-defface-spec)) ...)

Where

(cdar (get 'todo-faces-a 'face-defface-spec))

evaluates to

(:foreground "black" :background "gray95" :box "gray90")