annotate lisp/oobr/br-env.el @ 164:4e0740e5aab2

Added tag r20-3b8 for changeset 0132846995bd
author cvs
date Mon, 13 Aug 2007 09:43:39 +0200
parents 4be1180a9e89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: br-env.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: OO-Browser Environment support functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 8-Jun-90
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 21-Feb-97 at 17:22:39 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
14 ;; Copyright (C) 1989-1995, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (require 'hasht)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (defvar br-env-default-file "OOBR"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "*Standard file name for OO-Browser Environment storage.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar br-env-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "Default file into which to save a class Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (if (fboundp 'file-relative-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; For V18 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defun file-relative-name (filename &optional directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (setq filename (expand-file-name filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 directory (file-name-as-directory (if directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (expand-file-name directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (while directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (let ((up (file-name-directory (directory-file-name directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (cond ((and (string-equal directory up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (file-name-absolute-p directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; "/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq directory nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ((string-match (concat "\\`" (regexp-quote directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (setq filename (substring filename (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq directory nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; go up one level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq directory up)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun br-env-browse (env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Invoke the OO-Browser on an existing or to be created Environment ENV-FILE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (list (read-file-name "Load/Create OO-Browser Environment: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 nil (or br-env-file br-env-default-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (if (stringp env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq env-file (expand-file-name env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (error "(br-env-browse): Invalid env file: '%s'" env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (if (string-match "-FTR$" env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq env-file (substring env-file 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (cond ((and (file-exists-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (not (file-readable-p env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (error "(br-env-browse): Env file '%s' is unreadable." env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ((not (file-exists-p env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Specify a new Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (funcall (intern-soft (concat (br-env-select-lang) "browse"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (t ;; Existing Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (let ((lang-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (set-buffer (find-file-noselect env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (search-forward "br-lang-prefix" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Eval removes quote from in front of lang-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; value which is read from the Env file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (setq lang-string (eval (read (current-buffer))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if lang-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (funcall (intern-soft (concat lang-string "browse"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (error "(br-env-browse): Invalid env file: '%s'" env-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defun br-env-build (&optional env-file background-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "Build Environment from spec given by optional ENV-FILE or 'br-env-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 If optional 2nd argument BACKGROUND-FLAG is t, build the Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 using a background process. If it is nil, build in foreground. Any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 value prompts for whether to build in the background."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((env-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (list (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (format "Build Environment (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (br-relative-path env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 env-file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 'prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (cond ((or (null background-flag) (eq background-flag t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (noninteractive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (setq background-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (t (setq background-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (y-or-n-p "Build Environment in a background process? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if (or (not (stringp env-file)) (equal env-file ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq env-file br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (setq env-file (expand-file-name env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (or (not (file-exists-p env-file)) (file-readable-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (error (format "Non-readable Environment file, %s" env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (or (file-writable-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (error (format "Non-writable Environment file, %s" env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if background-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (progn (setenv "OOBR_DIR" br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (setenv "OOBR_ENV" env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (compile (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 "make -f %s %s oobr-env"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (expand-file-name "Makefile" br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if (and (boundp 'invocation-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (boundp 'invocation-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (stringp invocation-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (stringp invocation-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (file-directory-p invocation-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (file-name-absolute-p invocation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (concat "EMACS="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 invocation-name invocation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (br-env-load env-file nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; Detach unneeded data so can be garbage collected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (br-env-create-alists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (br-env-create-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if (and (boundp 'br-feature-tags-file) (stringp br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (not (file-writable-p br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "(br-env-build): %s is not writable" br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set-buffer (find-file-noselect br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-buffer-modified-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (br-build-sys-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (br-build-lib-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq br-env-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (br-env-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; Detach unneeded data so can be garbage collected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (br-env-create-alists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (br-env-load env-file nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defun br-env-rebuild ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "Rescan System and Library sources associated with the current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (cond ((interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (y-or-n-p "Rebuild current Environment? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (br-env-build nil 'prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (t (error "(br-env-rebuild): This must be called interactively."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun br-env-create (&optional env-file lang-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Create and save the specification of a new OO-Browser Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 Interactively prompt for the Environment file name or use optional ENV-FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 Interactively prompt for the Environment language to use or use optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 LANG-PREFIX as language indicator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 If called non-interactively, do not build the Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 If called interactively and presently in the OO-Browser and the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 Environment is the one that has been re-specified, automatically rebuild it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 Otherwise, prompt for whether to build the Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 Return the name of the Environment specification file that was created."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (if env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (read-string
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
184 (format "Please specify the \"%s\" Environment (Hit RET to begin)."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (file-name-nondirectory env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq env-file (br-env-default-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 env-file (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (format "Create Env spec file (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (br-relative-path env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 env-file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (setq env-file (expand-file-name env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; Display Env spec if previous one existed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (and (equal env-file br-env-file) (file-readable-p env-file) (br-env-stats))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
195 (let ((prompt "System search dir #%d (RET to end): ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (br-env-spec t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 br-sys-search-dirs br-lib-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 br-lang-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 br-children-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 br-sys-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 br-lib-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 br-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 br-parents-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (br-env-create-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq br-lang-prefix (or lang-prefix (br-env-select-lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 br-sys-search-dirs (br-env-get-dirs prompt)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
209 prompt "Library search dir #%d (RET to end): "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 br-lib-search-dirs (br-env-get-dirs prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; Now since user has not aborted, set real variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq br-env-spec t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (br-env-save env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; If called interactively and re-specifying current Env, then also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; rebuild it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (if (equal env-file br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (br-in-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; auto-build
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (br-env-build
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 nil (y-or-n-p "Environment will now be built. Build in background? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (call-interactively 'br-env-build))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun br-env-load (&optional env-file prompt no-build)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "Load browser Environment or spec from optional ENV-FILE or 'br-env-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Non-nil PROMPT means prompt user before building tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 Non-nil NO-BUILD means skip build of Environment entirely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Return t if load is successful, else nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((env-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (list (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (format "Environment file to load (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (br-relative-path env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 env-file t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq env-file (or (and (not (equal env-file "")) env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (br-env-default-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 env-file (expand-file-name env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 br-env-file env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (let ((buf (get-file-buffer env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (let ((br-loaded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (file-readable-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (message "Loading Environment...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; Ensure spec and version values are nil for old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; Environment files that do not contain a setting for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; these variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq br-env-spec nil br-env-version nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (load-file env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if br-env-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq br-children-htable (hash-make br-children-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 br-sys-paths-htable (hash-make br-sys-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 br-lib-paths-htable (hash-make br-lib-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (hash-make br-sys-parents-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (hash-make br-lib-parents-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (br-env-set-htables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Prevent rebuilding of Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq br-lib-prev-search-dirs br-lib-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 br-sys-prev-search-dirs br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq br-loaded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (message "Loading Environment...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ((and br-env-spec (not no-build))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq br-loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (br-env-cond-build
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if prompt "Build Environment from spec in file, \"%s\"? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; If Environment was built with a version of the OO-Browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; which did not add a version number to each Environment,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; then it may use an obsolete format. Offer to rebuild it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ((and (not no-build) (null br-env-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (br-member br-lang-prefix '("c++-" "objc-" "eif-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (br-env-stats)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (br-env-cond-build
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "Environment file format is obsolete, rebuild it? ")))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
289 ;; Ensure that OO-Browser support libraries for the current
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
290 ;; language are loaded, since this function may be called without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
291 ;; invoking the OO-Browser user interface.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
292 (let ((lang-symbol (intern-soft (concat br-lang-prefix "browse")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
293 lang-setup-symbol
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
294 lang-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
295 (if lang-symbol
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
296 (progn (setq lang-function (symbol-function lang-symbol))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
297 (and (listp lang-function) (eq (car lang-function) 'autoload)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
298 (load (car (cdr lang-function)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
299 ;; Initialize language-specific browser variables.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
300 (setq lang-setup-symbol (intern-soft (concat br-lang-prefix "browse-setup")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
301 (funcall lang-setup-symbol)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (if (file-exists-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (progn (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (message "No read rights for Envir file, \"%s\"" env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (sit-for 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (message "\"%s\", no such file." env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq br-loaded (br-env-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (br-env-create env-file br-lang-prefix) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 br-loaded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun br-env-save (&optional save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Save changed Environment to file given by optional SAVE-FILE or 'br-env-file'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (let ((env-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (list (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (format "Save Environment to (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (br-relative-path env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 env-file nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if (and (stringp save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (not (equal save-file br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (stringp br-feature-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (file-exists-p br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; Copy feature tags file to new file name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (copy-file br-feature-tags-file (br-feature-tags-file-name save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (or (not (stringp save-file)) (equal save-file ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq save-file br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq save-file (expand-file-name save-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (or (file-writable-p save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (error (format "Non-writable Environment file, \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (let ((buf (get-file-buffer save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (let ((dir (or (file-name-directory save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (or (file-writable-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (error (format "Non-writable Environment directory, \"%s\"" dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (let ((standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (set-buffer (funcall br-find-file-noselect-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 br-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (princ "\n(setq\nbr-env-version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (print br-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (br-env-save-mult-vars (cons (car br-env-mult-vars) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (setq br-sym (intern-soft (concat "br-" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (let ((nm-mid (string-match "-htable$" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if nm-mid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (progn (princ "\nbr-") (princ (substring nm 0 nm-mid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (princ "-alist\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (hash-prin1 (symbol-value br-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (princ "\n") (princ br-sym) (princ "\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (prin1 (symbol-value br-sym)) (princ "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 br-env-single-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (br-env-save-mult-vars (cdr br-env-mult-vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (princ ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (kill-buffer standard-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defun br-env-stats (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "Display summary for current Environment in viewer window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 With optional prefix ARG, display class totals in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (let ((env-file (abbreviate-file-name br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (message "Envir \"%s\": %s" env-file (br-env-totals))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (br-funcall-in-view-window
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
375 (concat br-buffer-prefix-info "Info*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (insert (format "Environment: \"%s\"" env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (center-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (if (null br-env-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (insert (format "Built by version %s of the OO-Browser.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (or br-env-version "earlier than 02.09.03"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (insert (br-env-totals) "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (let ((undefined (br-undefined-classes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (if undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (insert (format "Undefined classes: %s\n\n" undefined))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (lambda (sys-lib)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (insert (format "Directories to search for %s classes:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (car sys-lib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if (cdr sys-lib)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (progn (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (lambda (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (or (equal dir "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (format "\t%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (abbreviate-file-name dir))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (cdr sys-lib))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (insert "\t<None>\n\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (list (cons "System" br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (cons "Library" br-lib-search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (insert "Flag Settings:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "\n\tEnvironment built from specification: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if br-env-spec "no" "yes")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (set-buffer-modified-p nil)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun br-env-add-ref-classes (&optional htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Add classes to Environment which are referenced in it but not defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 With optional HTABLE-TYPE, affect only that part of the Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 HTABLE-TYPE may be \"sys\"or \"lib\". By default, add to both Library and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 whole Environment tables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; This function must NOT call any 'get-htable' type functions or it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; cause an infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (let ((classes (br-all-classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (intern-soft (concat "br-" htable-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if htable-type "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "paths-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (pars (br-env-all-parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (intern-soft (concat "br-" htable-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (if htable-type "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "parents-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (while pars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq class (car pars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 pars (cdr pars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if (or (null class) (br-member class classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq classes (cons class classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (null htable-type) (setq htable-type "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (br-env-add-to-htables class (concat htable-type "-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (br-add-to-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 class br-null-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (br-get-htable (concat htable-type "-paths")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defun br-env-add-to-htables (class parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 "Add CLASS to hash tables referenced by PARENTS name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 PARENTS may be \"parents\", \"sys-parents\", or \"lib-parents\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if (null class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (symbol-value (intern-soft (concat "br-" parents "-htable"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if parents (hash-add nil class parents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun br-env-all-parents (&optional htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "Return list of all parent names in Environment or optional HTABLE-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 HTABLE-TYPE may be \"sys\" or \"lib\". or an actual hash table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (hash-map 'car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (cond ((and (stringp htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (not (string-equal htable-type "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (br-get-htable (concat htable-type "-parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ((hashp htable-type) htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (t (br-get-parents-htable))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun br-env-batch-build ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Build Environments from specifications while running Emacs in batch mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 Invoke via a shell command line of the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 emacs -batch -l <BR-DIR>/br-start.el <OO-Browser Env Spec File> ... <Spec File> -f br-env-batch-build"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (br-init-autoloads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (if (or (not (boundp 'br-directory)) (null br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (not (file-exists-p br-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (error "br-env-batch-build: Set 'br-directory' properly before use.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (let ((spec-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (files (delq nil (mapcar 'buffer-file-name (buffer-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (while (setq spec-file (car files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (setq files (cdr files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (load spec-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (or (featurep (intern-soft (concat br-lang-prefix "browse")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (featurep (intern-soft (concat br-lang-prefix "brows")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (load (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (concat br-lang-prefix "browse") br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (load (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (concat br-lang-prefix "brows") br-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (funcall (intern (concat br-lang-prefix "browse-setup")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (kill-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (br-env-build spec-file nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;; The following function is called by the compilation sentinel whenever a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;; compilation finishes under versions of Emacs 19. (If you use Emacs 18,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;;; you would have to edit compilation-sentinel to call the function stored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;;; in 'compilation-finish-function' as Emacs 19, compile.el does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;; If there already is a compilation-finish-function, save it and use it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;;; when not in a batch environment build.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq compilation-original-finish-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (and (boundp 'compilation-finish-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (not (eq compilation-finish-function 'br-env-batch-build-browse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 compilation-finish-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 compilation-finish-function 'br-env-batch-build-browse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defun br-env-batch-build-browse (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;; This is only called when we are in the compilation buffer already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (cond ((not (string-match "oobr-env" compile-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; Some other type of build.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if compilation-original-finish-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (apply compilation-original-finish-function args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ((not (and (stringp mode-line-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (string-match "OK" mode-line-process)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Build failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (t ;; Environment build was successful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (let* ((env-file (getenv "OOBR_ENV"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 "(OO-Browser): Environment \"%s\" is built; browse it now? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (file-name-nondirectory env-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (if (y-or-n-p prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (br-env-browse env-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun br-env-cond-build (env-file prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 "Build current Environment from its specification and save it in ENV-FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 Non-nil PROMPT is used to prompt user before building Environment. Return t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 iff current Environment gets built from specification."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (let ((dir (or (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (if (not (file-writable-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (progn (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (message "Unwritable Environment directory, \"%s\"" dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (sit-for 4) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (if (or (not prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (y-or-n-p (format prompt env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (progn (br-env-build env-file 'prompt) t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun br-env-copy (to-br)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 "Copy 'br-' Environment to or from 'br-lang-prefix' language variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 If TO-BR is non-nil, copy from language-specific variables to browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 variables. Otherwise, do copy in the reverse direction."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (let* ((var1) (var2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (copy-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if to-br (function (lambda () (set var1 (symbol-value var2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (function (lambda () (set var2 (symbol-value var1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq var1 (intern (concat "br-" nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 var2 (intern (concat br-lang-prefix nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (funcall copy-func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 '("env-file" "env-version" "lib-search-dirs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 "lib-prev-search-dirs" "lib-parents-htable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 "lib-paths-htable" "sys-search-dirs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 "sys-prev-search-dirs" "sys-parents-htable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "sys-paths-htable" "paths-htable" "parents-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 br-env-single-vars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun br-env-create-alists ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 "Create all empty Environment association lists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (setq br-children-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 br-sys-paths-alist nil br-lib-paths-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 br-sys-parents-alist nil br-lib-parents-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 br-paths-alist nil br-parents-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun br-env-create-htables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 "Create all empty Environment hash tables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (setq br-children-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 br-sys-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 br-sys-parents-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 br-lib-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 br-lib-parents-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 br-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 br-parents-htable (hash-make 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defun br-env-default-file (&optional directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "Search up current or optional DIRECTORY tree for an OO-Browser environment file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 Return file name found, the value of 'br-env-file' if non-nil, or else the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 value of 'br-env-default-file'. All return values are expanded to absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 paths before being returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let ((path directory)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
582 (oo-browser-file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (while (and (stringp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq path (file-name-directory path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setq path (directory-file-name path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; Not at root directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (not (string-match ":?/\\'" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; No environment file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (not (file-exists-p
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
590 (setq oo-browser-file (expand-file-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 br-env-default-file path)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
592 (setq oo-browser-file nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
593 (expand-file-name (or oo-browser-file br-env-file br-env-default-file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defun br-env-file-sym-val (symbol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 "Given a SYMBOL-NAME, a string, find its value in the current Environment file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 Assume the Environment file to use is attached to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 Only search for the SYMBOL-NAME from the current point in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 Return cons whose car is t iff SYMBOL-NAME was found and then whose cdr is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 non-quoted value found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (set-buffer (funcall br-find-file-noselect-function br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (search-forward symbol-name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (let ((standard-input (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (cons t (eval (read)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (defun br-env-try-load (env-file default-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 "Try to load a complete Environment, initially given by ENV-FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 If an Environment specification is selected, the user will be prompted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 whether or not to build it. If ENV-FILE is not a string, the function will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 prompt for an Environment to load. DEFAULT-FILE is the default file to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 when an empty value is given at the Environment file prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 Return the name of the Environment file that was loaded or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (if (br-env-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (if (stringp env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (or (stringp default-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (setq default-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (setq env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "OO-Browser Environment file (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (br-relative-path default-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 default-file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 'prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (if (stringp env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (setq br-env-file (expand-file-name env-file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (defun br-env-get-dirs (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 "PROMPT for and return list of directory names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 PROMPT must contain a %d somewhere in it, so dir # may be inserted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (let ((dir) (dirs) (num 1) (default ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (while (not (string-equal "" (setq dir (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (format prompt num) default "" t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if (file-directory-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (setq dirs (cons dir dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 num (1+ num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 default "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (setq default dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (nreverse dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (defun br-env-init (env-file same-lang same-env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 "Load or build ENV-FILE if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 Otherwise, use 'br-env-file' if non-nil or if not, interactively prompt for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 Environment name. SAME-LANG should be non-nil if invoking the OO-Browser on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 the same language again. SAME-ENV should be non-nil if invoking the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 OO-Browser on the same Environment again. br-sys/lib-search-dirs variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 should be set before this function is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 Return the name of the current Environment file unless load attempt fails,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 then return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;; Specific environment requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;; Create or load spec and load or build Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (setq env-file (br-env-try-load env-file br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;; First invocation on this lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ((and (null br-sys-search-dirs) (null br-lib-search-dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;; Create or load spec and load or build Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (setq env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (br-env-try-load (or br-env-file (br-env-create)) br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; Non-first invocation, search paths have been set, possibly default Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (setq env-file br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; Continue browsing an Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (same-env nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (same-lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;; But search paths have changed, so rebuild Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (progn (or (eq br-sys-search-dirs br-sys-prev-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (br-build-sys-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (or (eq br-lib-search-dirs br-lib-prev-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (br-build-lib-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;; Request to browse a different language Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (setq env-file (br-env-try-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (or br-env-file (br-env-create)) br-env-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; Return current Env file name unless load attempt failed, then return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (defun *br-env-internal-structures* ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 "Display values of internal data structures in viewer buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (br-funcall-in-view-window
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
691 (concat br-buffer-prefix-info "Info*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (let ((standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (function (lambda (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (princ obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (list "!!! " (symbol-name sym) " !!!\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (symbol-value sym) "\n \n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 '(br-children-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 br-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 br-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 br-sys-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 br-sys-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 br-lib-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 br-lib-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 br-lang-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 br-env-spec)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (defun br-env-lang-dialog-box (dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 "Prompt user with DIALOG-BOX and return selected value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 Assumes caller has checked that 'dialog-box' function exists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (let ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 event-obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ;; Add a cancel button to dialog box.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq dialog-box (append dialog-box (list nil '["Cancel" abort t])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (popup-dialog-box dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (catch 'br-env-done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq event (next-command-event event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 event-obj (event-object event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (cond ((and (menu-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (memq event-obj '(abort menu-no-selection-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (signal 'quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ((button-release-event-p event) ;; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ((menu-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (throw 'br-env-done (eval event-obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (message "Please answer the dialog box.")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (defun br-env-lang-var (lang-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 "Create language-specific Environment variables for LANG-PREFIX."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (eval (list 'defvar (intern (concat lang-prefix "env-version"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 "Version of the OO-Browser used to build the current Environment or nil."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (eval (list 'defvar (intern (concat lang-prefix "env-file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 br-env-default-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "*File in which to save Environment.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun br-env-load-matching-htables (changed-types-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (let ((still-changed-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (if (file-readable-p br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (let ((buf (get-file-buffer br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (set-buffer (funcall br-find-file-noselect-function br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (let* ((search-dirs (concat "br-" type "-search-dirs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (prev-dirs (concat "br-" type "-prev-search-dirs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (paths (concat "br-" type "-paths-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (parents (concat "br-" type "-parents-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (dirs-val (cdr (br-env-file-sym-val search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (if (equal dirs-val (symbol-value (intern search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (and (br-member type changed-types-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (progn (set (intern paths)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (cdr (br-env-file-sym-val paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (set (intern parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (cdr (br-env-file-sym-val parents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (set (intern prev-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (intern search-dirs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (setq still-changed-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (cons type still-changed-types))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 '("sys" "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (nreverse still-changed-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defun br-env-save-mult-vars (mult-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let ((br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (lambda (suffix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (lambda (type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (setq br-sym (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (concat "br-" type-str suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (if (and br-sym (boundp br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (let* ((nm (symbol-name br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (nm-mid (string-match "-htable$" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (if nm-mid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (progn (princ "\n") (princ (substring nm 0 nm-mid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (princ "-alist\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (hash-prin1 (symbol-value br-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (princ "\n") (princ br-sym) (princ "\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (prin1 (symbol-value br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (princ "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 '("sys-" "lib-"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 mult-vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (defun br-env-set-htables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (br-env-add-ref-classes "lib")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (br-env-add-ref-classes "sys")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; Make System entries override Library entries which they duplicate, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; this is generally more desireable than merging the two. Don't do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;; for the paths-htable, however, since the value is the union of both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;; values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq br-paths-htable (hash-merge br-sys-paths-htable br-lib-paths-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (let ((hash-merge-values-function (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (setq br-parents-htable (hash-merge br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 br-lib-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (defun br-env-select-lang ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 "Interactively select and return value for 'br-lang-prefix'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (let ((n 0) (nlangs (length br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (lang-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; Use dialog box if last user event involved the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (use-dialog-box (and (fboundp 'popup-dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (fboundp 'button-press-event-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (or (button-press-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (button-release-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (menu-event-p last-command-event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Create a prompt numbering each OO-Browser language available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (setq lang-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (if use-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (function (lambda (lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (setq n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (vector lang (list 'identity n) 't)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (mapcar 'car br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (function (lambda (lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (format "%d\) %s" n lang)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (mapcar 'car br-env-lang-avector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 "; ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; Prompt user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (setq n (if use-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (br-env-lang-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (cons "Choose language to browse: " lang-prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; Otherwise, prompt in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (read-string (concat "Choose: " lang-prompt ": ") ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (or (< n 1) (> n nlangs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (cdr (aref br-env-lang-avector (1- n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (defun br-env-totals ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 "Return string of Environment class totals."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (let ((sys (length (br-all-classes "sys")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (lib (length (br-all-classes "lib")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (duplicates (car (br-all-classes nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (format "%sTotal unique classes: %d; System: %d; Library: %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (if (null duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (setq count (length duplicates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (format "%d DUPLICATE CLASS%s TO CONSIDER ELIMINATING:\n\t%s\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 count (if (= count 1) "" "ES") duplicates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (+ sys lib) sys lib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (defvar br-env-version nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 "Version of the OO-Browser used to build the current Environment or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (defconst br-env-mult-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 '("search-dirs" "paths-htable" "parents-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 "Descriptors of multiple copy variables saved as part of an Environment.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (defconst br-env-single-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 '("lang-prefix" "env-spec" "children-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 "Descriptors of singular variables saved as part of an Environment.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (defvar br-env-spec nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "Non-nil value means Environment specification has been given but not yet built.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 Nil means current Environment has been built, though it may still require
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 updating. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (defvar br-env-lang-avector
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
887 '[("C++/C" . "c++-")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ("Eiffel" . "eif-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ("Info" . "info-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ("Java" . "java-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ("Lisp" . "clos-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ("Obj-C" . "objc-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ("Python" . "python-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ("Smalltalk" . "smt-")]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 "Association vector of (LANGUAGE-NAME . LANGUAGE-PREFIX-STRING) elements of OO-Browser languages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (mapcar 'br-env-lang-var (mapcar 'cdr br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (provide 'br-env)