转:http://blog.csdn.net/u010164190/article/details/60867803
1.下载cscope和auto-complete
地址:http://download.csdn.net/detail/u010164190/9892170
2.安装:# tar -zxf cscope-xx.x.tar.gz
# cd cscope-xx.x
# ./configure
# make
# make install
//然后把contrib/xcscope/目录下的cscope-indexer复制到PATH目录比如/usr/local/bin
# cp contrib/xcscope/cscope-indexer /usr/local/bin //或者/usr/bin
# chmod 777 /usr/local/bin/cscope-indexer
<1>禁止每次重新加载索引
//将/usr/local/bin/cscope-indexer 159行修改
cscope -b -i $LIST_FILE -f $DATABASE_FILE
替换为:
cscope -q -b -i $LIST_FILE -f $DATABASE_FILE
<2>添加Java/aidl文件
cscope-indexer 默认只会扫描 C/C++ 的源码
egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
改成:
egrep -i '\.([chly](xx|pp)*|cc|hh|java|aidl)$' | \
然后在Emacs 中创建索引
3.配置接着whereis emacs 看下emacs安装在哪里,
把cscope-xx.x目录下的 contrib/xcscope/xcscope.el文件拷贝到~/emacs.d/site-lisp/目录下面.
# cp contrib/xcscope/xcscope.el ~/emacs.d/site-lisp/
# chmod 777 ~/emacs.d/site-lisp/xcscope.el
4、在.emacs文件中添加
(require 'cc-mode)(add-to-list 'load-path "~/.emacs.d/site-lisp")
(require 'xcscope)
(setq cscope-do-not-update-database t)
(global-set-key (kbd "M-3") 'cscope-index-files)
(global-set-key (kbd "M-4") 'cscope-find-this-symbol)
(global-set-key (kbd "M-5") 'cscope-find-global-definition)
5、安装autocomplete自动补全工具
<1>配置环境
# tar -xjf autocomplete.tar.bz2
# cd autocomplete/rope
# sudo Python setup.py install
# cd ../ropemacs
# sudo python setup.py install
# cd ../Pymacs-0.23
# sudo python setup.py install
# cp pymacs.el ~/.emacs.d
# cp ../auto-complete.el ../auto-complete-config.el ~/.emacs.d/site-lisp
<2>配置.emacs
add-to-list 'load-path "~/.emacs.d/site-lisp”)
(require 'auto-complete)
(global-auto-complete-mode t)
(require 'auto-complete-config)
(ac-ropemacs-initialize)
(global-auto-complete-mode t)
(define-key ac-complete-mode-map "\t" 'ac-expand)
(define-key ac-complete-mode-map "\r" 'ac-complete)
(define-key ac-complete-mode-map "\M-n" 'ac-next)
(define-key ac-complete-mode-map "\M-p" 'ac-previous)
(setq ac-auto-start 3)
(setq ac-dwim t)
(set-default 'ac-sources '(ac-source-abbrev ac-source-words-in-buffer))
(setq ac-modes
(append ac-modes
'(eshell-mode
)))