EDE, short for Emacs Development Environment, is a generic interface for managing projects. In EDE, a project hierarchy matches a directory hierarchy. The project's topmost directory is called the project root, and its subdirectories are sub-projects.

EDE can do many things but we will just use it for code completion at project level. To demonstrate the use of EDE, we will create a little project of our own.

To setup EDE:

( require ' ede ) ( global-ede-mode )

Now, let's try completion in main.c using moo-complete or company-semantic . Nothing also happens. It is because Semantic only looks for header files in current directory by default. If you put it elsewhere, you have to tell Semantic where it is. This is not limited to only Semantic; you have to specify project include path in Eclipse as well.

Create a new file called cedet-projects.el in ~/.emacs.d/ .

in . In this file, add a new ede-cpp-root-project in this form:

( ede-cpp-root-project "project_root" :file "/dir/to/project_root/Makefile" )

The first argument to ede-cpp-root-project is project name. :file argument specifies path to project root. You must create a file in the project root, since EDE uses that file as an "anchor" to project root; in our case, Makefile is the anchor file. Not sure why EDE just straightly uses root directory.

Add include directories specific to the project and in your system:

( ede-cpp-root-project "project_root" :file "/dir/to/project_root/Makefile" :include-path ' ( "/include1" "/include2" ) ;; add more include ;; paths here :system-include-path ' ( "~/linux" ) )

:include-path specifies directories local to your projects that EDE should search first when looking for a header file. :incluide-path is relative to project root specified in :file .

:system-include-path specifies system include paths that do not belong to current project. Note that despite it is called system-include-path , it does not have to be in place like /usr/include . You can specify any include directories outside of your current project as "system headers".

After done setting up your project, save the file and execute that ede-cpp-root-project expression with C-x C-e. Now, Semantic is aware of your project include paths. However, you have to do one last thing: either close the file main.c and reopen it or M-x semantic-force-refresh to tell Semantic to analyze main.c again. Otherwise, Semantic will still keep the previous parsing result of this file and completion candidates won't be available. As a result, it is important to load EDE projects defined by ede-cpp-root-project before opening any project file.

After that, try auto-completion and you will see everything is working fine again:

Summary:

EDE, short for Emacs Development Environment, is a generic interface for managing projects.

EDE enables Semantic to find sources and perform project level completions.

To add a C/C++ project, simply create a project definition with this template in a file, such as ede-projects.el :

( ede-cpp-root-project "project_root" :file "/dir/to/project_root/Makefile" :include-path ' ( "/include1" "/include2" ) ;; add more include ;; paths here :system-include-path ' ( "~/linux" ) )

Load ede-projects.el when Emacs start.

when Emacs start. If you have opening files, either close or refresh it with M-x semantic-force-refresh to make Semantic aware of new changes.

Later, you will also learn another project management tool called Projectile . You may ask, why another project management tool? The differences are:

EDE is older, Projectile appears recently.

EDE manages project files to integrate with specific build system and generate corresponding build file (such as Makefile; these features are not covered in this guide). Projectile provides generic file management operations such as quickly jump to file/directory in project, list buffers that belong to current project…

EDE is part of CEDET suite; it is geared toward Semantic. For example, we used EDE to tell Semantic where to retrieve correct include paths for current project to perform smart completion in previous section. Projectile provides a generic interface for managing your project under a VCS or some supported build system.

Projectile is easier to learn than EDE.

Both have some overlapping in features, such as Projectile provides basic tag navigation in project, but in general they support each other. For our basic usage, we use EDE for smart completion as in previous section and Projectile to navigate our project effortlessly.