Recently, we discussed CEDET in the interview with Eric Ludlam. CEDET has a deep understanding of the source code, and assists the development process by exploiting that knowledge. For example by drawing class diagrams (COGRE) or providing auto-completion for function names and parameters.

Currently, however, CEDET is also be a bit hard to set up effectively, and may also not support your programming language yet. Therefore, it's still useful to look at some other packages that can substitute (part of) the functionality.

For me, auto-complete-mode has been very useful for that. It's not as fancy as CEDET in the sense that it does not really understand the code – but in practice I found it to work quite well for both C/C++, Elisp and shell scripts. It can even display the docstrings of functions. And when editing shell-scripts, it can complete path names as you are editing the scripts; very nice.

To install, follow the instructions. Then, in your .emacs, have something like:

(when (require 'auto-complete-config nil 'noerror) ;; don't break if not installed 
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
  (setq ac-comphist-file  "~/.emacs.d/ac-comphist.dat")

After that, M-x auto-complete-mode to start using it. Alternatively, there's a YouTube-video explaining how to install and use auto-complete-mode; recommended. In any case, it is fully documented.

auto-complete-mode uses a configurable set of sources from which it takes it knowledge about what can be completed. For example, when writing in org-mode, it takes its input from

(ac-source-filename ac-source-abbrev ac-source-dictionary

while in a c-mode buffer it is (in my case):

(ac-source-filename ac-source-yasnippet ac-source-gtags ac-source-abbrev
ac-source-dictionary ac-source-words-in-same-mode-buffers)

You can customize this, and (for the more ambitious), it's possible to add your own sources as well.


E.L.K. said...

It seems to be very poweful addition to emacs, thank you.

I'm curious how it will fit into my usage. (:

Anonymous said...

Thanks for nice info about this package.
I would be grateful if you write some comment about predictive/completion-ui library.


Richard said...

Comparing auto-complete with cedet is a little like comparing apples with oranges. CEDET provides the parsing that can feed auto-complete. auto-complete really provides the UI to various completion backends.That said, I think you're right: CEDET is uncomfortably difficult to set up and the differences between the emacs shipped version and the downloadable sources add another layer of confusion.

Autocomplete is a great front end however - I particularly like the completion candidate docstring pane which appears with elisp for example.

Regarding cedet : there is an ac-source-semantic backend which uses the semantic portion of cedet to provide completions for all languages which have a relevant parser in semantic.

Anonymous said...

Does the help feature work with C/C++ using GNU global (by providing the prototype of the function)?

djcb said...

@Anonymous: it does work with GNU-global, but it only expands function names, not the arguments.

Adam said...

It's nice but it can freeze Emacs on occasion.

Anonymous said...

Might also want to look into hippie-expand as well, since it seems similar to auto-complete-mode.

Tried CEDET and had to remove it, as it slowed my core i7 920 to a crawl when working on a (reasonably) large C/C++ project.