1, install the following compent:
#sudo apt-get install -y emacs
#sudo apt-get install -y cscope
#sudo apt-get install -y ctags
#emacs lisp; config from kreatv
#sudo apt-get install global //GNU Global is a source code tagging system (similar to etags, ctags and idutils) that makes it possible to almost instantly find where tags/symbols are defined and referred to in the source code. Read more on http://www.gnu.org/software/global/.
install #gtags-update
http://hi.baidu.com/bamboolsu/blog/item/0499861240ee47225baf5376.html
/// there is a convenience script called gtags-update (located in ~tools/bin) that you can run in an SVN working copy containing a built source tree. The script tells GNU Global to only index the source code files known to SVN.
2, configuration:
2.1 gtags.conf
Copy /etc/gtags.conf (/usr/share/gtags/gtags.conf in older Fedora releases) to ~/.globalrc
Edit ~/.globalrc so that langmap says something like c\:.c and cpp\:.c++.cc.cpp.cxx.hxx.hpp.C.H.h
ubuntu: leosu@leosu:/$ cp ./usr/share/doc/global/examples/gtags.conf ~/.globalrc
2.2 .emacs
2.2.1 .emacs ~/.emacs
./mnt/devtools_trunk/dotfiles/.emacs
http://hi.baidu.com/bamboolsu/blog/item/36efafddd9867f81cc11661e.html
leosu@leosu:/$ cp ./mnt/devtools_trunk/dotfiles/.emacs ~/
2.2.2 gtags.el
Emacs usage : To use Global in Emacs, put(require 'gtags "/usr/share/gtags/gtags.el")
in your ~/.emacs. If you get the error Required feature `gtags' was not provided, use this line instead:
(load "/usr/share/gtags/gtags.el") /需要自己添加.emacs文件 到 ~/ 目录的
2.2.3 设置path ; /home/tools/elisp ; /home/tools/devtools/trunk/elisp;
devtools_trunk https://docs.google.com/file/d/0B-Cu90YBRn0cMGxIM21qU2E3a0k/edit
#sudo mkdir /home/tools
#sudo mkdir /home/tools/devtools/
#cp -fr devtools_trunk /home/tools/devtools/trunk
#$ ls /home/tools/devtools/trunk/
bin doc dotfiles elisp elisp.tar.gz lib share workflex
2.3 emacs 安装配置的地方:/usr/share/emacs/site-lisp/
2.4 使用便利, 别名
Add these two alias to your .bashrc
alias gu='gtags-update' ###GNU GLOBAL source code tagging system; you can directory use gtags to create index files.
alias g='global -g'
#gtags-update http://hi.baidu.com/bamboolsu/blog/item/0499861240ee47225baf5376.html
Enter your working branch: run "gu" $gu
Then you can run "g hellokitty" at any subfolder to search for keyword "hellokitty".
Add "-x" to show result with line number, i.e. "g -x hellokitty"
/ Chee
2.5 kreatv 使用的el 文件:
elisp.tar.gz // https://docs.google.com/file/d/0B-Cu90YBRn0cSURpYzNYRkRSTDA/edit
leosu@leosu:/mnt/devtools_trunk/elisp$ ls /home/tools/devtools/trunk/elisp
c++-header-common.el kreatv-compile.el kreatv-fcode.el markdown-mode.el workflex.el
c++-header.el kreatv-copyright.el kreatv-gtags.el no-trailing-whitespace.el
kreatv-cc-style.el kreatv-env.el kreatv-recommended.el unittest.el
2.6 简单配置
Emacs 有超强的可配置性,1000个人可以有1000种配置,可以有自己的键绑定, 有自定义的函数,有自己喜欢的扩展包。配置放在 home 目录下的 .emacs 里, Emacs 启动的时候会自动读取这个文件。
启动 Emacs 后,C-x C-f ~/.emacs 会 打开 .emacs 文件,如果不存在的话就是新建这个文件。home 目录在哪里呢? 可以 M-x 之后输入 getenv 之后按照提示输入 HOME 得到 home 的位置。Linux 系统很好理解。 Windows 系统,会默认放在 C:\Documents and Settings\username\Application Data 下,有几种方法可以指定 home 的位置:
- 在 我的电脑->属性->高级->环境变量 里添加一个 HOME 环境变量,指定位 置。
- 在注册表 [HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs] (如果没有 GNU 或 Emacs,添加一个即可) 添加 HOME 字符串变量,值为指定的 home 路径。
Emacs 配置使用的语言是 Elisp,Emacs 附带非常详细的 Elisp 手册,可以通 过 M-x info 得到。配置 .emacs 一般只需要几个简单语句,比如:
- (setq variable-name value) 设置变量值,例如 (setq transient-mark-mode t) 设置选定区域范围高亮
- (require 'extension) 安装一个扩展包。
- (load "file-name") 使用一个 .el 文件
- (global-set-key (kbd "C-c f") 'function-name) 全局自定义键绑定
- (define-key dired-mode (kbd "j") 'dired-next-line) 局部键绑定,只在 dired-mode 起作用
- (if ...) 一些简单的判断语句
这里提供一个简单的 .emacs 文件: quick.emacs.el
你可以把它复制到你的 home 目录下并改名为 .emacs 注意有个.
或者用 runemacs.exe -q -l quick.emacs.el 来指定 emacs 使用这个配置文件。
2.7, workflex
/// bin file: https://docs.google.com/file/d/0B-Cu90YBRn0cLVF4OUVIc1p3RGM/edit
///bin file: https://docs.google.com/file/d/0B-Cu90YBRn0cdHkwOWJ2SFhhSE0/edit
3, EmacsTricks-----Some useful Emacs modes
http://hi.baidu.com/bamboolsu/blog/item/0fccffd2054d8414960a1623.html
Reference:
这贴先给一些链接吧。
http://www.gnus.org/software/emacs GNU emacs的官方网站。
http://www.emacswiki.org Emacs用户大本营,有很多非常好的资料
http://learn.tsinghua.edu.cn/homepag...450/emacs.html 我学emacs的初始地,在这里表示对网站作者王垠的感激。
http://learn.tsinghua.edu.cn/homepag...cs24/index.htm 我学emacs的主要教程,sir里好像有人要翻译,不知道翻译完没。
http://www.dotemacs.de/ emacs配置文件的集中营,不过感觉梢旧了些。
http://zhdotemacs.sourceforge.net/emacs/ Emacs 中文化指南,有很多适合咱们中国人使用的技巧。