I am starting with emacs --daemon
in my session, and it seems to trigger some odd behavior regarding themes and faces. I am using this solarized theme but I have found it to have weird cursor issues. My fix was to customize the cursor face:
(custom-set-faces
;; https://github.com/bbatsov/solarized-emacs/issues/290
'(cursor ((t (:background "#990A1B")))))
The strange thing is that works if I start emacs normally (with the emacs
command). But when I start emacs as a daemon and open a frame (emacs --daemon ; emacsclient --create-frame /dev/null
), the cursor customization is not present.
I have tried to configure a hook like this to run after the theme is loaded but it doesn't seem to take effect either:
(use-package solarized-theme
:ensure t
:config
(progn
(defvar after-load-theme-hook nil
"Hook run after a color theme is loaded using `load-theme'.")
(defadvice load-theme (after run-after-load-theme-hook activate)
"Run `after-load-theme-hook'."
(run-hooks 'after-load-theme-hook))
(defun anarcat/customize-solarized ()
"Customize theme"
(message "custom hook config")
(when (member 'solarized-dark custom-enabled-themes)
(custom-theme-set-faces
'solarized-dark
'(cursor ((t (:background "#990A1B")))))
(message "tweaked theme"))
(message "done"))
(add-hook 'after-load-theme-hook 'anarcat/customize-solarized)))
I know about this question and those answers but they all relate to the theme: the theme loads fine here, it's only the face that fails to load. But it does provide a workaround that actually works:
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(when (eq (length (frame-list)) 2)
(progn
(select-frame frame)
(custom-set-faces
'(cursor ((t (:background "#990A1B"))))))))))
It just feels clunky and weird to run that every time a frame opens. Besides, this feels quite inelegant as it duplicates configuration between my .emacs
and my .emacs-custom
.
This question is also similar to this one although every settings but the faces load here.
So I'm wondering if that's a bug in Emacs worth reporting, or something I am doing wrong, or that the theme is doing wrong.
Any ideas?