1 ;;; ede/auto.el --- Autoload features for EDE
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; EDE Autoloads are a way to refer to different project types without
25 ;; loading those projects into Emacs.
27 ;; These routines are used to detect a project in a filesystem before
28 ;; handing over control to the usual EDE project system.
34 (defclass ede-project-autoload
()
36 :documentation
"Name of this project type")
38 :documentation
"The lisp file belonging to this class.")
39 (proj-file :initarg
:proj-file
40 :documentation
"Name of a project file of this type.")
41 (proj-root :initarg
:proj-root
43 :documentation
"A function symbol to call for the project root.
44 This function takes no arguments, and returns the current directories
45 root, if available. Leave blank to use the EDE directory walking
47 (initializers :initarg
:initializers
50 "Initializers passed to the project object.
51 These are used so there can be multiple types of projects
52 associated with a single object class, based on the initilizeres used.")
53 (load-type :initarg
:load-type
54 :documentation
"Fn symbol used to load this project file.")
55 (class-sym :initarg
:class-sym
56 :documentation
"Symbol representing the project class to use.")
57 (new-p :initarg
:new-p
60 "Non-nil if this is an option when a user creates a project.")
62 "Class representing minimal knowledge set to run preliminary EDE functions.
63 When more advanced functionality is needed from a project type, that projects
64 type is required and the load function used.")
66 (defvar ede-project-class-files
68 (ede-project-autoload "edeproject-makefile"
69 :name
"Make" :file
'ede
/proj
70 :proj-file
"Project.ede"
71 :load-type
'ede-proj-load
72 :class-sym
'ede-proj-project
)
73 (ede-project-autoload "edeproject-automake"
74 :name
"Automake" :file
'ede
/proj
75 :proj-file
"Project.ede"
76 :initializers
'(:makefile-type Makefile.am
)
77 :load-type
'ede-proj-load
78 :class-sym
'ede-proj-project
)
79 (ede-project-autoload "automake"
80 :name
"automake" :file
'ede
/project-am
81 :proj-file
"Makefile.am"
82 :load-type
'project-am-load
83 :class-sym
'project-am-makefile
85 "List of vectors defining how to determine what type of projects exist.")
87 ;;; EDE project-autoload methods
89 (defmethod ede-project-root ((this ede-project-autoload
))
90 "If a project knows its root, return it here.
91 Allows for one-project-object-for-a-tree type systems."
94 (defmethod ede-project-root-directory ((this ede-project-autoload
)
96 "If a project knows its root, return it here.
97 Allows for one-project-object-for-a-tree type systems.
98 Optional FILE is the file to test. If there is no FILE, use
101 (setq file default-directory
))
102 (when (slot-boundp this
:proj-root
)
103 (let ((rootfcn (oref this proj-root
)))
106 (funcall rootfcn file
)
111 (defmethod ede-dir-to-projectfile ((this ede-project-autoload
) dir
)
112 "Return a full file name of project THIS found in DIR.
113 Return nil if the project file does not exist."
114 (let* ((d (file-name-as-directory dir
))
115 (root (ede-project-root-directory this d
))
116 (pf (oref this proj-file
))
117 (f (cond ((stringp pf
)
118 (expand-file-name pf
(or root d
)))
119 ((and (symbolp pf
) (fboundp pf
))
120 (funcall pf
(or root d
)))))
122 (when (and f
(file-exists-p f
))
128 ;;; ede/auto.el ends here