The error message Invalid face
comes from an internal C function lface_from_face_name_no_resolve
within xfaces.c
A face must be defined before an attribute thereof may be changed with set-face-attribute
. The library that defines the org-level-...
faces is named org-faces
, with the Lisp version being org-faces.el
and the byte-compiled version being org-faces.elc
. The main library of org-mode
is org.el
, and it expressly calls the org-faces
library with the line (require 'org-faces)
. The function with-eval-after-load
(see the doc string of the function with C-h f with-eval-after-load
and the Elisp Manual for more details) can be used to ensure the org-faces
library is loaded before attributes of faces defined therein are changed:
(with-eval-after-load 'org-faces ...)
The dolist
statement proposed by the O.P. can be inserted/replaced in lieu of the ...
hereinabove. The second argument to with-eval-after-load
is looking for BODY, which is interpreted to mean just one form ... Where more than one statement is required, consider using (progn ...)
to wrap one or more statements; e.g., (progn [SOMETHING] [SOMETHING ELSE])
(with-eval-after-load 'org-faces ...)
?