我一直在使用color-theme在我的.emacs中设置颜色:
(defun custom-theme ()
(interactive)
(color-theme-install
'(custom-theme
((background-color . "black")
(background-mode . dark)
(border-color . "#0d1b2b")
(cursor-color . "#fce94f")
(foreground-color . "#dddddd")
(mouse-color . "black"))
(isearch ((t (:inverse-video t :underline t ))))
(lazy-highlight ((t (:inverse-video t :underline t ))))
(hl-line ((t (:background "gray13" ))))
(fringe ((t (:background "#0d1b2b" ))))
(mode-line ((t (:foreground "#bbbbbb" :background "#353e4b"))))
(region ((t (:background "gray13" ))))
(font-lock-builtin-face ((t (:foreground "#9c56dc" ))))
(font-lock-comment-face ((t (:foreground "#187093" ))))
(font-lock-function-name-face ((t (:foreground "#edd400" :underline t ))))
(font-lock-keyword-face ((t (:foreground "#b47113" ))))
(font-lock-string-face ((t (:foreground "#e65351" ))))
(font-lock-type-face ((t (:foreground "#3257d2" ))))
(font-lock-constant-face ((t (:foreground "#cc1e1e" ))))
(font-lock-variable-name-face ((t (:foreground "#cccccc" ))))
(minibuffer-prompt ((t (:foreground "#729fcf" :bold t ))))
(font-lock-warning-face ((t (:foreground "#BB0000" :inverse-video t :underline "#bbbbbb" ))))
)
)
)
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(custom-theme)))
然而,在24.3现在,出于某种原因,当我在终端中打开emacs(emacs -nw)时,它忽略了背景和前景色,所以我得到了白色的编辑器背景。更重要的是,emacs忽略了命令行上传递的-bg和-fg标志。
我发现我可以用这样的方式强制帧设置上的颜色:
(defun on-after-init ()
(unless (display-graphic-p (selected-frame))
(progn
(set-face-background 'default "black" (selected-frame))
(set-face-foreground 'default "#dddddd" (selected-frame)))))
(add-hook 'window-setup-hook 'on-after-init)
但这感觉就像一个黑客,我想明白为什么emacs没有正确地解释我的颜色主题。我的TERM被设置为xterm-256color,虽然回到普通的xterm似乎没有任何影响。