3

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?

6
  • Do you run Emacs using the daemon and emacsclient ? Commented Jun 26, 2023 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... Commented Jun 26, 2023 at 14:18
  • 1
    Please show your custom-set-faces code, at least the relevant part. Commented Jun 26, 2023 at 15:11
  • 1
    Then does this answer your question emacs.stackexchange.com/a/72730/40641 ? Commented Jun 27, 2023 at 9:28
  • 1
    I 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. Commented Jun 27, 2023 at 13:06

1 Answer 1

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 in startup.el):

  1. If appropriate, it creates a graphical frame. As part of creating the graphical frame, it initializes the window system specified by initial-frame-alist and default-frame-alist for the graphical frame, by calling the window-system-initialization function for that window system. This is not done in batch (noninteractive) or daemon mode.
  2. 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.
4
  • 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. Commented Jun 27, 2023 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. Commented Aug 28, 2023 at 14:58
  • @mikemtnbikes: You can omit that newline. Commented Aug 28, 2023 at 15:01
  • @shynur Thanks for note, I figured it was unnecessary, but wasn't sure. Commented Aug 28, 2023 at 15:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.