Minimal config https://www.refheap.com/18816
Scenario 1.
Scenario 2.
Why is that?
.emacs.d/init.d config:
(require 'package)
(package-initialize)
(defun install-pack (p)
"A utility function to help in installing emacs package."
(unless (package-installed-p p) (package-install p)))
(defun install-packs (packs)
"A utility function to help in installing emacs packages."
(unless package-archive-contents
(package-refresh-contents))
(dolist (p packs) (install-pack p)))
;(load-theme 'tronesque)
(load-theme 'tronesque t)
or
;(load-theme 'tronesque)
;;(load-theme 'tronesque t)
(custom-set-variables
;; custom-set-variables was added by Custom.
'(custom-enabled-themes (quote (tronesque)))
'(custom-safe-themes (quote ("b8f561a188a77e450ab8a060128244c81dea206f15c1152a6899423dd607b327" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
)
For Emacs 24,
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(select-frame frame)
(load-theme 'tronesque t)))
(load-theme 'tronesque t))
or
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(load-theme 'tronesque t))))
(load-theme 'tronesque t))
should do.
Using all mentioned approaches the theme is being reloaded in vain starting from the second frame creation.
For loading it only one time I did:
(if (daemonp)
(add-hook 'after-make-frame-functions (lambda (frame)
(when (eq (length (frame-list)) 2)
(progn
(select-frame frame)
(load-theme 'tronesque)))))
(load-theme 'tronesque 1))
After some tests in Emacs 24.5.1 with the distinguished theme and using emacs as daemon, I have got some issues.
If my first client is a terminal emacsclient -t
and later I open a window client emacsclient -c
, the window client loses theme configurations.
Then I came up with this solution:
;; theme
(defvar my:theme 'distinguished)
(defvar my:theme-window-loaded nil)
(defvar my:theme-terminal-loaded nil)
(if (daemonp)
(add-hook 'after-make-frame-functions(lambda (frame)
(select-frame frame)
(if (window-system frame)
(unless my:theme-window-loaded
(if my:theme-terminal-loaded
(enable-theme my:theme)
(load-theme my:theme t))
(setq my:theme-window-loaded t))
(unless my:theme-terminal-loaded
(if my:theme-window-loaded
(enable-theme my:theme)
(load-theme my:theme t))
(setq my:theme-terminal-loaded t)))))
(progn
(load-theme my:theme t)
(if (display-graphic-p)
(setq my:theme-window-loaded t)
(setq my:theme-terminal-loaded t))))
It's not so elegant, I know, but solves the two problems (unnecessary reloading and lost of config).
The following extension of the above answer fixed the problem for me with Emacs 24, setting the color-theme via the color-theme call, as shown with the solarized theme.
(if (daemonp)
(add-hook 'after-make-frame-functions
'(lambda (f)
(with-selected-frame f
(when (window-system f) (color-theme-solarized-dark)))))
(color-theme-solarized-dark))
HTH
J.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With