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

Added tag r20-3b8 for changeset 0132846995bd
author cvs
date Mon, 13 Aug 2007 09:43:39 +0200
parents 4be1180a9e89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: br-lib.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: OO-Browser support functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 22-Mar-90
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 20-Feb-97 at 10:55:11 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
14 ;; Copyright (C) 1990-1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (mapcar 'require '(br-env br-ftr br-compl set))
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-null-path "<none>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "Pathname associated with OO-Browser entities which have no source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 That is, virtual entities, such as categories.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; General public functions
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 (defun br-buffer-replace (regexp to-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "In current buffer, replace all occurrences of REGEXP with TO-STR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (while (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (replace-match to-str 'fixedcase nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (backward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defun br-delete-space (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Delete any leading and trailing space from STRING and return the STRING. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (string-match "\\`\\s *\\(\\(.\\|\n\\)*\\S \\)\\s *\\'" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (setq string (substring string (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defun br-first-match (regexp list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "Return non-nil if REGEXP matches to an element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 All elements of LIST must be strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 The value returned is the first matched element."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (while (and list (not (string-match regexp (car list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defun br-filename-head (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (setq path (file-name-nondirectory path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (if (string-match "\\(.+\\)\\." path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (substring path 0 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun br-duplicate-and-unique-strings (sorted-strings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Return SORTED-STRINGS list with a list of duplicate entries consed onto the front of the list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (let ((elt1) (elt2) (lst sorted-strings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (count 0) (repeat) (duplicates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (while (setq elt1 (car lst) elt2 (car (cdr lst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (cond ((not (string-equal elt1 elt2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq lst (cdr lst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ((equal elt1 repeat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; Already recorded this duplicate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setcdr lst (cdr (cdr lst))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (t ;; new duplicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (setq count (1+ count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 duplicates (cons elt1 duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 repeat elt1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setcdr lst (cdr (cdr lst))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (cons (sort duplicates 'string-lessp) sorted-strings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defun br-set-of-strings (sorted-strings &optional count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Return SORTED-STRINGS list with any duplicate entries removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Optional COUNT conses number of duplicates on to front of list before return."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (and count (setq count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((elt1) (elt2) (lst sorted-strings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (test (if count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (lambda (a b) (if (string-equal a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq count (1+ count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (function (lambda (a b) (string-equal a b))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (while (setq elt1 (car lst) elt2 (car (cdr lst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (if (funcall test elt1 elt2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (setcdr lst (cdr (cdr lst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq lst (cdr lst)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if count (cons count sorted-strings) sorted-strings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun br-member-sorted-strings (elt list)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
99 "Return non-nil if ELT is an element of LIST. Comparison done with `string-equal'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 All ELTs must be strings and the list must be sorted in ascending order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 The value returned is actually the tail of LIST whose car is ELT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (while (and list (not (string-equal (car list) elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq list (and (string-lessp (car list) elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun br-pathname-head (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (string-match "\\(.+\\)\\." path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (substring path 0 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun br-quote-match (match-num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "Quote special symbols in last matched expression MATCH-NUM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (br-regexp-quote (buffer-substring (match-beginning match-num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (match-end match-num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defun br-rassoc (elt list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "Return non-nil if ELT is the cdr of an element of LIST.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
119 Comparison done with `equal'. The value is actually the tail of LIST
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 starting at the element whose cdr is ELT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (while (and list (not (equal (cdr (car list)) elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun br-regexp-quote (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "If OBJ is a string, quote and return it for use in a regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; Don't use (stringp obj) here since we want to signal an error if some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; caller ever passes in a non-nil, non-string object, to aid in debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (if obj (regexp-quote obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defun br-relative-path (filename &optional directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "Convert FILENAME to be relative to DIRECTORY or default-directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 The shorter of the absolute and relative paths is returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((relative-path (file-relative-name filename directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if (< (length relative-path) (length filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 relative-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defmacro br-set-cons (set elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Add to SET element ELT. Returns nil iff ELT is already in SET.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
141 Uses `equal' for comparison."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (` (if (br-member (, elt) (, set))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq (, set) (cons (, elt) (, set))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defun br-wind-line-at-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "Return window relative line number that point is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (max 0 (1- (- (count-lines 1 (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (count-lines 1 (window-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; Browser public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defun br-add-class (class-name &optional class-path lib-table-p save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "Add or replace CLASS-NAME in current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 Find class source in optional CLASS-PATH. Interactively or when optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 CLASS-PATH is nil, defaults to current buffer file as CLASS-PATH. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 optional LIB-TABLE-P is non-nil, add to Library Environment, otherwise add to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 System Environment. If optional SAVE-FILE is t, the Environment is then
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
162 stored to filename given by `br-env-file'. If SAVE-FILE is non-nil and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 not t, its string value is used as the file to which to save the Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Does not update children lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (list (read-string "Class name to add: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (read-file-name (concat "Class file name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 " (default <current file>)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ": ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 nil buffer-file-name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (y-or-n-p "Add to Library, rather than System tables? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (concat "Save tables after addition to " br-env-file "? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; Pseudo code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; If class-name is in table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; If function called interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; Query whether should overwrite class-name in tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; If yes
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
182 ;; Replace class and its features
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; Don't add class; do nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; else
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
187 ;; Store class without its features in all necessary tables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; else
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
190 ;; Store class and its features under key in all necessary tables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (or class-path (setq class-path buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (error "No class pathname specified."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if (or (string-equal class-name "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (not (or (equal class-path br-null-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (file-exists-p class-path))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
198 (error (format "Invalid class specified, `%s', in: %s" class-name class-path)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; Is class already in Environment?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (if (hash-key-p class-name (br-get-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if lib-table-p "lib-parents" "sys-parents")))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
202 (if (or (not (interactive-p))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
203 (y-or-n-p (format "Overwrite existing `%s' entry? " class-name)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
204 (br-real-add-class lib-table-p class-name class-path t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
205 (setq save-file nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (br-real-add-class lib-table-p class-name class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (cond ((eq save-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ((eq save-file t) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((br-env-save save-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defun br-build-lib-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Build Library dependent Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (cond ((and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (not (y-or-n-p "Rebuild Library Environment? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (message "Building Library Environment...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (setq br-lib-paths-htable (hash-make br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 br-lib-parents-htable (hash-make br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (run-hooks 'br-after-build-lib-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (br-env-set-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (br-build-children-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; Set prev-search-dirs so table rebuilds are not triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq br-lib-prev-search-dirs br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (message "Building Library Environment...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defun br-build-sys-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "Build System dependent class Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (cond ((and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (not (y-or-n-p "Rebuild System Environment? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (message "Building System Environment...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setq br-sys-paths-htable (hash-make br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 br-sys-parents-htable (hash-make br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (run-hooks 'br-after-build-sys-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (br-env-set-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (br-build-children-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; Set prev-search-dirs so table rebuilds are not triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq br-sys-prev-search-dirs br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (message "Building System Environment...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun br-class-in-table-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "Return t iff CLASS-NAME is found in current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if class-name (hash-key-p class-name (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun br-class-path (class-name &optional insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "Return full path, if any, to CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 With optional prefix argument INSERT non-nil, insert path at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 Only the first matching class is returned, so each CLASS-NAME should be
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
262 unique. Set `br-lib/sys-search-dirs' properly before use."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (setq class-name (if class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (let* ((class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (class-htable (br-get-paths-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (function (lambda (val-key-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (and (null class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (br-member-sorted-strings class-name (car val-key-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq class-path (br-select-path val-key-cons nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 class-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (equal class-path br-null-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq class-path nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (and (interactive-p) (setq insert current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (and insert class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (insert class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (or class-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (format
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
282 "(OO-Browser): No `%s' class found in `br-lib/sys-search-dirs'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 class-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun br-find-class (&optional class-name view-only other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "Display file of class text matching CLASS-NAME in VIEW-ONLY mode if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 Return t if class is successfully displayed, nil otherwise. Can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 signal an error when called interactively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (and (interactive-p) (setq view-only current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (let ((class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (info (equal br-lang-prefix "info-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (err))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (or class-name (br-complete-class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 class-path (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (info (info-find-nd class-path class-name (not view-only)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (class-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (if (file-readable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (progn (if view-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (funcall br-view-file-function class-path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (funcall br-edit-file-function class-path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; Handle case of already existing buffer in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; read only mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (and buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (file-writable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (progn (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Force mode-line redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (set-buffer-modified-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (br-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (pmin (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (pmax (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (class-def (br-class-definition-regexp class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (if br-narrow-view-to-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; Display file narrowed to definition of
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
323 ;; `class-name'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (if (re-search-forward class-def nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; Narrow display to this class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (progn (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (progn (setq opoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (goto-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (br-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (progn (br-to-class-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (narrow-to-region pmin pmax)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
339 (setq err (format "(OO-Browser): No `%s' in %s" class-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (re-search-forward class-def nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (progn (setq opoint (goto-char (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (br-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (recenter 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (narrow-to-region pmin pmax)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
348 (setq err (format "(OO-Browser): No `%s' in %s" class-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq class-path t))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
352 (setq err (format "(OO-Browser): `%s' - src file not found or not readable, %s"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 class-name class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 class-path nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq err
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
358 (format "(OO-Browser): No `%s' class defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if err (error err))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun br-major-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "Invoke language-specific major mode on current buffer if not already set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (or (eq major-mode (symbol-function 'br-lang-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (br-lang-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
369 (defun br-scan-mode ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
370 "Invoke language-specific major mode for current buffer without running its hooks.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
371 This is used when scanning source files to build Environments."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
372 (let ((mode-hook-sym
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
373 (intern-soft (concat (symbol-name (symbol-function 'br-lang-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
374 "-hook"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
375 (if mode-hook-sym
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
376 (eval (` (let ((, mode-hook-sym)) (br-lang-mode))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
377 (br-lang-mode))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
378
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defun br-show-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Return children of CLASS-NAME from current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (interactive (list (br-complete-class-name t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (and class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (br-get-children class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defun br-show-parents (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 "Return parents of CLASS-NAME from Environment or scan of current buffer's source."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (interactive (list (br-complete-class-name t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (if (br-class-in-table-p class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (br-get-parents class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (and buffer-file-name (file-readable-p buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (br-get-parents-from-source buffer-file-name class-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (defun br-undefined-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "Return a list of the classes referenced but not defined within the current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (let ((classes (hash-get br-null-path (br-get-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (delq nil (mapcar (function (lambda (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; Remove default classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (/= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defun br-add-to-paths-htable (class-name paths-key htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "Add CLASS-NAME under PATHS-KEY in paths lookup HTABLE, keeping the classes sorted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (let ((other-classes (hash-get paths-key htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if (and other-classes (br-member-sorted-strings class-name other-classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (hash-add (sort (cons class-name other-classes) 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 paths-key htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun br-build-lib-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if (not br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (message "Building Library parent...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (hash-make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if br-lib-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (br-real-build-parents-alist br-lib-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 br-parents-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (message "Building Library parent...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (defun br-build-lib-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (if (not br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (message "Building Library paths...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq br-lib-paths-htable (hash-make br-paths-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (message "Building Library paths...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun br-build-sys-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (not br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (message "Building System parents...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (setq br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (hash-make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if br-sys-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (br-real-build-parents-alist br-sys-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 br-parents-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (message "Building System parents...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun br-build-sys-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (not br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (message "Building System paths...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq br-sys-paths-htable (hash-make br-paths-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (message "Building System paths...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun br-build-children-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (setq br-children-htable (br-real-build-children-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (interactive-p) (br-env-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defun br-build-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (br-build-sys-parents-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (br-build-lib-parents-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; Make System entries override Library entries which they duplicate, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; this is generally more desireable than merging the two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (let ((hash-merge-values-function (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq br-parents-htable (hash-merge br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 br-lib-parents-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (interactive-p) (br-env-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defun br-build-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (br-build-sys-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (br-build-lib-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (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
489 (if (interactive-p) (br-env-save)))
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-class-defined-p (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "Return path for CLASS if defined in current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 Otherwise, display error and return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (or (br-class-path class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (if (br-class-in-table-p class)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
499 (format "(OO-Browser): Class `%s' referenced but not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 class)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
501 (format "(OO-Browser): Class `%s' not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (defun br-check-for-class (cl &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "Try to display class CL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 Display message and return nil if unsucessful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (br-class-in-table-p cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (or (br-find-class cl nil other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (message
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
513 (format "(OO-Browser): Class `%s' referenced but not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
517 (defun br-delete-features (class)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
518 "Delete all feature tags lexically defined in CLASS."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
519 (br-feature-map-class-tags
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
520 (function (lambda ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
521 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
522 (delete-region (point) (progn (forward-line 1) (point)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
523 class)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
524 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
525
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (defun br-get-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 "Return list of children of CLASS-NAME from child lookup table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 Those which directly inherit from CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (br-set-of-strings (hash-get class-name (br-get-children-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun br-get-parents (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "Return list of parents of CLASS-NAME from parent lookup table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Those from which CLASS-NAME directly inherits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (br-set-of-strings (hash-get class-name (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun br-get-children-htable ()
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
539 "Loads or builds `br-children-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (br-get-htable "children"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defun br-get-paths-htable ()
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
543 "Loads or builds `br-paths-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (br-get-htable "paths"))
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-get-parents-htable ()
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
547 "Loads or builds `br-parents-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (br-get-htable "parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (defun br-get-children-from-parents-htable (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 "Return list of children of CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 Those that directly inherit from CLASS-NAME. Use parent lookup table to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 compute children."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (delq nil (hash-map (function (lambda (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (if (and (consp cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (br-member class-name (car cns)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defun br-get-htable (htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "Return hash table corresponding to string, HTABLE-TYPE. When necessary,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 load the hash table from a file or build it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (let* ((htable-symbol (intern-soft (concat "br-" htable-type "-htable")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (htable-specific (if (string-match "sys\\|lib" htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (substring htable-type (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 changed-types non-matched-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (if (equal htable-type "children")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (if (and (or (not htable-specific) (equal htable-specific "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (or (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (not (equal br-lib-prev-search-dirs br-lib-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (setq changed-types '("lib")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (if (and (or (not htable-specific) (equal htable-specific "sys"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (or (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (not (equal br-sys-prev-search-dirs br-sys-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (setq changed-types (cons "sys" changed-types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (if (and (or br-lib-search-dirs br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (or changed-types (null (symbol-value htable-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (not (boundp 'br-loaded)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; Then need to load or rebuild htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (progn (if (and br-env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (file-exists-p br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; Try to load from file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (progn (setq non-matched-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (br-env-load-matching-htables changed-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (if non-matched-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (setq changed-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (delq nil (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (if (br-member type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 changed-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 non-matched-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (and changed-types (br-env-set-htables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq changed-types nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (cond (htable-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ((equal htable-type "children")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (progn (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq br-children-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (cdr (br-env-file-sym-val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 "br-children-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ((let ((suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (concat "-" htable-type "-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 'hash-merge-values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; Make System entries override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; Library entries which they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;; duplicate, if this is the parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if (equal htable-type "parents")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (setq hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (set htable-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (hash-merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (concat "br-sys" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 "br-lib" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; Rebuild any lists that need to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (lambda (type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (let ((suffix (concat "-" htable-type "-htable")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (funcall (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (concat "br-build-" type-str suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (and htable-specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; Make System entries override Library entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ;; which they duplicate, if this is the parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (let ((hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 'hash-merge-values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (equal htable-type "parents")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (set htable-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (hash-merge (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (concat "br-sys" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (concat "br-lib" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 )))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 changed-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (if (and changed-types br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (let ((buf (get-file-buffer br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;; Return non-nil hash table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (if (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (set htable-symbol (hash-make 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (symbol-value htable-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun br-get-top-class-list (htable-type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "Returns unordered list of top-level classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Those that do not explicitly inherit from any other classes. Obtains classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 from list denoted by HTABLE-TYPE-STR whose values may be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 \"parents\", \"sys-parents\", or \"lib-parents\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (delq nil (hash-map (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (lambda (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (and (null (car cns)) (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (br-get-htable htable-type-str))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun br-get-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 "Returns lexicographically ordered list of top-level classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (br-get-top-class-list "parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (defun br-get-lib-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 "Returns lexicographically ordered list of top-level Library classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (br-get-top-class-list "lib-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (defun br-get-sys-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 "Returns lexicographically ordered list of top-level System classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (br-get-top-class-list "sys-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (defun br-has-children-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 "Return non-nil iff CLASS-NAME has at least one child.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 That is a class that directly inherits from CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (hash-get class-name (br-get-children-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (defun br-has-parents-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 "Return non-nil iff CLASS-NAME has at least one parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 That is a class which is a direct ancestor of CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (hash-get class-name (br-get-parents-htable)))
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-get-process-group (group max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 "Return list of all active processes in GROUP (a string).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 MAX is max number of processes to check for."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (proc-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (while (<= i max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 proc-list (cons (get-process (concat group (int-to-string i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 proc-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (delq nil proc-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (defun br-kill-process-group (group max group-descrip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 "Optionally question user, then kill all subprocesses in named GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 Processes are numbered one to MAX, some of which may have been killed already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 User is prompted with a string containing GROUP-DESCRIP, only if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 Return list of processes killed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (let ((proc-list (br-get-process-group group max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (if proc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (if (or (null group-descrip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (y-or-n-p (concat "Terminate all " group-descrip "? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (prog1 (mapcar 'delete-process proc-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (message ""))))))
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-real-add-class (lib-table-p class-name class-path &optional replace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
728 "Add or replace class and its features within the current Environment.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 If LIB-TABLE-P is non-nil, add to Library Environment, otherwise add to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 System Environment. Add class CLASS-NAME located in CLASS-PATH to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 Environment. If CLASS-PATH is nil, use current buffer file as CLASS-PATH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 Optional REPLACE non-nil means replace already existing class. Does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 update children lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (or class-path (setq class-path buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (let ((par-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (paths-key class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (class class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (if replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (setq func 'hash-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 class-name (br-first-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (concat "^" (regexp-quote class-name) "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (hash-get paths-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (if lib-table-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (br-get-htable "lib-paths")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (br-get-htable "sys-paths"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 par-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (and (stringp class-path) (file-readable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (br-get-parents-from-source class-path class-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (setq func 'hash-add))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ;; Signal error if class-name is invalid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (if (null class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (if replace
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
755 (error "(br-real-add-class): `%s' not found in %s classes, so cannot replace it."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 class (if lib-table-p "Library" "System"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 "(br-real-add-class): Attempt to add null class to %s classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if lib-table-p "Library" "System"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (let ((par-htable (br-get-htable (concat type "parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (path-htable (br-get-htable (concat type "paths"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (funcall func par-list class-name par-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (br-add-to-paths-htable class-name paths-key path-htable))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
768 (list (if lib-table-p "lib-" "sys-") ""))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
769 (and (stringp class-path) (file-readable-p class-path)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
770 (br-get-classes-from-source class-path))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (defun br-real-delete-class (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 "Delete class CLASS-NAME from current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 No error occurs if the class is undefined in the Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (require 'set)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
776 (br-delete-features class-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (let ((paths-key (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (setq class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (br-first-match (concat "^" class-name "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (hash-get paths-key (br-get-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (progn (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (hash-delete class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (br-get-htable (concat type "parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (setq htable (br-get-htable (concat type "paths")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (if (hash-key-p paths-key htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (hash-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (set:remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (hash-get paths-key htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 paths-key htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 '("lib-" "sys-" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (hash-delete class-name (br-get-children-htable))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (defun br-real-build-children-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 "Build and return Environment parent to child lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (let* ((par-ht (br-get-parents-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (htable (hash-make (hash-size par-ht)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (child))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (lambda (par-child-cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (setq child (cdr par-child-cns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (lambda (parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (hash-add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (cons child (hash-get parent htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 parent htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (car par-child-cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 par-ht)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (hash-map (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (lambda (children-parent-cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (hash-replace (sort (car children-parent-cns) 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (cdr children-parent-cns) htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (defun br-real-get-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 "Return list of child classes of CLASS-NAME listed in Environment parents htable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (delq nil (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (lambda (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (if (and (consp cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (br-member class-name (car cns)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (defun br-real-build-alists (search-dirs)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
833 "Use SEARCH-DIRS to build `br-paths-alist' and `br-parents-alist'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (setq br-paths-alist nil br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (br-feature-tags-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (br-real-build-al search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq br-paths-alist br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (br-feature-tags-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (defvar br-paths-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defvar br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (defun br-skip-dir-p (dir-name)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
845 "Returns non-nil iff DIR-NAME is matched by a member of `br-skip-dir-regexps'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (lambda (dir-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (string-match dir-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (directory-file-name dir-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 br-skip-dir-regexps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;;; If abbreviate-file-name is not defined, just make it return the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;; string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (or (fboundp 'abbreviate-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (fset 'abbreviate-file-name 'identity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (defun br-real-build-al (search-dirs)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
860 "Descend SEARCH-DIRS and build `br-paths-alist' and `br-parents-alist'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
861 Does not initialize `br-paths-alist' or `br-parents-alist' to nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (let ((inhibit-local-variables nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (enable-local-variables t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (files)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
865 ;; These are used in the `br-search-directory' function.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 classes parents paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (lambda (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (if (or (null dir) (equal dir "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (progn (setq dir (file-name-as-directory dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (br-skip-dir-p dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq files (if (and (file-directory-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (file-readable-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (directory-files dir t br-file-dir-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; Extract all class/parent names in all source files in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; particular directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (if files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (progn (message "Scanning %s in %s ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (or (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (br-search-directory dir files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ;; Call same function on all the directories below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (br-real-build-al
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (mapcar (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (if (file-directory-p f) f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 files)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (defun br-search-directory (dir files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (if (file-readable-p f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (setq paths-parents-cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (message "Scanning %s in %s ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (or (file-name-directory f) default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (br-get-classes-from-source f nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 classes (car paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 parents (cdr paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 br-paths-alist (if classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (cons (cons (sort classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 'string-lessp) f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 br-parents-alist (if parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (append br-parents-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (message "(OO-Browser): Unreadable file: %s in %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (or (file-name-directory f) default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (sit-for 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; List of files potentially containing classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (and (string-match br-src-file-regexp f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (not (file-directory-p f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (defun br-real-build-parents-alist (paths-htable)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
935 "Build and return `br-parents-alist' of (parent-list . class) elements built from PATHS-HTABLE.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
936 Initializes `br-parents-alist' to nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (let ((inhibit-local-variables nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (enable-local-variables t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (setq br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (lambda (cl-dir-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (lambda (class-dir-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (let ((dir (cdr class-dir-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (lambda (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (setq br-parents-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (cons (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (and (stringp dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (file-exists-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (br-get-parents-from-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 dir class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 br-parents-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (car class-dir-cons)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 cl-dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (defun br-set-lang-env (func sym-list val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 "Use FUNC to set each element in SYM-LIST.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
965 If VAL is non-nil, set `br' element to value of current OO-Browser language
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 element with the same name, otherwise set to symbol."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (let ((br) (lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (setq br (intern (concat "br-" nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 lang (intern-soft (concat br-lang-prefix nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (funcall func br (if val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (symbol-value lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (or lang 'br-undefined-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 sym-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (defun br-undefined-function (&rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (error "(OO-Browser): That command is not supported for this language."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (defun br-setup-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 "Initialize appropriate function pointers for the current browser language."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (br-set-lang-env 'fset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 '("class-definition-regexp" "class-list-filter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "get-classes-from-source" "get-parents-from-source"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 "insert-class-info" "set-case" "set-case-type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 "to-class-end" "to-comments-begin" "to-definition"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 "select-path"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 "feature-implementors" "feature-locate-p"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
991 "feature-name-to-regexp" "feature-map-class-tags"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
992 "feature-signature-to-name"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 "feature-signature-to-regexp" "feature-tag-class"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
994 "feature-tag-regexp" "feature-tree-command-p"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 "list-categories" "list-features" "list-protocols"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 "view-friend" "view-protocol")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (defun br-setup-constants ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 "Initialize appropriate constant values for the current browser language."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; Clear language-dependent hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (setq br-after-build-lib-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 br-after-build-sys-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; Set language-specific constants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (br-set-lang-env 'set '("class-def-regexp" "env-file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 "identifier" "identifier-chars"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 "src-file-regexp" "narrow-view-to-class"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 "type-tag-separator")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (defvar br-lib-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 "List of directories below which library dirs and source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 A library is a stable group of classes. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (defvar br-sys-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "List of directories below which system dirs and source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 A system is a group of classes that are likely to change. Value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (defvar br-lib-prev-search-dirs nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1024 "Used to check if `br-lib-paths-htable' must be regenerated.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (defvar br-sys-prev-search-dirs nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1027 "Used to check if `br-sys-paths-htable' must be regenerated.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (defun br-find-file (filename &optional other-win read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 "Edit file FILENAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 Switch to a buffer visiting file FILENAME, creating one if none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 already exists. Optional OTHER-WIN means show in other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 Optional READ-ONLY means make buffer read-only."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (interactive "FFind file: ")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1036 (if (br-in-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1037 (progn (br-to-view-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1038 (setq other-win nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (funcall (if other-win 'switch-to-buffer-other-window 'switch-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (find-file-noselect filename))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1041 (if read-only (setq buffer-read-only t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (defun br-find-file-read-only (filename &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 "Display file FILENAME read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 Switch to a buffer visiting file FILENAME, creating one if none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 already exists. Optional OTHER-WIN means show in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (interactive "FFind file read-only: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (br-find-file filename other-win t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defvar br-edit-file-function 'br-find-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 "*Function to call to edit a class file within the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (defvar br-view-file-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (if (eq br-edit-file-function 'br-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 'br-find-file-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 br-edit-file-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 "*Function to call to view a class file within the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (defvar br-find-file-noselect-function 'find-file-noselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 "Function to call to load a browser file but not select it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 The function must return the buffer containing the file's contents.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (defvar *br-tmp-buffer* "*oobr-tmp*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 "Name of temporary buffer used by the OO-Browser for parsing source files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (defun br-insert-file-contents (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 "Insert FILENAME contents into a temporary buffer and select buffer.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1067 Does not run any find-file or mode specific hooks. Marks buffer read-only to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1068 prevent any accidental editing.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1070 Set `br-view-file-function' to this function when parsing OO-Browser source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 files for fast loading of many files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (let ((buf (get-buffer-create *br-tmp-buffer*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (switch-to-buffer buf)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1074 ;; Don't bother saving anything for this temporary buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (buffer-disable-undo buf)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1076 (setq buffer-auto-save-file-name nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1077 buffer-read-only nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (erase-buffer)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1079 (insert-file-contents filename t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1080 (br-scan-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1081 (setq buffer-read-only t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (defvar br-lang-prefix nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 "Prefix string that starts language-specific symbol names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (defvar br-children-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 "Htable whose elements are of the form: (LIST-OF-CHILD-CLASSES . CLASS-NAME).
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1088 Used to traverse class inheritance graph. `br-build-children-htable' builds
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 this list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defvar br-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1092 Used to traverse class inheritance graph. `br-build-parents-htable' builds
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 this list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (defvar br-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1097 `br-build-paths-htable' builds this list. Value is language-specific.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (defvar br-lib-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 Only classes from stable software libraries are used to build the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (defvar br-lib-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 Only classes from stable software libraries are used to build the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (defvar br-sys-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 Only classes from systems that are likely to change are used to build the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (defvar br-sys-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 Only classes from systems that are likely to change are used to build the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (defvar br-file-dir-regexp "\\`[^.~#]\\(.*[^.~#]\\)?\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 "Regexp that matches only to files and directories that the OO-Browser should scan.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 Others are ignored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (defvar br-src-file-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 "Regular expression matching a unique part of source file names and no others.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (defvar br-narrow-view-to-class nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 "Non-nil means narrow buffer to just the matching class definition when displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 Don't set this, use the language specific variable instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (provide 'br-lib)