1

Why is :box not getting the current background color?. It doesn't even work if I setq a variable with the color hardcoded, but if I set the hex color as a literal it works perfectly. If I evaluate manually the sexp (face-background 'default) it returns the right color #1E1C31 ( a dark color, but if you notice on the screenshot is setting a bright color ).

(set-face-attribute 'tab-bar-tab-inactive nil
  :family "Cascadia"
  :foreground (face-foreground 'default)
  :background (face-background 'default)
  :height 1.3
  :slant 'italic
  :box '(:line-width 9 :color (face-background 'default))
                        )

enter image description here

In my opinion my question is not exactly the same as this one: https://emacs.stackexchange.com/a/7487/7006

In both cases the solution could be solved creating a list, but in this case as @db48x explained there's an alternate solution with quasiquoting that the other answers discourage the use.

Fabman
  • 578
  • 2
  • 14
  • 3
    Does this answer your question? [How to evaluate the variables before adding them to a list?](https://emacs.stackexchange.com/questions/7481/how-to-evaluate-the-variables-before-adding-them-to-a-list) – Drew Mar 28 '22 at 14:30
  • This question gets asked relatively frequently, in slightly different forms. It's essentially based on misunderstanding `quote`. – Drew Mar 28 '22 at 14:30
  • That question helps with this answer to understand the concept of `quote`, but with @db48x answer it makes more sense on using (or not using in this case ) of `quotes` on the attributes of the `:box` face – Fabman Mar 28 '22 at 14:39

1 Answers1

3

Because you put it inside of a quote.

'(:line-width 9 :color (face-background 'default)

This is quoted, so it is not evaluated. It is simply a list of four things. The last one in the list is another list with the symbol face-background and the list (quote default) in it.

There are a couple of ways you could write this so that will be evaluated. Use the list function, which constructs a list out of its arguments:

(list :line-width 9 :color (face-background 'default))

Use quasiquoting instead:

`(:line-width 9 :color ,(face-background 'default))

This lets you use the comma operator (,) to interpolate a value from an expression that will be evaluated.

See chapter 10.3 Quoting and chapter 10.4 Backquote of the Emacs Lisp manual for more information.

db48x
  • 15,741
  • 1
  • 19
  • 23