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))). Jan 12 at 14:33

1 Answer 1

0

Found a simpler solution!

(setq j-verb-face font-lock-function-name-face)
3
  • 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
    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. 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. Jan 12 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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