Initial Commit
[packages] / xemacs-packages / oo-browser / br-start.el
1 ;;!emacs
2 ;;
3 ;; FILE:         br-start.el
4 ;; SUMMARY:      Select language and invoke OO-Browser.
5 ;; USAGE:        GNU Emacs Lisp Library
6 ;; KEYWORDS:     oop, tools
7 ;;
8 ;; AUTHOR:       Bob Weiner
9 ;; ORG:          BeOpen.com
10 ;;
11 ;; ORIG-DATE:     5-Sep-92 at 23:31:03
12 ;; LAST-MOD:      3-Aug-99 at 22:41:31 by Bob Weiner
13 ;;
14 ;; Copyright (C) 1992, 1993, 1994, 1997, 1998 BeOpen.com
15 ;; See the file BR-COPY for license information.
16 ;;
17 ;; This file is part of the OO-Browser.
18 ;;
19 ;; DESCRIPTION:  
20 ;; DESCRIP-END.
21
22 ;;; ************************************************************************
23 ;;; OO-Browser directory setting
24 ;;; ************************************************************************
25
26 ;; Try to add hyperbole/ or OO-Browser-specific part, hypb/, to the load-path.
27 (if (eq t (catch 'found
28             (mapcar
29              (function (lambda (path)
30                          (if (string-match "\\(/hyperbole\\|/hypb\\)/?\\'" path)
31                              (throw 'found t))))
32              load-path)))
33     nil
34   (cond ((file-readable-p "hypb/")
35          (setq load-path (cons (expand-file-name "hypb/") load-path)))
36         ((file-readable-p "../hyperbole/")
37          (setq load-path (cons (expand-file-name "../hyperbole/") load-path)))))
38
39 ;; May define `locate-file' which is used below.
40 ;; A Hyperbole directory, such as oo-browser/hypb, must either already be in
41 ;; load-path or an explicit load of "hversion" must have been
42 ;; done already or else the following line will fail to load hversion.
43 ;; This is all documented in the OO-Browser installation instructions.
44 (require 'hversion)
45
46 ;; Reinitialize br-directory on reload if initialization failed for any reason.
47 (and (boundp 'br-directory) (null br-directory) (makunbound 'br-directory))
48
49 (defvar br-directory (or (locate-file "br-help-ms" load-path)
50                          (and (file-readable-p "br-help-ms")
51                               (expand-file-name "./")))
52   "Directory where the OO-Browser executable code and help files are kept.
53 It must end with a directory separator character.")
54 (if (stringp br-directory)
55     (setq br-directory (file-name-directory br-directory))
56   (error
57    "(br-start.el): OO-Browser failed to set br-directory.  Try setting it manually."))
58
59 ;; Add OO-Browser Info directory to Info-directory-list after the Info
60 ;; manual reader package is loaded.
61 (if (featurep 'info)
62     (let ((info-dir (expand-file-name "man/" br-directory)))
63       (if (file-exists-p info-dir)
64           (add-hook 'Info-directory-list info-dir t)))
65   (add-hook 'Info-mode-hook
66             (function
67              (lambda ()
68                (if (boundp 'br-directory)
69                    (let ((info-dir (expand-file-name "man/" br-directory)))
70                      (if (file-exists-p info-dir)
71                          (add-hook 'Info-directory-list info-dir t))))))))
72
73 (if (not (fboundp 'defalias)) (fset 'defalias 'fset))
74
75 (if (fboundp 'member)
76     (defalias 'br-member 'member)
77   (defun br-member (elt list)
78     "Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
79 The value is actually the tail of LIST whose car is ELT."
80     (while (and list (not (equal (car list) elt)))
81       (setq list (cdr list)))
82     list))
83
84 ;;; ************************************************************************
85 ;;; Hyperbole subset directory setting (for mouse handling)
86 ;;; ************************************************************************
87
88 ;; Reinitialize hyperb:dir on reload if initialization failed for any reason.
89 (and (boundp 'hyperb:dir) (null hyperb:dir) (makunbound 'hyperb:dir))
90
91 (defvar hyperb:dir (or (locate-file "hmouse-tag.elc" load-path)
92                        (and (file-readable-p "../hyperbole/")
93                             (expand-file-name "../hyperbole/"))
94                        (and (file-readable-p "hypb/")
95                             (expand-file-name "hypb/")))
96   "Directory where the Hyperbole executable code is kept.
97 It must end with a directory separator character.")
98 (if (stringp hyperb:dir)
99     (setq hyperb:dir (file-name-directory hyperb:dir))
100   (error
101    "(br-start.el): Failed to set hyperb:dir.  Try setting it manually."))
102
103 ;;; ************************************************************************
104 ;;; Other public variables
105 ;;; ************************************************************************
106
107 (defconst br-ootags-executable
108   (or (locate-file "ootags" (list br-directory exec-directory)
109                    ":.exe")
110       (locate-file "ootags" exec-path ":.exe"))
111   "Full pathname to `ootags' executable or nil if not found.")
112
113 (defconst br-shell-executable
114   (or (locate-file "bash" exec-path ":.exe")
115       (locate-file "sh" exec-path ":.exe")
116       (locate-file "csh" exec-path ":.exe"))
117   "Full pathname to command shell executable or nil if not found.")
118
119 (defvar br-c-tags-flag
120   (if hyperb:microcruft-os-p
121       ;;
122       ;; !! Temporarily disable c-tags building under microcruft systems
123       ;; !! since is not working properly (it can hang the build).
124       nil
125       ;; Set to t on MS OSs only if a valid shell and ootags.exe is found.  This
126       ;; is required by the "br-c-ft.el" code.
127       ;; (and br-ootags-executable br-shell-executable t)
128     t)
129   "*Non-nil means add C constructs when building C-based language Environments.")
130
131 ;; -f treats upper and lower case the same in sorting, also makes `a' sort
132 ;; list before `[a]', so default classes appear at the end of the list,
133 ;; typically.
134 ;; -u leaves only unique elements in the sorted list
135 (defvar br-sort-options (if hyperb:microcruft-os-p nil "-fu")
136   "*String of options to send to the operating system `sort' command.
137 Use nil for none.  The default sort command under MS OSes does not
138 support the options needed, so this must be set to nil in such cases.")
139
140 (defvar br-env-default-file "OOBR"
141   "*Standard file name for OO-Browser Environment storage.")
142
143 (defvar br-env-file nil
144   "Default file into which to save a class Environment.
145 Value is language-specific.")
146
147 ;;; ************************************************************************
148 ;;; Other required Elisp libraries
149 ;;; ************************************************************************
150
151 ;; Add br-directory and hyperb:dir to load-path so other OO-Browser libraries
152 ;; can be found.
153 (or (br-member br-directory load-path)
154     (setq load-path (cons br-directory load-path)))
155 (or (br-member hyperb:dir load-path)
156     (setq load-path (cons hyperb:dir load-path)))
157
158 (load "br-vers")
159 (mapcar 'require '(br-init br-site))
160
161 ;;; ************************************************************************
162 ;;; Public functions
163 ;;; ************************************************************************
164
165 ;;;###autoload
166 (defun oo-browser (&optional same-env-flag)
167   "Prompt for an Environment over which to run the OO-Browser.
168 Optional prefix argument SAME-ENV-FLAG means browse the current Environment,
169 if any, without prompting.  Otherwise, if called interactively, give the user
170 a choice whether to re-browse the last Environment or to browse a new one."
171   (interactive
172    (list (prog1
173              (if (and (not current-prefix-arg) br-env-file br-lang-prefix)
174                  (y-or-n-p (format "(OO-Browser):  Browse `%s' again? "
175                                    (or (and (not (eq br-env-name t)) br-env-name)
176                                        (br-env-substitute-home br-env-file))))
177                current-prefix-arg)
178            (message ""))))
179   (if (and same-env-flag br-env-file br-lang-prefix)
180       (funcall (intern-soft (concat br-lang-prefix "browse")))
181     (call-interactively 'br-env-browse)))
182
183 ;;;###autoload
184 (defun br-two-button-mouse ()
185   "Sets up the Action Key within OO-Browser listing buffers for a two button mouse.
186 The Action Key is placed on the left mouse button."
187   (interactive)
188   (setq hyperb:mouse-buttons 2)
189   (br-setup-mouse-keys)
190   (message
191    "2-Button Mouse: Display OO-Browser listing items with the left mouse button."))
192
193 ;;;###autoload
194 (defun br-three-button-mouse ()
195   "Sets up the Action Key within OO-Browser listing buffers for a three button mouse.
196 The Action Key is placed on the middle mouse button."
197   (interactive)
198   (setq hyperb:mouse-buttons 3)
199   (br-setup-mouse-keys)
200   (message
201    "3-Button Mouse: Display OO-Browser listing items with the middle mouse button."))
202
203 (provide 'br-start)