reddit / emacs

I get this error on startup (error Invalid face org-level-1)

GAMEWARRIOR010 · 2022-11-28 02:37
[Here is a Screen Shot](https://imgur.com/JTrEJDo) [Dotfiles](https://github.com/Game-Warrior/dotfiles/tree/main/.doom.d) I am pretty sure the problem is here but I don't know what the best solution is. I copy and pasted this from [Distro Tube's dotfiles](https://gitlab.com/dwt1/dotfiles). (defun gw/org-colors-doom-one () "Enable Doom One colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#51afef" ultra-bold) (org-level-2 1.6 "#c678dd" extra-bold) (org-level-3 1.5 "#98be65" bold) (org-level-4 1.4 "#da8548" semi-bold) (org-level-5 1.3 "#5699af" normal) (org-level-6 1.2 "#a9a1e1" normal) (org-level-7 1.1 "#46d9ff" normal) (org-level-8 1.0 "#ff6c6b" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-dracula () "Enable Dracula colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#8be9fd" ultra-bold) (org-level-2 1.6 "#bd93f9" extra-bold) (org-level-3 1.5 "#50fa7b" bold) (org-level-4 1.4 "#ff79c6" semi-bold) (org-level-5 1.3 "#9aedfe" normal) (org-level-6 1.2 "#caa9fa" normal) (org-level-7 1.1 "#5af78e" normal) (org-level-8 1.0 "#ff92d0" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-gruvbox-dark () "Enable Gruvbox Dark colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#458588" ultra-bold) (org-level-2 1.6 "#b16286" extra-bold) (org-level-3 1.5 "#98971a" bold) (org-level-4 1.4 "#fb4934" semi-bold) (org-level-5 1.3 "#83a598" normal) (org-level-6 1.2 "#d3869b" normal) (org-level-7 1.1 "#d79921" normal) (org-level-8 1.0 "#8ec07c" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-monokai-pro () "Enable Monokai Pro colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#78dce8" ultra-bold) (org-level-2 1.6 "#ab9df2" extra-bold) (org-level-3 1.5 "#a9dc76" bold) (org-level-4 1.4 "#fc9867" semi-bold) (org-level-5 1.3 "#ff6188" normal) (org-level-6 1.2 "#ffd866" normal) (org-level-7 1.1 "#78dce8" normal) (org-level-8 1.0 "#ab9df2" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-nord () "Enable Nord colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#81a1c1" ultra-bold) (org-level-2 1.6 "#b48ead" extra-bold) (org-level-3 1.5 "#a3be8c" bold) (org-level-4 1.4 "#ebcb8b" semi-bold) (org-level-5 1.3 "#bf616a" normal) (org-level-6 1.2 "#88c0d0" normal) (org-level-7 1.1 "#81a1c1" normal) (org-level-8 1.0 "#b48ead" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-oceanic-next () "Enable Oceanic Next colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#6699cc" ultra-bold) (org-level-2 1.6 "#c594c5" extra-bold) (org-level-3 1.5 "#99c794" bold) (org-level-4 1.4 "#fac863" semi-bold) (org-level-5 1.3 "#5fb3b3" normal) (org-level-6 1.2 "#ec5f67" normal) (org-level-7 1.1 "#6699cc" normal) (org-level-8 1.0 "#c594c5" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-palenight () "Enable Palenight colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#82aaff" ultra-bold) (org-level-2 1.6 "#c792ea" extra-bold) (org-level-3 1.5 "#c3e88d" bold) (org-level-4 1.4 "#ffcb6b" semi-bold) (org-level-5 1.3 "#a3f7ff" normal) (org-level-6 1.2 "#e1acff" normal) (org-level-7 1.1 "#f07178" normal) (org-level-8 1.0 "#ddffa7" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-solarized-dark () "Enable Solarized Dark colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#268bd2" ultra-bold) (org-level-2 1.6 "#d33682" extra-bold) (org-level-3 1.5 "#859900" bold) (org-level-4 1.4 "#b58900" semi-bold) (org-level-5 1.3 "#cb4b16" normal) (org-level-6 1.2 "#6c71c4" normal) (org-level-7 1.1 "#2aa198" normal) (org-level-8 1.0 "#657b83" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-solarized-light () "Enable Solarized Light colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#268bd2" ultra-bold) (org-level-2 1.6 "#d33682" extra-bold) (org-level-3 1.5 "#859900" bold) (org-level-4 1.4 "#b58900" semi-bold) (org-level-5 1.3 "#cb4b16" normal) (org-level-6 1.2 "#6c71c4" normal) (org-level-7 1.1 "#2aa198" normal) (org-level-8 1.0 "#657b83" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) (defun gw/org-colors-tomorrow-night () "Enable Tomorrow Night colors for Org headers." (interactive) (dolist (face '((org-level-1 1.7 "#81a2be" ultra-bold) (org-level-2 1.6 "#b294bb" extra-bold) (org-level-3 1.5 "#b5bd68" bold) (org-level-4 1.4 "#e6c547" semi-bold) (org-level-5 1.3 "#cc6666" normal) (org-level-6 1.2 "#70c0ba" normal) (org-level-7 1.1 "#b77ee0" normal) (org-level-8 1.0 "#9ec400" normal))) (set-face-attribute (nth 0 face) nil :font doom-variable-pitch-font :weight (nth 3 face) :height (nth 1 face) :foreground (nth 2 face))) (set-face-attribute 'org-table nil :font doom-font :weight 'normal :height 1.0 :foreground "#bfafdf")) ;; Load our desired gw/org-colors-* theme on startup (gw/org-colors-doom-one) Edit: for future reference wrapping this in (after! org) ended up being the solution.
dj_goku · 2022-11-28 06:56
Maybe —debug-init when starting emacs and see what lines of your config is causing the issue. If you remove all of these defun does your config load successfully?
MitchellMarquez42 · 2022-11-28 08:01
Add the functions to org-mode-hook so they don't try to load before the faces get defined.
EternalMigrainity · 2022-11-28 08:16
Weird
GAMEWARRIOR010 · 2022-11-28 12:52
I removed it from my config and now it loads with out errors.
GAMEWARRIOR010 · 2022-11-28 12:53
I am still pretty new to emacs so what would be the best way to go about doing that.
GAMEWARRIOR010 · 2022-11-28 14:59
[Here is the output from --debug-init](https://i.imgur.com/TKB37xk.png)
Khoulaiz · 2022-11-28 15:14
I am not using doom, but I guess you have to put all this into an \`(after! org ....)\`, since the faces are defined only after the org package is initialised. See the config of "org babel tangle" right above your functions in your dotfile for an example.