]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/ede/emacs.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / ede / emacs.el
index e3afe30063cb5dc9ffe6808fd4faccc896c18173..621e8951dd73ab346b1226a26c1314c4d46ecd82 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ede/emacs.el --- Special project for Emacs
 
-;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2015 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
 (declare-function semanticdb-refresh-table "semantic/db")
 
 ;;; Code:
-(defvar ede-emacs-project-list nil
-  "List of projects created by option `ede-emacs-project'.")
-
-(defun ede-emacs-file-existing (dir)
-  "Find a Emacs project in the list of Emacs projects.
-DIR is the directory to search from."
-  (let ((projs ede-emacs-project-list)
-       (ans nil))
-    (while (and projs (not ans))
-      (let ((root (ede-project-root-directory (car projs))))
-       (when (string-match (concat "^" (regexp-quote root))
-                           (file-name-as-directory dir))
-         (setq ans (car projs))))
-      (setq projs (cdr projs)))
-    ans))
 
-;;;###autoload
+;; @TODO - get rid of this.  Stuck in loaddefs right now.
+
 (defun ede-emacs-project-root (&optional dir)
   "Get the root directory for DIR."
-  (when (not dir) (setq dir default-directory))
-  (let ((case-fold-search t)
-       (proj (ede-emacs-file-existing dir)))
-    (if proj
-       (ede-up-directory (file-name-directory
-                          (oref proj :file)))
-      ;; No pre-existing project.  Let's take a wild-guess if we have
-      ;; an Emacs project here.
-      (when (string-match "emacs[^/]*" dir)
-       (let ((base (substring dir 0 (match-end 0))))
-         (when (file-exists-p (expand-file-name "src/emacs.c" base))
-             base))))))
+  nil)
 
 (defun ede-emacs-version (dir)
   "Find the Emacs version for the Emacs src in DIR.
@@ -80,12 +55,6 @@ Return a tuple of ( EMACSNAME . VERSION )."
     (with-current-buffer buff
       (erase-buffer)
       (setq default-directory (file-name-as-directory dir))
-      (or (file-exists-p configure_ac)
-         (setq configure_ac "configure.in"))
-      ;(call-process "egrep" nil buff nil "-n" "-e" "^version=" "Makefile")
-      (call-process "egrep" nil buff nil "-n" "-e" "AC_INIT" configure_ac)
-      (goto-char (point-min))
-      ;(re-search-forward "version=\\([0-9.]+\\)")
       (cond
        ;; Maybe XEmacs?
        ((file-exists-p "version.sh")
@@ -99,21 +68,33 @@ emacs_beta_version=\\([0-9]+\\)")
                          (match-string 2) "."
                          (match-string 3)))
        )
+       ((file-exists-p "sxemacs.pc.in")
+       (setq emacs "SXEmacs")
+       (insert-file-contents "sxemacs_version.m4")
+       (goto-char (point-min))
+       (re-search-forward "m4_define(\\[SXEM4CS_MAJOR_VERSION\\], \\[\\([0-9]+\\)\\])
+m4_define(\\[SXEM4CS_MINOR_VERSION\\], \\[\\([0-9]+\\)\\])
+m4_define(\\[SXEM4CS_BETA_VERSION\\], \\[\\([0-9]+\\)\\])")
+       (setq ver (concat (match-string 1) "."
+                         (match-string 2) "."
+                         (match-string 3)))
+       )
        ;; Insert other Emacs here...
 
        ;; Vaguely recent version of GNU Emacs?
-       (t
+       ((or (file-exists-p configure_ac)
+           (file-exists-p (setq configure_ac "configure.in")))
        (insert-file-contents configure_ac)
        (goto-char (point-min))
-       (re-search-forward "AC_INIT(emacs,\\s-*\\([0-9.]+\\)\\s-*)")
+       (re-search-forward "AC_INIT(\\(?:GNU \\)?[eE]macs,\\s-*\\([0-9.]+\\)\\s-*[,)]")
        (setq ver (match-string 1))
        )
        )
       ;; Return a tuple
       (cons emacs ver))))
 
-(defclass ede-emacs-project (ede-project eieio-instance-tracker)
-  ((tracking-symbol :initform 'ede-emacs-project-list)
+(defclass ede-emacs-project (ede-project)
+  (
    )
   "Project Type for the Emacs source code."
   :method-invocation-order :depth-first)
@@ -123,30 +104,27 @@ emacs_beta_version=\\([0-9]+\\)")
 Return nil if there isn't one.
 Argument DIR is the directory it is created for.
 ROOTPROJ is nil, since there is only one project."
-  (or (ede-emacs-file-existing dir)
-      ;; Doesn't already exist, so let's make one.
-      (let* ((vertuple (ede-emacs-version dir)))
-       (ede-emacs-project (car vertuple)
-                          :name (car vertuple)
-                          :version (cdr vertuple)
-                          :directory (file-name-as-directory dir)
-                          :file (expand-file-name "src/emacs.c"
-                                                  dir)))
-      (ede-add-project-to-global-list this)
-      )
-  )
+  ;; Doesn't already exist, so let's make one.
+  (let* ((vertuple (ede-emacs-version dir)))
+    (ede-emacs-project
+     (car vertuple)
+     :name (car vertuple)
+     :version (cdr vertuple)
+     :directory (file-name-as-directory dir)
+     :file (expand-file-name "src/emacs.c"
+                            dir))))
 
 ;;;###autoload
-(add-to-list 'ede-project-class-files
           (ede-project-autoload "emacs"
-             :name "EMACS ROOT"
-             :file 'ede/emacs
-             :proj-file "src/emacs.c"
-             :proj-root 'ede-emacs-project-root
-             :load-type 'ede-emacs-load
-             :class-sym 'ede-emacs-project
-             :new-p nil)
           t)
+(ede-add-project-autoload
+ (ede-project-autoload "emacs"
+                      :name "EMACS ROOT"
+                      :file 'ede/emacs
+                      :proj-file "src/emacs.c"
+                      :load-type 'ede-emacs-load
+                      :class-sym 'ede-emacs-project
+                      :new-p nil
+                      :safe-p t)
'unique)
 
 (defclass ede-emacs-target-c (ede-target)
   ()
@@ -295,6 +273,15 @@ Knows about how the Emacs source tree is organized."
       (ede-emacs-find-in-directories name dir dirs))
     ))
 
+;;; Command Support
+;;
+(defmethod project-rescan ((this ede-emacs-project))
+  "Rescan this Emacs project from the sources."
+  (let ((ver (ede-emacs-version (ede-project-root-directory this))))
+    (oset this name (car ver))
+    (oset this version (cdr ver))
+    ))
+
 (provide 'ede/emacs)
 
 ;; Local variables: