emacs中使用semantic实现c代码自动完成功能

阅读更多

环境:

windows xp

emacs 23 自已编译的cvs版

cedet cvs版(当前的1.0pre4提示的速度太慢了,cvs中的提示出现速度飞快)

 

配置过程备忘:

1.下载cvs版cedet

cvs -z3 -d:pserver:[email protected]:/cvsroot/cedet co -P cedet

 

2.编译cedet

在windows中用emacs来编译cedet。在emacs中打开cedet-build.el

M-x eval-buffer
M-x cedet-build-in-this-emacs

编译cedet。

 

3.按照INSTALL中的配置来加载CEDET

;; Load CEDET
(load-file (concat site-lisp-path "/cedet/common/cedet.el"))

;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; Enable EDE for a pre-existing C++ project
;; (ede-cpp-root-project "NAME" :file "~/myproject/Makefile")


;; Enabling Semantic (code-parsing, smart completion) features
;; Select one of the following:

;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;;   imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as the nascent intellisense mode
;;   decoration mode, and stickyfunc mode (plus regular code helpers)
;; (semantic-load-enable-guady-code-helpers)

;; * This enables the use of Exuberent ctags if you have it installed.
;; (semantic-load-enable-all-exuberent-ctags-support)

;; Enable SRecode (Template management) minor-mode.
;; (global-srecode-minor-mode 1)

 

4. 配置头文件,这一步比较关键,配置不正确则不会出现提示,这里我没有直接使用"/",在windows下试了这个似乎不能用,下面是我的配置的一部分:

(add-to-list 'semanticdb-project-roots "e:/devel/gtk")

(global-semanticdb-minor-mode 1)
(semantic-add-system-include "d:/cygwin/usr/include/" 'c-mode)
(semantic-add-system-include "d:/cygwin/usr/include/" 'c++-mode)
(semantic-add-system-include "d:/GTK/include/" 'c-mode)
(semantic-add-system-include "d:/GTK/include/gtk-2.0/" 'c-mode)
(semantic-add-system-include "d:/GTK/include/glib-2.0/" 'c-mode)

 

我的配置产生的~/.semanticdb如下:

!drive_d!GTK!include!glib-2.0!glib!semantic.cache*
!drive_d!GTK!include!glib-2.0!gobject!semantic.cache*
!drive_d!GTK!include!glib-2.0!semantic.cache*
!drive_d!GTK!include!gtk-2.0!gdk!semantic.cache*
!drive_d!GTK!include!gtk-2.0!gdk-pixbuf!semantic.cache*
!drive_d!GTK!include!gtk-2.0!gtk!semantic.cache*
!drive_d!cygwin!home!zhujie!.emacs.d!semantic.cache*
!drive_d!cygwin!usr!include!machine!semantic.cache*
!drive_d!cygwin!usr!include!semantic.cache*
!drive_d!cygwin!usr!include!sys!semantic.cache*
!drive_d!emacs!site-lisp!cedet!semantic.cache*
!drive_e!devel!gtk!simple!semantic.cache*

 

5.配置快捷键,我的提示快捷键定义到了c-enter上

(require 'semantic-sb nil t)
(when (require 'semantic-ia nil t)
;  (global-set-key [(control return)] 'semantic-ia-complete-symbol)
  (global-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
  )

 

效果图:

 

 

  • emacs中使用semantic实现c代码自动完成功能_第1张图片
  • 大小: 50.5 KB
  • 查看图片附件

你可能感兴趣的:(Emacs,C#,C++,C,CVS)