cpaulik / emacs-material-theme

Color Theme for emacs based on material design colors
MIT License
415 stars 48 forks source link

Theme does not load correctly in daemon mode #45

Open cg505 opened 6 years ago

cg505 commented 6 years ago

When emacs is started in daemon mode (using emacsclient --alternate-editor= -c or emacs --daemon && emacsclient -c) the theme is not loaded correctly.

Expected result (just run emacs): correct

Actual result (emacsclient --alternate-editor= -c): wrong

The most obvious difference is in background color. Reloading the theme fixes the issue, but disabling and re-enabling the theme does not.

This was tested in a totally clean .emacs, so I'm confident it's either an issue with emacs or emacs-material-theme. I'm glad to help in any capacity to track down the issue.

articuluxe commented 6 years ago

In daemon mode, there may not be a frame when you load your theme. You should add a hook to ‘after-make-frame-functions (or ‘after-init-hook). If you google you’ll find plenty of discussion regarding this.

On Apr 28, 2018, at 6:57 PM, Christopher Cooper notifications@github.com wrote:

When emacs is started in daemon mode (using emacsclient --alternate-editor= -c or emacs --daemon && emacsclient -c) the theme is not loaded correctly.

Expected result (just run emacs):

Actual result (emacsclient --alternate-editor= -c):

The most obvious difference is in background color.

This was tested in a totally clean .emacs, so I'm confident it's either an issue with emacs or emacs-material-theme. I'm glad to help in any capacity to track down the issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cg505 commented 6 years ago

Sorry, I should have specified in the initial issue that those approaches do not resolve the issue.

Specifically, I tested:

(add-hook 'after-make-frame-functions
          (lambda (_f) (load-theme 'material t)))

and

(add-hook 'after-init-hook
          (lambda () (load-theme 'material t)))
cg505 commented 6 years ago

Basically, (selected-frame) doesn't correspond to the correct frame even if you run it in after-init-hook or after-make-frame-functions. A demonstrative example:

(add-hook 'after-make-frame-functions
            (lambda (frame)
          (message "selected: %s %s"
               (terminal-name (frame-terminal))
               (display-color-cells (selected-frame)))
          (message "passed: %s, %s"
               (terminal-name (frame-terminal frame))
               (display-color-cells frame))))

result:

selected: initial_terminal 0
passed: :0, 16777216
cg505 commented 6 years ago

The following DOES work:

(add-hook 'after-make-frame-functions
            (lambda (frame)
              (with-selected-frame frame
                (load-theme 'material t))))