本文主要是介绍Mac下安装emacs+cscopse+auto-complete(二十九),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第一种方式:安装cscope
# sudo apt install cscope
第二种方式:下载cscope和auto-complete
下载
2.安装:
# tar -zxf cscope-xx.x.tar.gz
# cd cscope-xx.x
# ./configure
# sudo apt-get install libncurses5-dev
# make
# sudo 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 -Rqbk -i $LIST_FILE -f $DATABASE_FILE
#: cscope -Rbkqi //也可这么写
R: 表示把所有子目录里的文件也建立索引
b: 表示cscope不启动自带的用户界面,而仅仅建立符号数据库
q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
k: 在生成索引文件时,不搜索/usr/include目录
i: 列出函数名在哪个文件中<2>添加java/aidl文件
cscope-indexer 默认只会扫描 C/C++ 的源码egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
改成:egrep -i '\.([chly](xx|pp)*|cc|hh|java|aidl|Makefile|te|hal|bp|mk)$' | \
然后在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.el4、在.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)
(global-set-key (kbd "M-6") 'cscope-pop-mark)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)))
这篇关于Mac下安装emacs+cscopse+auto-complete(二十九)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!