CEDET Quickstart

On emacs-devel, LesHarris said that CEDET worked for him. “Not only that it works better now than it ever has before.” [1] [2]

http://i.imgur.com/OGrq6.png

He says:

For the screenshot I opened up a random Emacs source file, went to a random function, and tried to complete a structure. In this case it was glyph_matrix, and we can see that CEDET has provided a list of all the members of the glyph_matrix struct.
There is a bit prettification going on there, I use AutoComplete Mode and its AC-Semantic backend to do the overlay-based completion window but the heavy lifting is all CEDET.

This is the configuration he uses:

;; Semantic
(global-semantic-idle-completions-mode t)
(global-semantic-decoration-mode t)
(global-semantic-highlight-func-mode t)
(global-semantic-show-unmatched-syntax-mode t)

;; CC-mode
(add-hook 'c-mode-hook '(lambda ()
        (setq ac-sources (append '(ac-source-semantic) ac-sources))
        (local-set-key (kbd "RET") 'newline-and-indent)
        (linum-mode t)
        (semantic-mode t)))

;; Autocomplete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (expand-file-name
             "~/.emacs.d/elpa/auto-complete-1.4.20110207/dict"))
(setq ac-comphist-file (expand-file-name
             "~/.emacs.d/ac-comphist.dat"))
(ac-config-default)

I found that semantic-idle-completions-mode interferes with autocomplete and had to disable it for autocomplete to work normally. - TaylanUB

The example obove is very outdated and brought up many errors. As this is more an everyone-always-butts-in-Wiki, I want to share my own version of this code which worked for me:

(setq package-enable-at-startup nil)
(package-initialize)

;; -----------
(load-file "~/.emacs.d/cedet-1.1/common/cedet.el") ;; your cedet.el load path

;; Enable EDE (Project Management) features
(global-ede-mode 1)
(semantic-load-enable-excessive-code-helpers)      ; Enable prototype help and smart completion 
;;(global-srecode-minor-mode 1)            ; Enable template insertion menu

;; Semantic
(global-semantic-idle-scheduler-mode)
(global-semantic-idle-completions-mode)
(global-semantic-decoration-mode)
(global-semantic-highlight-func-mode)
(global-semantic-show-unmatched-syntax-mode)

;; CC-mode
(add-hook 'c-mode-common-hook '(lambda ()
        (setq ac-sources (append '(ac-source-semantic) ac-sources))
))

;; Autocomplete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (expand-file-name
             "~/.emacs.d/elpa/auto-complete-1.4.20110207/dict"))
(setq ac-comphist-file (expand-file-name
             "~/.emacs.d/ac-comphist.dat"))
(ac-config-default)
  • Problems

There are some problems with loading the requirements of EDE. If you encounter the following error message while loading a EDE project, try to require all proj-* files.

Error: eieio-persistent-validate/fix-slot-value: Wrong type argument: arrayp, nil

Fix:

    (require 'cedet)
    (require 'eieio)
    (require 'eieio-speedbar)
    (require 'eieio-opt)
    (require 'eieio-base)
    (require 'ede/source)
    (require 'ede/base)
    (require 'ede/auto)
    (require 'ede/proj)
    (require 'ede/proj-archive)
    (require 'ede/proj-aux)
    (require 'ede/proj-comp)
    (require 'ede/proj-elisp)
    (require 'ede/proj-info)
    (require 'ede/proj-misc)
    (require 'ede/proj-obj)
    (require 'ede/proj-prog)
    (require 'ede/proj-scheme)
    (require 'ede/proj-shared)

CategoryProgrammerUtils