0

I can do this:

(custom-set-faces
 '(j-verb-face ((t (:foreground "Red")))))

But what I want is to set the color to one that is theme-dependent.

I tried the following, which causes a "wrong argument type" error:

(custom-set-faces
 '(j-verb-face ((t (font-lock-function-name-face)))))

How can I set the color of j-verb-face to be font-lock-function-name-face?

1
  • 1
    Try ((t (:inherit font-lock-function-name-face))). Commented Jan 12, 2022 at 14:33

1 Answer 1

0

Found a simpler solution!

(setq j-verb-face font-lock-function-name-face)
4
  • 1
    Not all faces have corresponding variables with the same name. Your solution assumes that the code used to apply the face references the variable (rather than the face name) [written slightly differently, such as as a single quote preceding the face name], and that both j-verb-face and font-lock-function-name-face have been assigned variables with the same name as the face (which happens to be the case here, but certainly not always).
    – lawlist
    Commented Aug 14, 2021 at 20:42
  • Yeah, I read recently that faces are not variables, which is weird to me. This solution seemed to work when I tried it, but I have no idea what edge cases may exist. Commented Aug 16, 2021 at 12:49
  • It depends on the face and how the font-lock rule are written. font-lock evalute the face field of font-lock rules. If they contain the quoted name of the, as in (0 'my-face), then this method won't work. However, if it contains the unquoted name, as in (0 my-face) then font-lock reads the variable named my-face which typically contains the name of the face, equally typically a face with the same name as the variable. Using the variable way is deprecated -- if it works in this case I'm glad, but it wont work for all cases. Commented Jan 12, 2022 at 14:31
  • n.b. A lot of the time, the variable FOO-face will have a default value of the face FOO (without a -face suffix). So there's a face FOO and a variable FOO-face to access it (or indeed some other face set in place of the default, which is the reason for having variables like this at all). That's not consistent though -- some faces do, redundantly, have a name ending in -face, which can make matters more confusing.
    – phils
    Commented Aug 29 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.