(I tested the following procedure about installing and customizing CEDET for Emacs with GNU Emacs 23 under Ubuntu and Snow Leopard.)
- Install CEDET
- Download the source package of CEDET
- Unpack to ~/.emacs.d/cedet (or other places)
- Compile the package using command
emacs -Q -nw -l cedet-build.el -f cedet-build -f save-buffers-kill-terminal
- Install external tag systems (optionally required by CEDET)
- GNU Global, and/or
- exuberent ctags
- Install ECB
- Download the source package of ECB.
- Unpack into ~/.emacs.d/ecb (or any other directory)
An excellent tutorial about customizing CEDET is here. The author also published his .emacs file which contains a few flaws. Mine based on his is as follows:
;; CEDET (load-file "~/.emacs.d/cedet-1.0pre7/common/cedet.el") (global-ede-mode 'nil) ; do NOT use project manager (semantic-load-enable-excessive-code-helpers) (require 'semantic-ia) ; names completion and display of tags (require 'semantic-gcc) ; auto locate system include files (semantic-add-system-include "~/3rd-party/boost-1.43.0/include/" 'c++-mode) (semantic-add-system-include "~/3rd-party/protobuf-2.3.0/include" 'c++-mode) (require 'semanticdb) (global-semanticdb-minor-mode 1) (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-c>" 'semantic-complete-analyze-inline) (local-set-key "\C-c=" 'semantic-decoration-include-visit) (local-set-key "\C-cj" 'semantic-ia-fast-jump) (local-set-key "\C-cq" 'semantic-ia-show-doc) (local-set-key "\C-cs" 'semantic-ia-show-summary) (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) (local-set-key "\C-c+" 'semantic-tag-folding-show-block) (local-set-key "\C-c-" 'semantic-tag-folding-fold-block) (local-set-key "\C-c\C-c+" 'semantic-tag-folding-show-all) (local-set-key "\C-c\C-c-" 'semantic-tag-folding-fold-all) ) (add-hook 'c-mode-common-hook 'my-cedet-hook) (global-semantic-tag-folding-mode 1) (require 'eassist) ;(concat essist-header-switches ("hh" "cc")) (defun alexott/c-mode-cedet-hook () (local-set-key "\C-ct" 'eassist-switch-h-cpp) (local-set-key "\C-xt" 'eassist-switch-h-cpp) (local-set-key "\C-ce" 'eassist-list-methods) (local-set-key "\C-c\C-r" 'semantic-symref) ) (add-hook 'c-mode-common-hook 'alexott/c-mode-cedet-hook) ;; gnu global support (require 'semanticdb-global) (semanticdb-enable-gnu-global-databases 'c-mode) (semanticdb-enable-gnu-global-databases 'c++-mode) ;; ctags (require 'semanticdb-ectag) (semantic-load-enable-primary-exuberent-ctags-support) (global-semantic-idle-tag-highlight-mode 1)
- control return: whatever the symbol you are typing, this hot key automatically complete it for you.
- C-c?: another way to complete the symbol you are typing
- C-c>: when you typed . or -> after an object name, use this key to show possible public member functions or data members.
- C-cj: jump to the definition of the symbol under cursor
- C-cs: show a summary about the symbol under cursor
- C-cq: show the document of the symbol under cursor
- C-c=: visit the header file under cursor
- C-cp: toggle between the implementation and a prototype of symbol under cursor
- C-ce: when your cursor is in the scope of a class or one of its member function, list all methods in the class
- C-cC-r: show references of the symbol under cursor
- C-cC-c-: fold all
- C-cC-c+: unfold all
- C-c-: fold the block under cursor
- C-c+: unfold the block under cursor
Once CEDET is installed and customized, we can use ECB. Add the following lines into your .emacs file:
(add-to-list 'load-path "~/.emacs.d/ecb-2.40") (require 'ecb) (require 'ecb-autoloads)
In Emacs, we can use M-x ecb-activate to turn on ECB mode. This page shows how to byte compile ECB to make it runs fast.