reddit / emacs

How to define custom faces outside of (custom-set-variables...)? And why doesn't this work...

Status-Detective-783 · 2022-03-09 02:37
I use .emacs-custom.el to contain the customizations made by the interactive functions. However, I'd like to start moving some of that stuff out so I can manage it myself and make comments. I tried pulling some stuff out and putting into my init.el, but it didn't work. Namely, I pulled out these: '(org-todo ((((class color) (min-colors 89)) (:weight normal :box (:line-width 1 :color "#808080") :foreground "#FF00FF" :background "#f0f0f0")))) '(org-upcoming-deadline ((t (:foreground "#FF33FF")))) '(org-warning ((t (:background "#ffffa0" :foreground "#ff33ff" :weight normal)))) Why don't these work within my init.el? I tried them before and after my (load custom-file). **EDIT:** Ok I see I'm supposed to use set-face-attribute. So I tried wrapping the above, but this doesn't work (set-face-attribute 'org-todo ((((class color) (min-colors 89)) (:weight normal :box (:line-width 1 :color "#808080") :foreground "#FF00FF" :background "#f0f0f0")))) **EDIT 2:** I figured out the answer. A correct, commonly used form for set-face-attribute is like this: (set-face-attribute 'org-todo nil :box '(:line-width 1 :color "#808080") :weight 'normal :foreground "#FF00FF" :background "#f0f0f0") And it probably didn't work with a straight copy because each of those first three lines, I think those are args to the function (custom-set-faces...). I don't know what it does behind the scenes, but I guess it wants its args in a certain format.
Status-Detective-783 · 2022-03-09 02:42
Well it looks like I can answer my own question: https://emacs.stackexchange.com/questions/45895/changing-faces-one-at-a-time-outside-customize Basically, use set-face-attribute like this: (set-face-attribute 'font-lock-comment-face nil :foreground "Green" :weight 'bold) Also set-face-foreground and set-face-background. EDIT: I updated the question with the complete answer.
00-11 · 2022-03-09 02:59
> so I can manage it myself and make comments 1. As for comments: are you aware that you can add comments when you use the Customize interface? For that, use the **State** menu, item **Add Comment**. 2. What do you intend, by "manage it myself"? What is that you really want/need to do? ([X-Y question?](https://meta.stackexchange.com/q/66377/231821))
Status-Detective-783 · 2022-03-09 05:18
1. I didn't know I could add comments via the Customize interface. Thanks! 2. I simply want to manage the settings myself in my init.el as a natural progression of learning emacs. Because it's far easier and faster to work in text than clicking or selecting around in an awkward Customize interface, and allows me the freedom to do what I want and how I want to do it. I figured out the answer to my question. A correct, commonly used form for set-face-attribute is like this: (set-face-attribute 'org-todo nil :box '(:line-width 1 :color "#808080") :weight 'normal :foreground "#FF00FF" :background "#f0f0f0")