Project detection happens with the list of
instances stored in
ede-project-class-files. The full project
detection scheme works like this:
ede-turn-on-hook on BUFFER.
ede-turn-on-hook turns on
ede-minor-mode looks to see if BUFFER is associated with any
open projects. If not, it calls
ede-load-project-file to find
a project associated with the current directory BUFFER is in.
ede-minor-mode associates the found project with the current
buffer with a series of variables, such as
Once a buffer is associated, EDE minor mode commands will operate on that buffer.
ede-load-project-file is at the heart of detecting
projects, and it works by looping over all the known project autoload
ede-project-autoload using the utility
ede-directory-project-p will call
ede-dir-to-projectfile on every
until one of them returns true. The method
ede-dir-to-projectfile in turn gets the
from the autoload. If it is a string (i.e., a project file name), it
checks to see if that exists in BUFFER’s directory. If it is a
function, then it calls that function and expects it to return a file
nil. If the file exists, then this directory is assumed to be
part of a project, and
ede-directory-project-p returns the
ede-project-autoload that matched.
If the current directory contains the file
that directory is automatically assumed to contain no projects, even
if there is a matching pattern. Use this type of file in a directory
that may contain many other sub projects, but still has a Makefile of
If the current directory is a project, then EDE scans upwards till
it finds the top of the project. It does this by calling
ede-toplevel-project. If this hasn’t already been discovered,
the directories as scanned upward one at a time until a directory with
no project is found. The last found project becomes the project
root. If the found instance of
ede-project-autoload has a
proj-root slot value, then that function is called instead
of scanning the project by hand. Some project types have a short-cut
for determining the root of a project, so this comes in handy.
Getting back to
ede-load-project-file, this now has an instance
ede-project-autoload. It uses the
load-type slot to
both autoload in the project type, and to create a new instance of the
project type found for the root of the project. That project is added
to the global list of all projects. All subprojects are then created
and assembled into the project data structures.