简体   繁体   English

Emacs覆盖init文件中color-theme的背景颜色

[英]Emacs override background color from color-theme in init file

I installed emacs, created a .emacs.d directory and made an init.el file: 我安装了emacs,创建了一个.emacs.d目录并创建了一个init.el文件:

(require 'package)                                                              
(add-to-list 'package-archives                                                  
             '("melpa" . "http://melpa.milkbox.net/packages/") t)               
(package-initialize)                                                            

(when (not package-archive-contents)                                            
  (package-refresh-contents))                                                   

(defvar my-packages                                                             
  '(starter-kit                                                                 
    starter-kit-bindings                                                        
    starter-kit-lisp                                                            
    clojure-mode                                                                
    color-theme                                                                 
    nrepl))                                                                     

(dolist (p my-packages)                                                         
  (when (not (package-installed-p p))                                           
    (package-install p)))                                                       

(require 'color-theme)                                                          
(color-theme-initialize)                                                        
(color-theme-charcoal-black)                                                    
(color-theme-install-frame-params '((background-color . "black")))              

When I open emacs, I end up with the color-theme-charcoal-black colors, with its default gray background. 当我打开emacs时,我最终得到了color-theme-charcoal-black ,并带有默认的灰色背景。 If I open init.el and eval-buffer , the background goes black as desired. 如果我打开init.el和eval-buffer ,背景会根据需要变黑。

How can I get that affect without needing to eval-buffer ? 如何在不需要eval-buffer情况下获得该效果?

I also tried: 我也尝试过:

(add-hook 'after-init-hook 
          '(lambda () (color-theme-install-frame-params 
                       '((background-color . "black"))))

Similar to this question: https://superuser.com/questions/481793/permanently-override-background-colour-of-emacs-theme 与此问题类似: https//superuser.com/questions/481793/permanently-override-background-colour-of-emacs-theme

Well, that's not the way to set up a theme in Emacs 24, but you could patch the old one to work like the new one. 嗯,这不是在Emacs 24中设置主题的方法,但你可以修补旧的主题,就像新的一样。 Here's an example of a theme I've made for myself, but you could just take the one that you like and replace the values. 这是我为自己制作的一个主题的例子,但你可以拿一个你喜欢的主题并替换它们。 I've not finished this one yet, but it is close to be finished :) 我还没有完成这个,但它已接近完成:)

After you've done, save the file into ~/.emacs.d/themes/charcoal-black-theme.el 完成后,将文件保存到〜/ .emacs.d / themes / charcoal-black-theme.el中

and in your .emacs: 在你的.emacs中:

(add-to-list 'custom-theme-load-path (expand-file-name "~/.emacs.d/themes/"))
(setq custom-enabled-themes '(charcoal-black))

after you've done so, Emacs will ask you whether you want to permanently add the themes directory and the theme to enabled themes. 完成后,Emacs会询问您是否要将主题目录和主题永久添加到启用的主题。 If you answer positively, it will append some code to the (custom-set-variables ...) 如果你肯定地回答,它会将一些代码附加到(custom-set-variables ...)

The example theme follows: 示例主题如下:

http://pastebin.com/S2BHmd5s http://pastebin.com/S2BHmd5s

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM