annotate lisp/oobr/br-env.el @ 7:c153ca296910

Added tag r19-15b4 for changeset 27bc7f280385
author cvs
date Mon, 13 Aug 2007 08:47:16 +0200
parents 376386a54a3c
children 4103f0995bd7
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; ORG: Motorola Inc.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 20-Sep-95 at 14:59:03 by Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; Copyright (C) 1989-1995 Free Software Foundation, Inc.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (format "Please specify the \"%s\" Environment (Hit RTN to begin)."
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))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((prompt "System search dir #%d (RTN to end): ")
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)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 prompt "Library search dir #%d (RTN to end): "
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? ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (if (file-exists-p env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (progn (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (message "No read rights for Envir file, \"%s\"" env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (sit-for 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (message "\"%s\", no such file." env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setq br-loaded (br-env-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (br-env-create env-file br-lang-prefix) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 br-loaded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun br-env-save (&optional save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "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
302 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (let ((env-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (list (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (format "Save Environment to (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (br-relative-path env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 env-file nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (if (and (stringp save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (not (equal save-file br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (stringp br-feature-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (file-exists-p br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; Copy feature tags file to new file name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (copy-file br-feature-tags-file (br-feature-tags-file-name save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if (or (not (stringp save-file)) (equal save-file ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq save-file br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (setq save-file (expand-file-name save-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (or (file-writable-p save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (error (format "Non-writable Environment file, \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((buf (get-file-buffer save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (let ((dir (or (file-name-directory save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (or (file-writable-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (error (format "Non-writable Environment directory, \"%s\"" dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (set-buffer (funcall br-find-file-noselect-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 br-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (princ "\n(setq\nbr-env-version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (print br-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (br-env-save-mult-vars (cons (car br-env-mult-vars) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq br-sym (intern-soft (concat "br-" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (let ((nm-mid (string-match "-htable$" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if nm-mid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (progn (princ "\nbr-") (princ (substring nm 0 nm-mid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (princ "-alist\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (hash-prin1 (symbol-value br-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (princ "\n") (princ br-sym) (princ "\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (prin1 (symbol-value br-sym)) (princ "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 br-env-single-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (br-env-save-mult-vars (cdr br-env-mult-vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (princ ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (kill-buffer standard-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun br-env-stats (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "Display summary for current Environment in viewer window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 With optional prefix ARG, display class totals in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (let ((env-file (abbreviate-file-name br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (message "Envir \"%s\": %s" env-file (br-env-totals))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (br-funcall-in-view-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (concat br-buffer-prefix-info "Info")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (insert (format "Environment: \"%s\"" env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (center-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (if (null br-env-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (insert (format "Built by version %s of the OO-Browser.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (or br-env-version "earlier than 02.09.03"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (insert (br-env-totals) "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (let ((undefined (br-undefined-classes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (if undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (insert (format "Undefined classes: %s\n\n" undefined))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (mapcar
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 (sys-lib)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (insert (format "Directories to search for %s classes:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (car sys-lib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (if (cdr sys-lib)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (progn (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (lambda (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (or (equal dir "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (format "\t%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (abbreviate-file-name dir))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (cdr sys-lib))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (insert "\t<None>\n\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (list (cons "System" br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (cons "Library" br-lib-search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (insert "Flag Settings:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "\n\tEnvironment built from specification: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if br-env-spec "no" "yes")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (set-buffer-modified-p nil)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun br-env-add-ref-classes (&optional htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "Add classes to Environment which are referenced in it but not defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 With optional HTABLE-TYPE, affect only that part of the Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 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
407 whole Environment tables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; This function must NOT call any 'get-htable' type functions or it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; cause an infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (let ((classes (br-all-classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (intern-soft (concat "br-" htable-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (if htable-type "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 "paths-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (pars (br-env-all-parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (intern-soft (concat "br-" htable-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (if htable-type "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "parents-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (while pars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq class (car pars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 pars (cdr pars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (or (null class) (br-member class classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq classes (cons class classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if (null htable-type) (setq htable-type "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (br-env-add-to-htables class (concat htable-type "-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (br-add-to-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 class br-null-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (br-get-htable (concat htable-type "-paths")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun br-env-add-to-htables (class parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "Add CLASS to hash tables referenced by PARENTS name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 PARENTS may be \"parents\", \"sys-parents\", or \"lib-parents\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (if (null class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (symbol-value (intern-soft (concat "br-" parents "-htable"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if parents (hash-add nil class parents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (defun br-env-all-parents (&optional htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 "Return list of all parent names in Environment or optional HTABLE-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 HTABLE-TYPE may be \"sys\" or \"lib\". or an actual hash table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (hash-map 'car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (cond ((and (stringp htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (not (string-equal htable-type "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (br-get-htable (concat htable-type "-parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ((hashp htable-type) htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (t (br-get-parents-htable))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun br-env-batch-build ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Build Environments from specifications while running Emacs in batch mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 Invoke via a shell command line of the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 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
458 (br-init-autoloads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (or (not (boundp 'br-directory)) (null br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (not (file-exists-p br-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (error "br-env-batch-build: Set 'br-directory' properly before use.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (let ((spec-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (files (delq nil (mapcar 'buffer-file-name (buffer-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (while (setq spec-file (car files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq files (cdr files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (load spec-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (or (featurep (intern-soft (concat br-lang-prefix "browse")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (featurep (intern-soft (concat br-lang-prefix "brows")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (load (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (concat br-lang-prefix "browse") br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (load (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (concat br-lang-prefix "brows") br-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (funcall (intern (concat br-lang-prefix "browse-setup")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (kill-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (br-env-build spec-file nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;;; The following function is called by the compilation sentinel whenever a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;;; compilation finishes under versions of Emacs 19. (If you use Emacs 18,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;; you would have to edit compilation-sentinel to call the function stored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;;; in 'compilation-finish-function' as Emacs 19, compile.el does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;;; If there already is a compilation-finish-function, save it and use it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;;; when not in a batch environment build.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (setq compilation-original-finish-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (and (boundp 'compilation-finish-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (not (eq compilation-finish-function 'br-env-batch-build-browse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 compilation-finish-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 compilation-finish-function 'br-env-batch-build-browse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun br-env-batch-build-browse (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; This is only called when we are in the compilation buffer already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (cond ((not (string-match "oobr-env" compile-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; Some other type of build.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (if compilation-original-finish-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (apply compilation-original-finish-function args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ((not (and (stringp mode-line-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (string-match "OK" mode-line-process)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; Build failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (t ;; Environment build was successful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (let* ((env-file (getenv "OOBR_ENV"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "(OO-Browser): Environment \"%s\" is built; browse it now? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (file-name-nondirectory env-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (y-or-n-p prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (br-env-browse env-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (defun br-env-cond-build (env-file prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 "Build current Environment from its specification and save it in ENV-FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 Non-nil PROMPT is used to prompt user before building Environment. Return t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 iff current Environment gets built from specification."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (let ((dir (or (file-name-directory env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (if (not (file-writable-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (progn (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (message "Unwritable Environment directory, \"%s\"" dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (sit-for 4) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (if (or (not prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (y-or-n-p (format prompt env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (progn (br-env-build env-file 'prompt) t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defun br-env-copy (to-br)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "Copy 'br-' Environment to or from 'br-lang-prefix' language variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 If TO-BR is non-nil, copy from language-specific variables to browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 variables. Otherwise, do copy in the reverse direction."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (let* ((var1) (var2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (copy-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (if to-br (function (lambda () (set var1 (symbol-value var2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (function (lambda () (set var2 (symbol-value var1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (setq var1 (intern (concat "br-" nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 var2 (intern (concat br-lang-prefix nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (funcall copy-func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 '("env-file" "env-version" "lib-search-dirs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 "lib-prev-search-dirs" "lib-parents-htable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 "lib-paths-htable" "sys-search-dirs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 "sys-prev-search-dirs" "sys-parents-htable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "sys-paths-htable" "paths-htable" "parents-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 br-env-single-vars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (defun br-env-create-alists ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 "Create all empty Environment association lists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq br-children-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 br-sys-paths-alist nil br-lib-paths-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 br-sys-parents-alist nil br-lib-parents-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 br-paths-alist nil br-parents-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defun br-env-create-htables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 "Create all empty Environment hash tables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq br-children-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 br-sys-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 br-sys-parents-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 br-lib-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 br-lib-parents-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 br-paths-htable (hash-make 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 br-parents-htable (hash-make 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (defun br-env-default-file (&optional directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 "Search up current or optional DIRECTORY tree for an OO-Browser environment file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 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
566 value of 'br-env-default-file'. All return values are expanded to absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 paths before being returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (let ((path directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (oobr-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (while (and (stringp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (setq path (file-name-directory path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (setq path (directory-file-name path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; Not at root directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (not (string-match ":?/\\'" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; No environment file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (not (file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (setq oobr-file (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 br-env-default-file path)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq oobr-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (expand-file-name (or oobr-file br-env-file br-env-default-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (defun br-env-file-sym-val (symbol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 "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
584 Assume the Environment file to use is attached to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 Only search for the SYMBOL-NAME from the current point in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 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
587 non-quoted value found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (set-buffer (funcall br-find-file-noselect-function br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (if (search-forward symbol-name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (let ((standard-input (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (cons t (eval (read)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun br-env-try-load (env-file default-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 "Try to load a complete Environment, initially given by ENV-FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 If an Environment specification is selected, the user will be prompted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 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
598 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
599 when an empty value is given at the Environment file prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Return the name of the Environment file that was loaded or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (if (br-env-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (stringp env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (or (stringp default-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq default-file (br-env-default-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 "OO-Browser Environment file (default \"%s\"): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (br-relative-path default-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 default-file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 'prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (if (stringp env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (setq br-env-file (expand-file-name env-file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (defun br-env-get-dirs (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 "PROMPT for and return list of directory names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 PROMPT must contain a %d somewhere in it, so dir # may be inserted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (let ((dir) (dirs) (num 1) (default ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (while (not (string-equal "" (setq dir (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (format prompt num) default "" t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (if (file-directory-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (setq dirs (cons dir dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 num (1+ num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 default "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (setq default dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (nreverse dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (defun br-env-init (env-file same-lang same-env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 "Load or build ENV-FILE if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 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
635 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
636 the same language again. SAME-ENV should be non-nil if invoking the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 OO-Browser on the same Environment again. br-sys/lib-search-dirs variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 should be set before this function is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 Return the name of the current Environment file unless load attempt fails,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 then return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;; Specific environment requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; Create or load spec and load or build Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq env-file (br-env-try-load env-file br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;; First invocation on this lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ((and (null br-sys-search-dirs) (null br-lib-search-dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;; Create or load spec and load or build Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (setq env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (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
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;; Non-first invocation, search paths have been set, possibly default Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (setq env-file br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;; Continue browsing an Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (same-env nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (same-lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;; But search paths have changed, so rebuild Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (progn (or (eq br-sys-search-dirs br-sys-prev-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (br-build-sys-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (or (eq br-lib-search-dirs br-lib-prev-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (br-build-lib-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ;; Request to browse a different language Env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (setq env-file (br-env-try-load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (or br-env-file (br-env-create)) br-env-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; Return current Env file name unless load attempt failed, then return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (defun *br-env-internal-structures* ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 "Display values of internal data structures in viewer buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (br-funcall-in-view-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (concat br-buffer-prefix-info "Info")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (let ((standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (function (lambda (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (princ obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (list "!!! " (symbol-name sym) " !!!\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (symbol-value sym) "\n \n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 '(br-children-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 br-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 br-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 br-sys-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 br-sys-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 br-lib-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 br-lib-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 br-lang-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 br-env-spec)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (defun br-env-lang-dialog-box (dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 "Prompt user with DIALOG-BOX and return selected value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 Assumes caller has checked that 'dialog-box' function exists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (let ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 event-obj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;; Add a cancel button to dialog box.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (setq dialog-box (append dialog-box (list nil '["Cancel" abort t])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (popup-dialog-box dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (catch 'br-env-done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (setq event (next-command-event event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 event-obj (event-object event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (cond ((and (menu-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (memq event-obj '(abort menu-no-selection-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (signal 'quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ((button-release-event-p event) ;; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ((menu-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (throw 'br-env-done (eval event-obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (message "Please answer the dialog box.")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (defun br-env-lang-var (lang-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 "Create language-specific Environment variables for LANG-PREFIX."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (eval (list 'defvar (intern (concat lang-prefix "env-version"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 "Version of the OO-Browser used to build the current Environment or nil."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (eval (list 'defvar (intern (concat lang-prefix "env-file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 br-env-default-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "*File in which to save Environment.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun br-env-load-matching-htables (changed-types-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (let ((still-changed-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (if (file-readable-p br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (let ((buf (get-file-buffer br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (set-buffer (funcall br-find-file-noselect-function br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (let* ((search-dirs (concat "br-" type "-search-dirs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (prev-dirs (concat "br-" type "-prev-search-dirs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (paths (concat "br-" type "-paths-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (parents (concat "br-" type "-parents-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (dirs-val (cdr (br-env-file-sym-val search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (if (equal dirs-val (symbol-value (intern search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (and (br-member type changed-types-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (progn (set (intern paths)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (cdr (br-env-file-sym-val paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (set (intern parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (cdr (br-env-file-sym-val parents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (set (intern prev-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (intern search-dirs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (setq still-changed-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (cons type still-changed-types))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 '("sys" "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (nreverse still-changed-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (defun br-env-save-mult-vars (mult-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (let ((br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (lambda (suffix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (lambda (type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (setq br-sym (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (concat "br-" type-str suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (if (and br-sym (boundp br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (let* ((nm (symbol-name br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (nm-mid (string-match "-htable$" nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if nm-mid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (progn (princ "\n") (princ (substring nm 0 nm-mid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (princ "-alist\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (hash-prin1 (symbol-value br-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (princ "\n") (princ br-sym) (princ "\n'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (prin1 (symbol-value br-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (princ "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 '("sys-" "lib-"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 mult-vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (defun br-env-set-htables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (br-env-add-ref-classes "lib")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (br-env-add-ref-classes "sys")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; Make System entries override Library entries which they duplicate, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; this is generally more desireable than merging the two. Don't do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 ;; for the paths-htable, however, since the value is the union of both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;; values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (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
800 (let ((hash-merge-values-function (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (setq br-parents-htable (hash-merge br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 br-lib-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (defun br-env-select-lang ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 "Interactively select and return value for 'br-lang-prefix'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (let ((n 0) (nlangs (length br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (lang-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; Use dialog box if last user event involved the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (use-dialog-box (and (fboundp 'popup-dialog-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (fboundp 'button-press-event-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (or (button-press-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (button-release-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (menu-event-p last-command-event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;; Create a prompt numbering each OO-Browser language available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (setq lang-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (if use-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (function (lambda (lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (setq n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (vector lang (list 'identity n) 't)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (mapcar 'car br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (function (lambda (lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (setq n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (format "%d\) %s" n lang)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (mapcar 'car br-env-lang-avector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 "; ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; Prompt user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq n (if use-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (br-env-lang-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (cons "Choose language to browse: " lang-prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; Otherwise, prompt in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (read-string (concat "Choose: " lang-prompt ": ") ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (or (< n 1) (> n nlangs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (cdr (aref br-env-lang-avector (1- n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (defun br-env-totals ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 "Return string of Environment class totals."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (let ((sys (length (br-all-classes "sys")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (lib (length (br-all-classes "lib")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (duplicates (car (br-all-classes nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (format "%sTotal unique classes: %d; System: %d; Library: %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if (null duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (setq count (length duplicates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (format "%d DUPLICATE CLASS%s TO CONSIDER ELIMINATING:\n\t%s\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 count (if (= count 1) "" "ES") duplicates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (+ sys lib) sys lib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (defvar br-env-version nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 "Version of the OO-Browser used to build the current Environment or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (defconst br-env-mult-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 '("search-dirs" "paths-htable" "parents-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 "Descriptors of multiple copy variables saved as part of an Environment.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (defconst br-env-single-vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 '("lang-prefix" "env-spec" "children-htable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 "Descriptors of singular variables saved as part of an Environment.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (defvar br-env-spec nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 "Non-nil value means Environment specification has been given but not yet built.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 Nil means current Environment has been built, though it may still require
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 updating. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (defvar br-env-lang-avector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 '[("C++" . "c++-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ("Eiffel" . "eif-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ("Info" . "info-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ("Java" . "java-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ("Lisp" . "clos-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ("Obj-C" . "objc-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ("Python" . "python-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ("Smalltalk" . "smt-")]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "Association vector of (LANGUAGE-NAME . LANGUAGE-PREFIX-STRING) elements of OO-Browser languages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (mapcar 'br-env-lang-var (mapcar 'cdr br-env-lang-avector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (provide 'br-env)