定制GNU Emacs字体语法颜色

来源:互联网 发布:网络社交平台利弊调查 编辑:程序博客网 时间:2024/05/16 17:50

在~/.emacs中加上一个如下的lisp语句,这样启动以后该设置就会生效了,当然是全局的.需要进一步的改进.对于更多的机制我不是很清楚.

(custom-set-faces
'(font-lock-string-face ((t (:foreground "Goldenrod"))) t)
'(font-lock-constant-face ((t (:foreground "Orange"))) t)
'(font-lock-doc-string-face ((t (:foreground "Red"))) t)
'(font-lock-variable-name-face ((t (:foreground "OrangeRed"))) t)
'(font-lock-function-name-face ((t (:foreground "Brown"))) t)
'(font-lock-keyword-face ((t (:foreground "Blue"))) t)
'(font-lock-builtin-face ((t (:foreground "Blue"))) t)
'(font-lock-type-face ((t (:foreground "Blue"))) t)
'(font-lock-other-type-face ((t (:foreground "Blue"))) t)
'(font-lock-comment-face ((t (:foreground "ForestGreen"))) t)
'(font-lock-warning-face ((t (:foreground "Coral"))) t))

可以在*scratch* buffer中调试这个语句,方法是在语句后面按Ctrl-x Ctrl-e.

查看颜色和名称可以用命令Alt-x list-colors-display,当然这个要窗口模式下运行才有效.