Chinaunix首页 | 论坛 | 博客
  • 博客访问: 536974
  • 博文数量: 146
  • 博客积分: 5030
  • 博客等级: 大校
  • 技术积分: 1820
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-16 20:57
文章分类

全部博文(146)

文章存档

2011年(1)

2010年(4)

2009年(30)

2008年(111)

我的朋友

分类: LINUX

2011-11-17 21:05:39

1. Emacs 自带的hippie-expand (参考的是王垠的)
hippie-expand是 Emacs 自带的功能,
把M-/ 绑定到 hippie-expand,在.emacs文件中加入
;;绑定按键 
(global-set-key [(meta ?/)] 'hippie-expand)

hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优先使用表最前面的函数来补全。通常的设置是:

(setq hippie-expand-try-functions-list 
'(try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
首先使用当前的buffer补全,如果找不到,就到别的可见的窗口里寻找,
如果还找不到,那么到所有打开的buffer去找,如果还……那么到kill-ring里,
到文件名,到简称列表里,到list,…… 当前使用的匹配方式会在 echo 区域
显示.
确实是非常好用,基本上我M-/就能到达我想要的了.

2 采用etags
etags能像cscope那样,在代码里跳来跳去,比如查找函数,变量等,它还能够自动补齐代码.
1),先生成etags文件
find . /usr/include/ -name "*.c" -or -name "*.cpp" -or -name "*.hpp" -or -name "*.h" |xargs etags --members --language=c++
2).配置.emacs
(setq tags-file-name "~/TAGS")
3),使用
在emacs中,M-tab 就可以自动补齐了,不过有时候还是不是很好用. 
M-. 查找一个tag,比如函数定义类型定义等。
C-u M-. 查找下一个tag的位置
M-* 回到上一次运行M-.前的光标位置。 M-TAB 自动补齐函数名。 

3 采用cedet包
1)下载cedet 
网址是
2)编译
tar -zxf cedet-1.0pre3.tar.gz
cd cedet-1.0pre3
make
如果make不成功的话,就看看那个说明吧
3)配置
查看emacs的配置文件在哪里
whereis emacs
拷贝编译好了的cedet 
cp -r cedet-1.0pre3 /usr/share/emacs/
查看是否有我们需要的那个文件
ls /usr/share/emacs/cedet-1.0pre3/common/cedet.el

配置.emacs文件,在.emacs文件中加入
;;;;;;;;;;cedet
(load-file "/usr/share/emacs/cedet-1.0pre3/common/cedet.el")

;;设置检索范围
(setq semanticdb-project-roots 
(list
(expand-file-name "/")));;可以设置为项目的顶级目录

;;绑定按键,ctr+tab,以下三种,任意选择一个,我喜欢第二个
;;(global-set-key [(control tab)] 'senator-complete-symbol);
(global-set-key [(control tab)] ' senator-completion-menu-popup)
;; (global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)

4)使用
在一个未输入完成的函数上尝试下ctr+tab键

阅读(1749) | 评论(0) | 转发(0) |
0

上一篇:emacs配置文档,持续更新中

下一篇:没有了

给主人留下些什么吧!~~