简体   繁体   English

从.emacs设置Emacs 24颜色主题

[英]Setting Emacs 24 color theme from .emacs

I have the following code in my .emacs: 我的.emacs中有以下代码:

(if (null window-system)
  (progn
    (require 'color-theme)
    (color-theme-initialize)
    (color-theme-simple-1)))

When I open Emacs on the console, I can verify that the progn block runs (by a (message "Got here.") ), and I see a flash that suggests that the color theme was loaded, but if it was loaded, it is overridden by something else. 当我在控制台上打开Emacs时,我可以验证progn块是否运行(通过(message "Got here.") ),我看到一个闪存,表明颜色主题已加载,但如果它已加载,它被其他东西覆盖。 If, after loading, I open my .emacs file and submit the block above using Cx Ce , it works. 如果,在加载后,我打开我的.emacs文件并使用Cx Ce提交上面的块,它可以工作。 I've tried doing: 我试过做:

(add-hook 'after-init-hook
          (lambda ()
            (progn
              (require 'color-theme)
              (color-theme-initialize)
              (color-theme-simple-1))))

but that acts the same. 但是行为是一样的。

It may be relevant that I'm using Emacs 24, and that this code is not in my .emacs, but in ~/Dropbox/.emacs, which is loaded from my .emacs. 可能与我使用Emacs 24相关,并且此代码不在我的.emacs中,而是在〜/ Dropbox / .emacs中,它是从我的.emacs加载的。


An additional note: I've tried Mx customize-themes , but none of those work acceptably on the console. 另外一个注意事项:我已经尝试过Mx customize-themes ,但这些Mx customize-themes在控制台上都不可接受。 They either produce a nearly unreadable light theme, or most of the text is invisible. 它们或者产生几乎不可读的光主题,或者大部分文本是不可见的。

Emacs 24 has built-in theming, which doesn't use statements like (require 'color-theme) . Emacs 24内置了主题,它不使用像(require 'color-theme)这样的语句。 As Drew points out in the comments, there are differences between color themes and custom themes, and the new direction is towards the latter. 正如Drew在评论中指出的那样,颜色主题和自定义主题之间存在差异 ,而新的方向则是针对后者。 Try Mx customize-themes to take a look. 尝试Mx customize-themes来看看。 From .emacs, you can do things like (load-theme 'wombat t) . 从.emacs,您可以执行诸如(load-theme 'wombat t)

But ... ......

It may still be going wrong for you. 它可能仍然是你的错。 One thing that can mess it up like this is changing the face -- maybe in the custom-set-faces part of your .emacs file. 有一件事可以搞砸它就像改变了面孔 - 可能是你的.emacs文件的自定义面部分。 Emacs's interactive customization automatically includes the color information (both background and foreground) of whatever theme you happen to be using at the time you set it, so this can definitely make trouble with color themes. Emacs的交互式自定义功能会自动包含您在设置时使用的任何主题的颜色信息(背景前景),因此这绝对会给色彩主题带来麻烦。 If that is what's causing it, you can just set the particular attribute you care about with something like 如果这是导致它的原因,你可以用类似的东西设置你关心的特定属性

(set-face-attribute 'default nil :height 120)

That will change the font size without changing the colors. 这将改变字体大小而不改变颜色。

Emacs 24 have own theming system. Emacs 24拥有自己的主题系统。

M-x customize-themes

or 要么

(custom-set-variables
  ....
   '(custom-enabled-themes (quote (selected-theme)))
)

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

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