emacs 设置emacs的外观

设置emacs的外观

emacs的外观包括文本区的外观,辅助区的外观,状态行的外观,光标的外观等,

每个外观都有名字,并且都有下面属性:

  • Font Family: 字体名字
  • Font Foundry: ?
  • Width: 字体宽度
  • Height: 字体宽度
  • Weight: 字体重
  • Slant: 斜体
  • Underline: 下划线
  • Overline: 上划线
  • Strike-through: 透过线
  • Box around text: ?
  • Inverse-video: ?
  • Foreground: 前景色
  • Background: 背景色
  • Stipple: ?
  • Inherit: 继承别的外观

如何设置外观呢?emacs通过【Face】的东西来设置

face的定义:face可以定义字体,颜色等。大多数主编辑模式(major mode)分配各种face给函数名,注释,变量,关键字等,通过【Font Lock mode】。【Font Lock mode】的说明在后面。

Emacs can display text in several different styles, called faces. Each face can specify various face attributes, such as the font, height, weight, slant, foreground and background color, and underlining or overlining. Most major modes assign faces to the text automatically, via Font Lock mode.

注意:face里并不设定所有属性,没有被设定的属性就使用叫default的face的属性。比如face:popup-face,它只设定了前景色和背景色属性,所有它的其他属性的值就是face:default的相应属性的值。

这个概念非常重要,所以当改变了face:default里属性的值的话,就会影响所有face

list-faces-display :查看系统里有所有face

list-colors-display :查看系统里所有的颜色的名字和RGB值

set-face-foreground :改变指定face里的前景色(先输入要改变的face的名字,然后再输入颜色的名字)

set-face-background:改变指定face里的背景色(先输入要改变的face的名字,然后再输入颜色的名字)

ctrl h v 变量A:查看变量A的作用

Font Lock mode:

Font Lock mode is a minor mode, always local to a particular buffer, which assigns faces to (or fontifies) the text in the buffer. Each buffer's major mode tells Font Lock mode which text to fontify; for instance, programming language modes fontify syntactically relevant constructs like comments, strings, and function names.

Font Lock mode is enabled by default in major modes that support it. To toggle it in the current buffer, type M-x font-lock-mode.

font-lock-mode :作用在当前缓冲区

global-font-lock-mode:作用在当前缓冲区

Font Lock mode uses several specifically named faces to do its job, including font-lock-string-facefont-lock-comment-face, and others. The easiest way to find them all is to use

M-x customize-group 回车 font-lock-faces 回车. You can then use that customization buffer to customize the appearance of these faces.

从下图可以看出来:

1,关键字(font lock keyward face)后面是紫色,所以右面代码里关键字(template,protected,try等)部分全是紫色

2,函数名(font lock function name face)后面是蓝色,所以右面代码里函数名(insert,get_node等)部分全是蓝色

如何在上面的画面操作请参考Changing a Variable

注意:当通过用emacs改变变量的值后,会自动在.emacs里插入下面的代码。

(custom-set-variables
 ;; custom-set-variables 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.
)

注意:当通过用emacs改变face的设定后,会自动在.emacs里插入下面的代码。

;;设置face:default的背景色为黑色,前景色为白色,字体大小为218
(custom-set-faces
 ;; custom-set-variables 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.
)

注意:custom-set-facescustom-set-variables在.emacs里只能出现一次。

c/c++ 学习互助QQ群:877684253

本人微信:xiaoshitou5854

posted @ 2019-11-17 16:30  小石王  阅读(1047)  评论(0编辑  收藏  举报