]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/ede/base.el
Update copyright year to 2014 by running admin/update-copyright.
[gnu-emacs] / lisp / cedet / ede / base.el
index ce3d4a036f35cbe8dd7d7714d92f2df7b5ad89fd..283f9dccac795d9af36530079c9b7619a6b4a619 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ede/base.el --- Baseclasses for EDE.
 
-;; Copyright (C) 2010-201 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 
@@ -135,7 +135,9 @@ other desired outcome.")
    (dirinode :documentation "The inode id for :directory.")
    (file :type string
         :initarg :file
-        :documentation "File name where this project is stored.")
+        :documentation "The File uniquely tagging this project instance.
+For some project types, this will be the file that stores the project configuration.
+In other projects types, this file is merely a unique identifier to this type of project.")
    (rootproject ; :initarg - no initarg, don't save this slot!
     :initform nil
     :type (or null ede-project-placeholder-child)
@@ -163,7 +165,7 @@ and querying them will cause the actual project to get loaded.")
            :documentation "Sub projects controlled by this project.
 For Automake based projects, each directory is treated as a project.")
    (targets :initarg :targets
-           :type list
+           :type ede-target-list
            :custom (repeat (object :objectcreatefcn ede-new-target-custom))
            :label "Local Targets"
            :group (targets)
@@ -287,10 +289,7 @@ All specific project types must derive from this project."
   "For the project in which OBJ resides, execute FORMS."
   `(save-window-excursion
      (let* ((pf (if (obj-of-class-p ,obj ede-target)
-                   ;; @todo -I think I can change
-                   ;; this to not need ede-load-project-file
-                   ;; but I'm not sure how to test well.
-                   (ede-load-project-file (oref ,obj path))
+                   (ede-target-parent ,obj)
                  ,obj))
            (dbka (get-file-buffer (oref pf file))))
        (if (not dbka) (find-file (oref pf file))
@@ -307,7 +306,8 @@ All specific project types must derive from this project."
 ;;
 (defcustom ede-project-placeholder-cache-file
   (locate-user-emacs-file "ede-projects.el" ".projects.ede")
-  "File containing the list of projects EDE has viewed."
+  "File containing the list of projects EDE has viewed.
+If set to nil, then the cache is not saved."
   :group 'ede
   :type 'file)
 
@@ -317,48 +317,49 @@ All specific project types must derive from this project."
 (defun ede-save-cache ()
   "Save a cache of EDE objects that Emacs has seen before."
   (interactive)
-  (let ((p ede-projects)
-       (c ede-project-cache-files)
-       (recentf-exclude '( (lambda (f) t) ))
-       )
-    (condition-case nil
-       (progn
-         (set-buffer (find-file-noselect ede-project-placeholder-cache-file t))
-         (erase-buffer)
-         (insert ";; EDE project cache file.
-;; This contains a list of projects you have visited.\n(")
-         (while p
-           (when (and (car p) (ede-project-p p))
-             (let ((f (oref (car p) file)))
-               (when (file-exists-p f)
-                 (insert "\n  \"" f "\""))))
-           (setq p (cdr p)))
-         (while c
-           (insert "\n \"" (car c) "\"")
-           (setq c (cdr c)))
-         (insert "\n)\n")
-         (condition-case nil
-             (save-buffer 0)
-           (error
-            (message "File %s could not be saved."
-                     ede-project-placeholder-cache-file)))
-         (kill-buffer (current-buffer))
+  (when ede-project-placeholder-cache-file
+    (let ((p ede-projects)
+         (c ede-project-cache-files)
+         (recentf-exclude '( (lambda (f) t) ))
          )
-      (error
-       (message "File %s could not be read."
-               ede-project-placeholder-cache-file))
-
-      )))
+      (condition-case nil
+         (progn
+           (set-buffer (find-file-noselect ede-project-placeholder-cache-file t))
+           (erase-buffer)
+           (insert ";; EDE project cache file.
+;; This contains a list of projects you have visited.\n(")
+           (while p
+             (when (and (car p) (ede-project-p p))
+               (let ((f (oref (car p) file)))
+                 (when (file-exists-p f)
+                   (insert "\n  \"" f "\""))))
+             (setq p (cdr p)))
+           (while c
+             (insert "\n \"" (car c) "\"")
+             (setq c (cdr c)))
+           (insert "\n)\n")
+           (condition-case nil
+               (save-buffer 0)
+             (error
+              (message "File %s could not be saved."
+                       ede-project-placeholder-cache-file)))
+           (kill-buffer (current-buffer))
+           )
+       (error
+        (message "File %s could not be read."
+                 ede-project-placeholder-cache-file))
+
+       ))))
 
 (defun ede-load-cache ()
   "Load the cache of EDE projects."
   (save-excursion
-    (let ((cachebuffer nil))
+    (let ((cachebuffer (get-buffer-create "*ede cache*")))
       (condition-case nil
-         (progn
-           (setq cachebuffer
-                 (find-file-noselect ede-project-placeholder-cache-file t))
-           (set-buffer cachebuffer)
+         (with-current-buffer cachebuffer
+           (erase-buffer)
+           (when (file-exists-p ede-project-placeholder-cache-file)
+             (insert-file-contents ede-project-placeholder-cache-file))
            (goto-char (point-min))
            (let ((c (read (current-buffer)))
                  (new nil)
@@ -612,6 +613,28 @@ instead of the current project."
                (setq cp (ede-parent-project cp)))
              cp)))))
 
+\f
+;;; Utility functions
+;;
+
+(defun ede-normalize-file/directory (this project-file-name)
+  "Fills :directory or :file slots if they're missing in project THIS.
+The other slot will be used to calculate values.
+PROJECT-FILE-NAME is a name of project file (short name, like 'pom.xml', etc."
+  (when (and (or (not (slot-boundp this :file))
+                (not (oref this :file)))
+            (slot-boundp this :directory)
+            (oref this :directory))
+    (oset this :file (expand-file-name project-file-name (oref this :directory))))
+  (when (and (or (not (slot-boundp this :directory))
+                (not (oref this :directory)))
+            (slot-boundp this :file)
+            (oref this :file))
+    (oset this :directory (file-name-directory (oref this :file))))
+  )
+
+
+
 \f
 ;;; Hooks & Autoloads
 ;;