最小配置https://www.refheap.com/18816
情景1。
情景2。
为什么?
.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)
或
;(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.
)
答案 0 :(得分:16)
对于Emacs 24,
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(select-frame frame)
(load-theme 'tronesque t)))
(load-theme 'tronesque t))
或
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(load-theme 'tronesque t))))
(load-theme 'tronesque t))
应该这样做。
答案 1 :(得分:5)
使用所有提到的方法,从第二帧创建开始,主题正在重新加载。
为了加载它我只做了一次:
(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))
在Emacs 24.5.1 中使用尊重主题进行一些测试并使用emacs作为守护进程后,我遇到了一些问题。
如果我的第一个客户端是终端emacsclient -t
,之后我打开一个窗口客户端emacsclient -c
,则窗口客户端会丢失主题配置。
然后我提出了这个解决方案:
;; 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))))
我知道,这并不是那么优雅,但是解决了这两个问题(不必要的重新加载和丢失了配置)。
答案 2 :(得分:3)
上面的答案的以下扩展为我解决了Emacs 24的问题,通过颜色主题调用设置了颜色主题,如曝光主题所示。
(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
学家
答案 3 :(得分:2)
由于它是一个守护进程启动,因此在涉及load-theme
函数时没有创建任何框架。启动后,您通过输入`emacsclient -c'创建了一个新框架,当然没有任何事情发生。
因此,您必须告诉emacs在创建框架后应用主题。钩子after-make-frame-functions
是为此而创建的:
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(load-theme 'tronesque t)))
(load-theme 'tronesque t))
如果是守护进程启动,则在创建框架后加载主题,否则直接加载主题。