I have a custom (custom-set-faces ...)
section in my ~/.emacs
file. When I run emacs this section seems to get completely ignored since the custom colours don't get set. But if I go to ~/.emacs
, highlight the section and run it with M-x eval-region
then the colours load correctly. Why is custom-set-faces
getting silently ignored?
Asked
Active
Viewed 163 times
2

shynur
- 4,065
- 1
- 3
- 23

Jan Stolarek
- 123
- 4
-
Do you run Emacs using the daemon and `emacsclient` ? – Tristan Riehs Jun 26 '23 at 13:54
-
If you are using *daemon-client*, then `custom-set-faces` sets the face of frame `F1`, which is actually invisible. I encountered this issue yesterday... – shynur Jun 26 '23 at 14:18
-
1Please show your `custom-set-faces` code, at least the relevant part. – Drew Jun 26 '23 at 15:11
-
@TristanRiehs @shynur Indeed, I connect to Emacs by daemonizing it and then using `emacsclient`. – Jan Stolarek Jun 27 '23 at 08:55
-
1Then does this answer your question https://emacs.stackexchange.com/a/72730/40641 ? – Tristan Riehs Jun 27 '23 at 09:28
-
1I don't know ELisp well enough to adapt that code to settings I have in `custom-set-faces`. I tried calling `custom-set-faces` by putting it inside the hook like this: `(defun efs/set-font-faces () (custom-set-faces ...))`, but that does not seem to work. – Jan Stolarek Jun 27 '23 at 13:06
1 Answers
2
Add
(add-hook 'emacs-startup-hook
(lambda ()
(custom-set-faces
"Put your original “(custom-set-faces ...)” here!")))
to your configuration.
I guess the problem you encountered has to do with the order of actions at Emacs startup:
When Emacs is started up, it performs the following operations (see
normal-top-level
instartup.el
):
- If appropriate, it creates a graphical frame. As part of creating the graphical frame, it initializes the window system specified by
initial-frame-alist
anddefault-frame-alist
for the graphical frame, by calling thewindow-system-initialization
function for that window system. This is not done in batch (noninteractive) or daemon mode.- It initializes the initial frame’s faces, and sets up the menu bar and tool bar if needed. If graphical frames are supported, it sets up the tool bar even if the current frame is not a graphical one, since a graphical frame may be created later on.

shynur
- 4,065
- 1
- 3
- 23
-
Is there a way to make this work both in daemon mode and in normal mode? While I run Emacs by daemonizing it, I also have it as my default git commit message editor. With your proposed solution all seems to work fine in daemon mode, but when editing git messages in standalone mode fonts are not customized properly. – Jan Stolarek Jun 27 '23 at 17:37
-
@JanStolarek I was able to get the behavior you desire by adding this line after the `(add-hook...)` code: `(add-hook 'emacs-startup-hook \n face-customizer)` where the `\n` is a new line. – mikemtnbikes Aug 28 '23 at 14:58
-
-
@shynur Thanks for note, I figured it was unnecessary, but wasn't sure. – mikemtnbikes Aug 28 '23 at 15:05