Doom-emacs: [BUG] emacsclient uses wrong background unless reload theme

Created on 29 Aug 2019  路  7Comments  路  Source: hlissner/doom-emacs

By default, the background of text field is not correct set.

It looks like this
Screen Shot 2019-08-29 at 5 22 38 PM

I can see Unable to load color "unspecified-bg" [24 times] in Message buffer.

Reload the theme manually would fix this.

But this may not be the only issue with emacsclient.

Go to a file would not enable lsp

File local-variables error: (doom-hook-error lsp! (void-function lsp-register-client))

Not sure if it's the same cause. I configured a new lsp client in config file.
(LSP is another issue with loading order, I think)

I can reproduce this in a fresh install. I always use SPC q Q to kill the daemon.

With /usr/local/bin/emacs everything works perfect.

:core bug redaemon themes resolved

Most helpful comment

No discrepancies with text background here but I've got another issue when launching Emacs through emacsclient i.e. with something like emacsclient -a '' -c -n. My issue is that cursor color is white and unchanging when I switch states, seems like doom theme is not properly initialized. So I used to have a timer in my config.el which reloads the theme:

;; fix doom theme cursor
(run-at-time "2 sec" nil #'doom/reload-theme)

Then I saw this issue and tried removing the above and launching Emacs through /usr/bin/emacs and guess what -- no issues!

Edit

Using a timer didn't look right so I've changed the above with a hook after frame is created:

;; fix theme when frame created by emacsclient
(add-hook! 'after-make-frame-functions
  (defun my-load-theme-fix (frame)
      (select-frame frame)
      (doom/reload-theme)))

All 7 comments

No discrepancies with text background here but I've got another issue when launching Emacs through emacsclient i.e. with something like emacsclient -a '' -c -n. My issue is that cursor color is white and unchanging when I switch states, seems like doom theme is not properly initialized. So I used to have a timer in my config.el which reloads the theme:

;; fix doom theme cursor
(run-at-time "2 sec" nil #'doom/reload-theme)

Then I saw this issue and tried removing the above and launching Emacs through /usr/bin/emacs and guess what -- no issues!

Edit

Using a timer didn't look right so I've changed the above with a hook after frame is created:

;; fix theme when frame created by emacsclient
(add-hook! 'after-make-frame-functions
  (defun my-load-theme-fix (frame)
      (select-frame frame)
      (doom/reload-theme)))

I have the same issue, and @zhelezov 's fix worked. However, I imagine this issue is also related to why (add-hook 'window-setup-hook #'toggle-frame-maximized) does not work when emacs is run as a daemon

@phillc
Why not use default-frame-alist for frame settings? Try this in the beginning of your init.el to default to maximized Emacs frames:

(add-to-list 'default-frame-alist '(fullscreen . maximized))

@zhelezov That worked, thanks!

@hlissner

@zhelezov's solution fixes the theme issue perfectly. Should we port that into doom or there would be a more straight forward fix?

I don't need any workarounds after 17174e1. What about the rest of you? If it works for you too, time to close this I guess.

Fixed the issue for me. Thank you all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ptival picture Ptival  路  3Comments

governorgoat picture governorgoat  路  3Comments

gilbertw1 picture gilbertw1  路  3Comments

oyarsa picture oyarsa  路  3Comments

ashiklom picture ashiklom  路  3Comments