现在的位置: 首页 > 综合 > 正文

关于emacs的一些东西

2013年02月23日 ⁄ 综合 ⁄ 共 2910字 ⁄ 字号 评论关闭

我是一个emacs新手,所以关于emacs多么强大可扩展性多好之类的就不扯了,我听说的却没实践,所以不知道:)不过总之我打算开始坚持使用emacs了。vim也用过一阵子。刚从vim转向使用emacs,老是把手放在hjkl上并期望光标移动...

关于emacs代表什么,倒是觉得这个解释非常有趣:
Escape Meta Alt Ctrl Shift

这里笔记下如何获得emacs以及其配套工具的资源以备查(linux上的Emacs)。

1.获取emacs
这里可以download GNU emacs源码包:

http://www.gnu.org/software/emacs/

如果使用Ubuntu distribution并且网络可用的话(当然要apt-get可用),装Emacs没那么麻烦,不必自己去获取源码包并安装的。
Ubuntu下: $sudo apt-get install emacs
CentOS下: $sudo yum install emacs
一切都由yum和apt-get搞定。
CentOS也自带emacs的,如果安装的时候安装了它的话。不过不是最新版本,好像是21的。如果想用最新版的GNU emacs的话,还是自己去下源码包并编译安装吧。
Ubuntu下apt-get得到的是最新的emacs 23版本。

2.emacs的color-theme
试试用这里的color-theme.el来设置想要的颜色风格:

http://lifegoo.pluskid.org/wiki/EmacsColorTheme.html

先在网页底部下载那个color-theme.el扩展包,然后把这个扩展包放到~/.emacs.d/目录下(这里应该是emacs默认的用户扩展包放置处)。
然后打开emacs默认配置文件:
$vim ~/.emacs
如果原来没有这个.emacs配置文件的话,就创建它。emacs默认使用用户目录下的.emacs文件作为配置文件。
在.emacs中添加如下两行(;;代表注释,就像C/C++中的//或shell script中的#一样):

;; 表示加入“~/.emacs.d”为扩展包加载路径
(setq load-path(cons(expand-file-name "~/.emacs.d")load-path))

;; 加载color-theme.el
(require 'color-theme)

然后进入emacs, 使用M-x color-theme-select命令来选择喜欢的颜色主题 。它会打开一个列表,在每个列表项目上回车会应用那个颜色主题,如果选上了某个主题,按一下 d ,会出现类似:
color-theme-sitaramv-nt is an interactive compiled Lisp function in `color-theme.el'.(color-theme-sitaramv-nt)Black foreground on white background.Includes faces for font-lock, widget, custom, speedbar.[back]

的东西,其中那句 (color-theme-sitaramv-nt) 加入到你的 ~/.emacs 里面去,就可以永久应用这个颜色主题了。


3.
要将emacs打造成为一个编辑和阅读源代码的利器,以下配套工具是必不可少的:

3.1
cscope:

http://cscope.sourceforge.net/

Cscope is a developer's tool for browsing source code. It has an impeccable Unix pedigree, having been
originally developed at Bell Labs back in the days of the PDP-11. Cscope was part of the official
AT&T Unix distribution for many years, and has been used to manage projects involving 20 million lines of code!

Cscope是个用来浏览源代码的开发工具。它有纯正的Unix血统,发源于贝尔实验室,那时是贝尔实验室还在使用PDP-11机器的时代。Cscope一直是AT&T官方 Unix发布版的一部分,并曾用以管理两千万行源代码的项目。

首先编译并安装cscope.怎么编译和安装cscope请看源码包中的说明,这是一个linuxer的基本功,一般来说是configure; make; make install;
由于我是直接$sudo apt-get install cscope
所以编译源码包倒是省了。不过apt-get把xcscope.el放错了。结果我还是得自己去重新下源码包,Faint。
把xcscope.el 拷贝到 load-path 里面(color-theme那节已经说过什么是load-path了)包含的目录里面。xcscope.el在下载下来的源码包里面。怎么在源码包里面找到xcscope.el?
答案是$sudo find . -name xcscope.el

请参考:

http://lifegoo.pluskid.org/wiki/EmacsCscope.html

3.2
ecb:
http://ecb.sourceforge.net/

ECB stands for "Emacs Code Browser". While Emacs already has good
editing support for many modes, its browsing support is somewhat lacking.
ECB的意思是“Emacs Code Browser”,emacs代码浏览器。由于emacs已经具有很好的编辑功能和很多的编辑模式,因此它的代码浏览功能支持就不是那么好了...

编译并安装ecb。
在.emacs里面加入

(add-to-list 'load-path "你放ecb的目录")
;; 例如(add-to-list 'load-path "~/.emacs.d/ecb-2.32")
(require 'ecb)

3.3
cedet:
http://cedet.sourceforge.net/

CEDET is a
Collection of Emacs Development
Environment Tools
written with the end goal of creating an advanced development environment in Emacs.
CEDET是一个emacs开发工具集成环境,目的是为了将emacs打造成高级IDE.

编译、安装和配置请参考:

http://blog.csdn.net/hide1713/archive/2007/06/10/1647209.aspx

http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html

PS,关于emacs配置文件的基本知识参考:

http://blog.csdn.net/schumyxp/archive/2008/04/10/2278268.aspx

抱歉!评论已关闭.