更改Emacs语法突出显示颜色

时间:2009-07-02 20:23:22

标签: emacs syntax-highlighting colors font-lock-mode

我正在运行Emacs,在C ++模式和PHP模式下编辑文件。我喜欢语法高亮作为一个概念,但默认颜色是一个讽刺。我几乎看不到其中的一些:太黑了。改变价值观的最简单方法是什么?我似乎无法在网上找到任何相关信息。我甚至不介意更改二进制文件,因为我正在编译自己的Emacs。我只想找到蓝色为#0000FF的地方,并将其改为#AAAAFF。

5 个答案:

答案 0 :(得分:65)

我发现在这类事情上使用颜色主题最简单。

https://www.emacswiki.org/emacs/ColorThemes

但如果您不想这样做,请将光标放在有问题的文本上,然后点击M-x customize-face。它应默认为光标所在的面。

http://www.gnu.org/software/emacs/manual/html_node/emacs/Specific-Customization.html

答案 1 :(得分:26)

2种方式 - 你可以安装包颜色主题,它有很多很好的方案可供选择,而且更容易手工完成。副手看起来像这样(在你的.emacs中)

(custom-set-faces
   custom-set-faces was added by Custom.
   If you edit it by hand, you could mess it up, so be careful.
   Your init file should contain only one such instance.
   If there is more than one, they won't work right.
  '(default ((t (:inherit nil :stipple nil :background "lightyellow2" :foreground "gray20" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :width normal :family "liberation mono"))))
  '(background "blue")
  '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
  '(font-lock-comment-face ((t (:foreground "MediumAquamarine"))))
  '(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
  '(font-lock-doc-string-face ((t (:foreground "green2"))))
  '(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
  '(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
  '(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
  '(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
  '(font-lock-string-face ((t (:foreground "LimeGreen"))))

...

等。等

您也可以输入

`M-x customize-face RET`

它将为您提供所有自定义设置,最终以.emacs结束。

答案 2 :(得分:16)

将光标放在要更改的面(“颜色”)上。点击 C-u C-x = 。这将告诉您哪个面在该位置,并且它将让您单击以自定义它们/它们。保存您的自定义。

答案 3 :(得分:2)

如果您根本不关心颜色突出显示,或者上述答案都不适合您(或花费太多时间和精力去弄清楚),这是一个非常简单的解决方案,可以摆脱颜色一共。

键入以下内容将消除颜色:

M-x global-font-lock-mode

您也可以将此作为临时步骤,以便您实际看到屏幕上的所有内容,以尝试上述任何答案。在我的情况下,这非常有用,因为允许我改变颜色的某些关键文本的颜色本身几乎是不可见的 - 例如,M-x的提示。

如果您希望更改是永久性的,可以将其添加到.emacs文件中:

(setq-default global-font-lock-mode nil)

答案 4 :(得分:0)

从 Emacs 24.1 开始,您可以使用 M-x customize-themes 来选择颜色主题。

Emacs 带有十几个不同亮度和色彩的主题,因此您很可能会找到最符合您喜好的主题。

您还可以在 https://peach-melpa.org/ 找到更多可通过 MELPA 安装的颜色主题。