font , color and Auto-mode customization

来源:互联网 发布:centos创建网络 编辑:程序博客网 时间:2024/05/23 13:19
.emacs.elc
The byte-compiled Lisp version or your startup file. This is not editable, but can make startup quicker if you have a big, complex startup file.
.emacs.el
The more formal name for your startup file. You can use Lisp commands to customize and initialize your entire Emacs environment.
.emacs
The common name for the startup file. Exactly like the .emacs.el file, just without the .el extension. Both are editable.

As soon as Emacs finds one of these files, that's it; then it's on to the next step in startup. You can't have a .emacs.elc for the big customizations and then a separate .emacs for the last few. Sorry!


every Emacs command corresponds to a Lisp function 比如我们输入M-f 实际上调用的是(forward-word 1)

$ emacs -q 其中q选项表示不加载.emacs文件。

$ emacs -u username  它会加载/home/username/.emacs 所以说只限于共享 home directory,我们可以加载其他人的配置,然后可以参考http://www.dotemacs.de/localfiles.html#JohnJGlynn 里面有其它人共享的配置信息


Font customization

Emacs thinks internally in terms of faces. A face is a font and color combination.
你可以通过 holding down the shift key while click the left mouse button 来更改当前buffer的字体。你可以通过这种方式来调试到自己喜欢的字体。


Automatic Highlighting and Coloring


Isearch

M-x customize-group RET --> 输入variable isearch --> 找到isearch-face 通过state中选择"set for current session "测试功能

Strike-through on 它会在把符合的字符串中间画一道横线

Box around text   它会将符合匹配的字符周围加上一个盒子形式

foreground        光标所经过的匹配字符的颜色

Background        设置光标经过之后匹配的字符串的背景颜色


Buffer highlighting

你可以通过在.emacs加入下面两句实现对C/lisp模式buffer中的高亮显示

;; Turn on font lock mode every time Emacs initializes a buffer ;; for Lisp or C.;;(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)(add-hook 'c-mode-hook 'turn-on-font-lock)

Change color

M-x set-foreground-color RET ->提示输入颜色 你可以Tab两次进行查看所有的颜色选项,用于设置整个环境中字符的颜色,

M-x set-background-colorRET ->提示输入颜色 你可以Tab两次进行查看所有的颜色选项,用于设置整个环境中的背景颜色,

它们两个组合起来类似color-theme-le。

set-cursor-color 用于设置鼠标的颜色


Auto-mode Customization

我们平常说的后缀关联,比如.java 的话它会自动去调用jde模式,这种成对匹配的关系包含在Emacs变量auto-mode-alist中,它是一个点对格式是(regexp . mode),其中mode就是一个主模式名,当Emacs打开一个文件时,它会跟这个list进行从头开始进行正则表达式匹配,如果匹配上就把该匹配串对应的mode输出来。具体如下

CL-USER> (setq auto-mode-alist nil) ;;因为最开始该变量肯定为nil,然后我们每执行一次set就对它的值追加一个点对NILCL-USER> (setq auto-mode-alist (cons '("\\.java$" . java-mode) auto-mode-alist))(("\\.java$" . JAVA-MODE))CL-USER> (setq auto-mode-alist (cons '("\\.ada$" . ada-mode) auto-mode-alist))(("\\.ada$" . ADA-MODE) ("\\.java$" . JAVA-MODE))CL-USER> auto-mode-alist(("\\.ada$" . ADA-MODE) ("\\.java$" . JAVA-MODE))
既然时追加的话,我们可以把cons替换成append.根据上面的流程现在如果我们的文件后缀时.ada,也就时跟第一个匹配,然后对着个串进行(car (cdr str))就能够得到ADA-MODE.

如果是文件开头为msg就调用text-mode的话,配置如下

(setq auto-mode-alist (cons '("^msg-" . text-mode) auto-mode-alist))




原创粉丝点击