By: 潘云登
Date: 2009-7-8
Email: intrepyd@gmail.com
Homepage:http://blog.csdn.net/intrepyd
Copyright: 该文章版权由潘云登所有。可在非商业目的下任意传播和复制。
对于商业目的下对本文的任何行为需经作者同意。
写在前面
CEDET是Collection of Emacs Development Environment Tools的缩写,用以将Emacs改装成高级的程序开发工具。它提供了丰富多彩的功能,如工程管理,智能补全,代码生成,UML图等等。这里,介绍一些平时编程中最常使用的三个功能:代码补全,查找定义和查找引用。
本文主要参考:CEDET主页,《A Gentle introduction to Cedet》,以及曹乐的《在Emacs下用C/C++编程》。
安装 CEDET
从CEDET主页上下载源码包,解压到任意地方,如~/.emacs.d/site-lisp。在终端下,进入解压后的文件夹,执行下面的命令,进行编译。
make EMACS=emacs |
在.emacs文件中加入如下内容,加载CEDET。
(load-file "~/.emacs.d/site-lisp/cedet-1.0pre6/common/cedet.el") |
配置 CEDET
这里,将要使用的三个功能是通过执行CEDET定义的不同命令来完成的,所以往.emacs配置文件中加入的主要是这些命令的按键绑定。另外,打开了一个代码折叠功能,对阅读较长文件略有帮助。现在,一并给出需要在.emacs中添加的内容,相关作用以注释形式给出,稍后再详细说明。
;;;; 具体说明可参考源码包下的INSTALL文件,或《A Gentle introduction to Cedet》 ;; Enabling Semantic (code-parsing, smart completion) features ;; Select one of the following: ;;(semantic-load-enable-minimum-features) ;;(semantic-load-enable-code-helpers) ;;(semantic-load-enable-gaudy-code-helpers) (semantic-load-enable-excessive-code-helpers) ;;(semantic-load-enable-semantic-debugging-helpers)
;;;; 使函数体能够折叠或展开 ;; Enable source code folding (global-semantic-tag-folding-mode 1)
;; Key bindings (defun my-cedet-hook () (local-set-key [(control return)] 'semantic-ia-complete-symbol) (local-set-key "/C-c?" 'semantic-ia-complete-symbol-menu) (local-set-key "/C-cd" 'semantic-ia-fast-jump) (local-set-key "/C-cr" 'semantic-symref-symbol) (local-set-key "/C-cR" 'semantic-symref)) (add-hook 'c-mode-common-hook 'my-cedet-hook)
;;;; 当输入"."或">"时,在另一个窗口中列出结构体或类的成员 (defun my-c-mode-cedet-hook () (local-set-key "." 'semantic-complete-self-insert) (local-set-key ">" 'semantic-complete-self-insert)) (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook) |
对于五种模式,后一种总是包含前一种的功能。其具体作用不甚了解,唯一可以观察到的是,当光标停留在函数调用上时,如printf,能够显示函数原型。semantic-load-enable-gaudy-code-helpers与semantic-load-enable-excessive-code-helpers的区别在于,前者将函数原型显示在缓冲区顶部,后者显示在状态栏。
代码补全,使用semantic-ia-complete-symbol和semantic-ia-complete-symbol-menu命令,后者以弹出菜单形式显示所有可能的选项。这里的补全主要是针对函数名和变量名。
查找定义和引用,分别使用semantic-ia-fast-jump和semantic-symref-symbol,semantic-symref命令。semantic-symref-symbol请求输入要查找的符号,semantic-symref则查找光标所在处的符号。之前使用cscope完成此类工作(可参考《Cscope在emacs中的配置与使用》)。cscope常用来阅读大型工程的源码,如linux内核。相比之下,semantic更加轻便,无须额外的数据库文件,更适于平时的编程工作。它可以查找到库头文件中的函数声明。遗憾的是,无法查找到上层文件夹中的内容。目前没有找到解决办法,先将就用吧:)
更强大的代码补全
semantic的补全基于编程语义,emacs自带的hippie-expand则提供更为强大的编辑补全功能。这里,直接将曹乐的配置内容添加到.emacs文件中。
;;;;自动补齐策略 (defun my-indent-or-complete () (interactive) (if (looking-at "//>") (hippie-expand nil) (indent-for-tab-command)) )
(global-set-key [(control tab)] 'my-indent-or-complete)
(autoload 'senator-try-expand-semantic "senator") (setq hippie-expand-try-functions-list '( senator-try-expand-semantic try-expand-dabbrev try-expand-dabbrev-visible try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-expand-list try-expand-list-all-buffers try-expand-line try-expand-line-all-buffers try-complete-file-name-partially try-complete-file-name try-expand-whole-kill ) ) |
相关推荐
emacs 配置(cedet, ecb, yasnipped),改键工具
emacs ecb cedet源码包 包括: emacs-23.4.tar.gz emacs-24.3.tar.gz ecb-2.40.zip cedet-1.0.1.tar.gz cedet-1.1.tar.gz
cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb .emacs cedet ecb ....
2、适用于windows emacs23.1的cedet 3、ecb 4、distel(for erlang) 具有的功能: 1、隐藏工具栏、滚动条 2、自动保存会话(desktop) 3、颜色主题(color-theme) 4、启动时窗口最大化(maxtheme) 5、erlang-...
个人emacs配置,ecb, cedet, c++, dot emacs, speeder 用于平时备份使用。
EMACS 23.1 CEDET 1.0pre7 ECB 2.33 cscope 15.7 诸多其他插件及优化配置 使用方法: 覆盖Emacs安装目录下的site-lisp文件夹 然后在C盘根目录建立一个.emacs文件,文件的内容为: (require 'examyes-main)
emacs lisp with autocomplete cedet company doxymacs ecb yasnippet etc.
emacs-23.2-bin-i386 含cedet,auto-complete,doxymacs,yasnippet,cscope,ecb .emacs 已做基本配置
emacs lisp dea cedet 更好的使用emacs
本配置文件基于网上提供的其他配置文件进行修改。 支持: emacs 24 +cedet 1.1 +ecb 2.40 源配置文件下载地址: http://download.csdn.net/detail/karotte/3812760
Alex Ott的cedet配置文件,通过这个,可以在emacs下支持代码自动补全等VC Assist之类的功能。
Emacs版本:23.2.1 操作系统:RedHat AS 5.4 将该cedet-1.0和ecb-2.32解压后, 通过修改.emacs文件来加载cedet和ecb即可
emacs 的完全配置, 将emacs配置为IDE 代码补全,模板公功能。 函数跳转, 工程管理, 等等
在这个包里面,cedet是cvs版的,在这里公布一下,各位就不必用cvs去下载了,(在windows下用cvs下载比较麻烦),他跟最新的emacs-23.1配合,在windows下比较好。cedet-1.0pre6比较适合早版本的,本人在linux下用的...
emacs的好东西,谁用谁知道,大神都用
emacs 实用配置 auto-complete + helm gtags + 实用小函数 快捷好用 远离ecb cedet 之类的
包含常用emcas需要的插件,以及.emacs 配置目录: └─site-lisp │ color-theme.el │ ibuffer.el │ ido.el │ linum.el │ redo.el │ session.el │ tabbar.el │ xcscope.el ├─cedet-1.0pre6 ├─...
可以在命令窗口中独立使用matlabShell.exe,这样做可以清除许多安装难题,从而帮助确定外壳安装或matlab.el安装是否存在任何问题。 点emacs 有关详细信息,请按照Matlab模式说明进行操作。 您的emacs初始化应该包含...
一个比较简单的,仅用yasnippet,ecb,cedet三个插件的emacs配置文件
auto-complete-1.3 cedet-1.0 cscope-15.7a doxymacs-1.8.0 ecb-2.40 yasnippet-0.6.1c