Initial Commit
[packages] / xemacs-packages / cedet-common / cedet.el
1 ;;; cedet.el --- Setup CEDET environment
2
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 by David Ponce
4
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: CEDET developers <http://sf.net/projects/cedet>
7 ;; Created: 09 Dec 2002
8 ;; Keywords: syntax
9 ;; X-RCS: $Id: cedet.el,v 1.1 2007-11-26 15:06:40 michaels Exp $
10
11 ;; This file is not part of Emacs
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; see the file COPYING.  If not, write to
25 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
27
28 ;;; Commentary:
29 ;;
30 ;; This library automatically setups your [X]Emacs to use CEDET tools.
31 ;;
32 ;; First download the latest CEDET distribution, provided in a
33 ;; cedet-<VERSION>.tar.gz tarball, from the project page at:
34 ;; <http://sf.net/projects/cedet>.
35 ;;  
36 ;; Unpack the tarball in a directory of your choice.  It will install
37 ;; the following directory tree:
38 ;;
39 ;;   cedet
40 ;;     |
41 ;;     +- common
42 ;;     |
43 ;;     +- cogre
44 ;;     |
45 ;;     +- ede
46 ;;     |
47 ;;     +- eieio
48 ;;     |
49 ;;     +- semantic
50 ;;     |
51 ;;     +- speedbar
52 ;;     |
53 ;;     \- contrib
54 ;;
55 ;; Then, add the following into your ~/.emacs startup file:
56 ;;
57 ;;   (load-file "<INSTALL-PATH>/cedet/common/cedet.el")
58 ;;
59 ;; If you want to turn on useful or all Semantic features by default,
60 ;; respectively add:
61 ;;
62 ;;   (setq semantic-load-turn-useful-things-on t)
63 ;; or
64 ;;   (setq semantic-load-turn-everything-on t)
65 ;;
66 ;; before loading this file, like this:
67 ;;
68 ;;   (setq semantic-load-turn-useful-things-on t)
69 ;;   (load-file "<INSTALL-PATH>/cedet/common/cedet.el")
70 ;;
71 ;; That's it!
72 ;;
73
74 ;;; History:
75 ;;
76
77 ;;; Code:
78 (eval-when-compile
79   (require 'cl)
80   )
81
82 ;;;###autoload
83 (defconst cedet-version "1.0pre4"
84   "Current version of CEDET.")
85
86 (defconst cedet-packages
87   `(
88     ;;PACKAGE   MIN-VERSION      INSTALLDIR
89     (cedet         ,cedet-version  "common" )
90     (cogre         "0.5"                    )
91     (ede           "1.0pre4"                )
92     (eieio         "1.0"                    )
93     (semantic      "2.0pre4"                )
94     (speedbar      "1.0.1"                  )
95     (cedet-contrib "1.0pre4"      "contrib" )
96     )
97   "Table of CEDET packages to install.")
98
99 ;; This file must be in "<INSTALL-DIR>/cedet/common"!
100 (let ((default-directory
101         (file-name-directory
102          (or load-file-name (buffer-file-name)))))
103   
104   ;; Add "<INSTALL-DIR>/cedet/common" to `load-path'.
105   (add-to-list 'load-path default-directory)
106   (message "%S added to `load-path'" default-directory)
107   ;; Require the inversion library.
108   (require 'inversion)
109   
110   ;; Go up to the parent "<INSTALL-DIR>/cedet" directory.
111   (let ((default-directory (expand-file-name ".."))
112         package min-version installdir)
113
114     ;; Add the CEDET packages subdirectories to the `load-path' if
115     ;; necessary.
116     (dolist (package-spec cedet-packages)
117       (setq package     (nth 0 package-spec)
118             min-version (nth 1 package-spec)
119             installdir  (nth 2 package-spec))
120       (when installdir
121         (setq installdir (expand-file-name installdir)))
122       (inversion-add-to-load-path package min-version installdir))
123
124     ;; Then run every package setup.
125     (dolist (package-spec cedet-packages)
126       (setq package (nth 0 package-spec))
127       (message "Setting up %s..." package)
128       (condition-case err
129           (progn
130             (require (intern (format "%s-load" package)))
131             (message "Setting up %s...done" package))
132         (error
133          (message "%s" (error-message-string err)))))
134     ))
135
136 (eval-when-compile
137   (require 'inversion))
138
139 (defun cedet-version ()
140   "Display all active versions of CEDET and Dependant packages.
141
142 The PACKAGE column is the name of a given package from CEDET.
143
144 REQUESTED VERSION is the version requested by the CEDET load script.
145 See `cedet-packages' for details.
146
147 FILE VERSION is the version number found in the source file
148 for the specificed PACKAGE.
149
150 LOADED VERSION is the version of PACKAGE current loaded in Emacs
151 memory and (presumably) running in this Emacs instance.  Value is X
152 if the package has not been loaded."
153   (interactive)
154   (with-output-to-temp-buffer "*CEDET*"
155     (princ "CEDET Version:\t") (princ cedet-version)
156     (princ "\n  \t\t\tRequested\tFile\t\tLoaded")
157     (princ "\n  Package\t\tVersion\t\tVersion\t\tVersion")
158     (princ "\n  ----------------------------------------------------------")
159     (let ((p cedet-packages))
160       (while p
161         (let ((sym (symbol-name (car (car p)))))
162           (princ "\n  ")
163           (princ sym)
164           (princ ":\t")
165           (if (< (length sym) 5)
166               (princ "\t"))
167           (if (< (length sym) 13)
168               (princ "\t"))
169           (let ((reqver (nth 1 (car p)))
170                 (filever (car (inversion-find-version sym)))
171                 (loadver (when (featurep (car (car p)))
172                            (symbol-value (intern-soft (concat sym "-version"))))))
173             (princ reqver)
174             (if (< (length reqver) 8) (princ "\t"))
175             (princ "\t")
176             (if (string= filever reqver)
177                 ;; I tried the words "check" and "match", but that
178                 ;; just looked lame.
179                 (princ "ok\t")
180               (princ filever)
181               (if (< (length filever) 8) (princ "\t")))
182             (princ "\t")
183             (if loadver
184                 (if (string= loadver reqver)
185                     (princ "ok")
186                   (princ loadver))
187               (princ "Not Loaded"))
188             ))
189         (setq p (cdr p))))
190     (princ "\n\n\nC-h f cedet-version RET\n  for details on output format.")
191     ))
192
193 (provide 'cedet)
194
195 ;;; cedet.el ends here