annotate lisp/oobr/br-lib.el @ 97:498bf5da1c90

Added tag r20-0final for changeset dbb370e3c29e
author cvs
date Mon, 13 Aug 2007 09:12:43 +0200
parents 131b0175ea99
children 4be1180a9e89
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
9 ;; ORG: Motorola Inc.
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
12 ;; LAST-MOD: 21-Sep-95 at 14:30:36 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
14 ;; Copyright (C) 1990-1995 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)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
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.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
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.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
182 ;; Replace entry
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
187 ;; Store class 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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
190 ;; Store class 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))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
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")))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
202 (if (interactive-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
203 (if (y-or-n-p (format "Overwrite existing '%s' entry? " class-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
204 (br-real-add-class lib-table-p class-name class-path 'replace)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
205 (setq save-file nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
206 (br-real-add-class lib-table-p class-name class-path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (br-real-add-class lib-table-p class-name class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (cond ((eq save-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((eq save-file t) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ((br-env-save save-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun br-build-lib-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "Build Library dependent Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cond ((and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (not (y-or-n-p "Rebuild Library Environment? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (message "Building Library Environment...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq br-lib-paths-htable (hash-make br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 br-lib-parents-htable (hash-make br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (run-hooks 'br-after-build-lib-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (br-env-set-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (br-build-children-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Set prev-search-dirs so table rebuilds are not triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq br-lib-prev-search-dirs br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (message "Building Library Environment...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defun br-build-sys-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "Build System dependent class Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (cond ((and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (not (y-or-n-p "Rebuild System Environment? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (message "Building System Environment...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (setq br-sys-paths-htable (hash-make br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 br-sys-parents-htable (hash-make br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (run-hooks 'br-after-build-sys-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (br-env-set-htables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (br-build-children-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; Set prev-search-dirs so table rebuilds are not triggered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq br-sys-prev-search-dirs br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (message "Building System Environment...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun br-class-in-table-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Return t iff CLASS-NAME is found in current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if class-name (hash-key-p class-name (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun br-class-path (class-name &optional insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 "Return full path, if any, to CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 With optional prefix argument INSERT non-nil, insert path at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Only the first matching class is returned, so each CLASS-NAME should be
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
263 unique. Set 'br-lib/sys-search-dirs' properly before use."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq class-name (if class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (let* ((class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (class-htable (br-get-paths-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (function (lambda (val-key-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (and (null class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (br-member-sorted-strings class-name (car val-key-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq class-path (br-select-path val-key-cons nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 class-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (equal class-path br-null-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq class-path nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (and (interactive-p) (setq insert current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (and insert class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (insert class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (or class-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (format
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
283 "(OO-Browser): No '%s' class found in 'br-lib/sys-search-dirs'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 class-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defun br-find-class (&optional class-name view-only other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "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
289 Return t if class is successfully displayed, nil otherwise. Can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 signal an error when called interactively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (and (interactive-p) (setq view-only current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (let ((class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (info (equal br-lang-prefix "info-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (err))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setq class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (or class-name (br-complete-class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 class-path (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (info (info-find-nd class-path class-name (not view-only)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (class-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (if (file-readable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (progn (if view-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (funcall br-view-file-function class-path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (funcall br-edit-file-function class-path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; Handle case of already existing buffer in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; read only mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (and buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (file-writable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (progn (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; Force mode-line redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (set-buffer-modified-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (br-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (let ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (pmin (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (pmax (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (class-def (br-class-definition-regexp class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if br-narrow-view-to-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; Display file narrowed to definition of
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
324 ;; 'class-name'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (if (re-search-forward class-def nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; Narrow display to this class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (progn (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (progn (setq opoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (goto-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (br-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (progn (br-to-class-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (narrow-to-region pmin pmax)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
340 (setq err (format "(OO-Browser): No '%s' in %s" class-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if (re-search-forward class-def nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (progn (setq opoint (goto-char (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (br-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (recenter 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (narrow-to-region pmin pmax)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
349 (setq err (format "(OO-Browser): No '%s' in %s" class-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq class-path t))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
353 (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
354 class-name class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 class-path nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq err
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
359 (format "(OO-Browser): No '%s' class defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if err (error err))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 class-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun br-major-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "Invoke language-specific major mode on current buffer if not already set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (or (eq major-mode (symbol-function 'br-lang-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (br-lang-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun br-show-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "Return children of CLASS-NAME from current Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (interactive (list (br-complete-class-name t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (and class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (br-get-children class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun br-show-parents (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "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
378 (interactive (list (br-complete-class-name t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (if (br-class-in-table-p class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (br-get-parents class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (and buffer-file-name (file-readable-p buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (br-get-parents-from-source buffer-file-name class-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (defun br-undefined-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "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
388 (let ((classes (hash-get br-null-path (br-get-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (delq nil (mapcar (function (lambda (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; Remove default classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (/= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defun br-add-to-paths-htable (class-name paths-key htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "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
401 (let ((other-classes (hash-get paths-key htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if (and other-classes (br-member-sorted-strings class-name other-classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (hash-add (sort (cons class-name other-classes) 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 paths-key htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun br-build-lib-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (if (not br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (message "Building Library parent...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq br-lib-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (hash-make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if br-lib-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (br-real-build-parents-alist br-lib-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 br-parents-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (message "Building Library parent...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defun br-build-lib-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (not br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (message "Building Library paths...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (br-real-build-alists br-lib-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (setq br-lib-paths-htable (hash-make br-paths-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (message "Building Library paths...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun br-build-sys-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (not br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (message "Building System parents...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (hash-make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if br-sys-paths-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (br-real-build-parents-alist br-sys-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 br-parents-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (message "Building System parents...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun br-build-sys-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (if (not br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (message "Building System paths...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (br-real-build-alists br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq br-sys-paths-htable (hash-make br-paths-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (if (interactive-p) (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (message "Building System paths...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defun br-build-children-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (setq br-children-htable (br-real-build-children-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (interactive-p) (br-env-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defun br-build-parents-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (br-build-sys-parents-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (br-build-lib-parents-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Make System entries override Library entries which they duplicate, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;; this is generally more desireable than merging the two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (let ((hash-merge-values-function (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (setq br-parents-htable (hash-merge br-sys-parents-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 br-lib-parents-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (if (interactive-p) (br-env-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun br-build-paths-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (br-build-sys-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (br-build-lib-paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (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
480 (if (interactive-p) (br-env-save)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defun br-class-defined-p (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 "Return path for CLASS if defined in current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Otherwise, display error and return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (or (br-class-path class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (if (br-class-in-table-p class)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
490 (format "(OO-Browser): Class '%s' referenced but not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 class)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
492 (format "(OO-Browser): Class '%s' not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun br-check-for-class (cl &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 "Try to display class CL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 Display message and return nil if unsucessful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (if (br-class-in-table-p cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (or (br-find-class cl nil other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (message
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
504 (format "(OO-Browser): Class '%s' referenced but not defined in Environment."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun br-get-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "Return list of children of CLASS-NAME from child lookup table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 Those which directly inherit from CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (br-set-of-strings (hash-get class-name (br-get-children-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (defun br-get-parents (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "Return list of parents of CLASS-NAME from parent lookup table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 Those from which CLASS-NAME directly inherits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (br-set-of-strings (hash-get class-name (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (defun br-get-children-htable ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
521 "Loads or builds 'br-children-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (br-get-htable "children"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun br-get-paths-htable ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
525 "Loads or builds 'br-paths-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (br-get-htable "paths"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defun br-get-parents-htable ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
529 "Loads or builds 'br-parents-htable' if necessary and returns value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (br-get-htable "parents"))
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-children-from-parents-htable (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "Return list of children of CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Those that directly inherit from CLASS-NAME. Use parent lookup table to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 compute children."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (delq nil (hash-map (function (lambda (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (if (and (consp cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (br-member class-name (car cns)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (defun br-get-htable (htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "Return hash table corresponding to string, HTABLE-TYPE. When necessary,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 load the hash table from a file or build it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (let* ((htable-symbol (intern-soft (concat "br-" htable-type "-htable")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (htable-specific (if (string-match "sys\\|lib" htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (substring htable-type (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 changed-types non-matched-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (if (equal htable-type "children")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if (and (or (not htable-specific) (equal htable-specific "lib"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (or (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (not (equal br-lib-prev-search-dirs br-lib-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (setq changed-types '("lib")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (if (and (or (not htable-specific) (equal htable-specific "sys"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (or (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (not (equal br-sys-prev-search-dirs br-sys-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (setq changed-types (cons "sys" changed-types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (and (or br-lib-search-dirs br-sys-search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (or changed-types (null (symbol-value htable-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (not (boundp 'br-loaded)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; Then need to load or rebuild htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (progn (if (and br-env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (file-exists-p br-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;; Try to load from file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (progn (setq non-matched-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (br-env-load-matching-htables changed-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if non-matched-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq changed-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (delq nil (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (if (br-member type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 changed-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 non-matched-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (and changed-types (br-env-set-htables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq changed-types nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (cond (htable-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ((equal htable-type "children")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (progn (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (setq br-children-htable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (cdr (br-env-file-sym-val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 "br-children-htable")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ((let ((suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (concat "-" htable-type "-htable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 'hash-merge-values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; Make System entries override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; Library entries which they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; duplicate, if this is the parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (if (equal htable-type "parents")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (set htable-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (hash-merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (concat "br-sys" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 "br-lib" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; Rebuild any lists that need to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (lambda (type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (let ((suffix (concat "-" htable-type "-htable")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (funcall (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (concat "br-build-" type-str suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (and htable-specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; Make System entries override Library entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; which they duplicate, if this is the parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; htable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (let ((hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 'hash-merge-values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if (equal htable-type "parents")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq hash-merge-values-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (function (lambda (val1 val2) val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (set htable-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (hash-merge (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (concat "br-sys" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (concat "br-lib" suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 )))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 changed-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if (and changed-types br-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (br-env-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (let ((buf (get-file-buffer br-env-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; Return non-nil hash table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (null (symbol-value htable-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (set htable-symbol (hash-make 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (symbol-value htable-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (defun br-get-top-class-list (htable-type-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 "Returns unordered list of top-level classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 Those that do not explicitly inherit from any other classes. Obtains classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 from list denoted by HTABLE-TYPE-STR whose values may be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 \"parents\", \"sys-parents\", or \"lib-parents\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (delq nil (hash-map (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (lambda (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (and (null (car cns)) (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (br-get-htable htable-type-str))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (defun br-get-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 "Returns lexicographically ordered list of top-level classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (br-get-top-class-list "parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun br-get-lib-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 "Returns lexicographically ordered list of top-level Library classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (br-get-top-class-list "lib-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (defun br-get-sys-top-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 "Returns lexicographically ordered list of top-level System classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 Those that do not explicitly inherit from any other classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (br-get-top-class-list "sys-parents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (defun br-has-children-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 "Return non-nil iff CLASS-NAME has at least one child.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 That is a class that directly inherits from CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (hash-get class-name (br-get-children-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (defun br-has-parents-p (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 "Return non-nil iff CLASS-NAME has at least one parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 That is a class which is a direct ancestor of CLASS-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (setq class-name (and class-name (br-set-case class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (hash-get class-name (br-get-parents-htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defun br-get-process-group (group max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 "Return list of all active processes in GROUP (a string).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 MAX is max number of processes to check for."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (proc-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (while (<= i max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 proc-list (cons (get-process (concat group (int-to-string i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 proc-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (delq nil proc-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
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-kill-process-group (group max group-descrip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 "Optionally question user, then kill all subprocesses in named GROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 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
700 User is prompted with a string containing GROUP-DESCRIP, only if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 Return list of processes killed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (let ((proc-list (br-get-process-group group max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (if proc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (if (or (null group-descrip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (y-or-n-p (concat "Terminate all " group-descrip "? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (prog1 (mapcar 'delete-process proc-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (message ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (defun br-real-add-class (lib-table-p class-name class-path &optional replace)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
710 "Add or replace class in current Environment.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 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
712 System Environment. Add class CLASS-NAME located in CLASS-PATH to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Environment. If CLASS-PATH is nil, use current buffer file as CLASS-PATH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 Optional REPLACE non-nil means replace already existing class. Does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 update children lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (or class-path (setq class-path buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (let ((par-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (paths-key class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (class class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (if replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (setq func 'hash-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 class-name (br-first-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (concat "^" (regexp-quote class-name) "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (hash-get paths-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (if lib-table-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (br-get-htable "lib-paths")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (br-get-htable "sys-paths"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 par-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (and (stringp class-path) (file-readable-p class-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (br-get-parents-from-source class-path class-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (setq func 'hash-add))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; Signal error if class-name is invalid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (if (null class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (if replace
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
737 (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
738 class (if lib-table-p "Library" "System"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 "(br-real-add-class): Attempt to add null class to %s classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if lib-table-p "Library" "System"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (let ((par-htable (br-get-htable (concat type "parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (path-htable (br-get-htable (concat type "paths"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (funcall func par-list class-name par-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (br-add-to-paths-htable class-name paths-key path-htable))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
750 (list (if lib-table-p "lib-" "sys-") ""))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (defun br-real-delete-class (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 "Delete class CLASS-NAME from current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 No error occurs if the class is undefined in the Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (require 'set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (let ((paths-key (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setq class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (br-first-match (concat "^" class-name "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (hash-get paths-key (br-get-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (if class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (progn (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (lambda (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (hash-delete class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (br-get-htable (concat type "parents")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (setq htable (br-get-htable (concat type "paths")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (if (hash-key-p paths-key htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (hash-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (set:remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (hash-get paths-key htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 paths-key htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 '("lib-" "sys-" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (hash-delete class-name (br-get-children-htable))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (defun br-real-build-children-htable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 "Build and return Environment parent to child lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (let* ((par-ht (br-get-parents-htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (htable (hash-make (hash-size par-ht)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (child))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (lambda (par-child-cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq child (cdr par-child-cns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (lambda (parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (hash-add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (cons child (hash-get parent htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 parent htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (car par-child-cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 par-ht)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (hash-map (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (lambda (children-parent-cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (hash-replace (sort (car children-parent-cns) 'string-lessp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (cdr children-parent-cns) htable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 htable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun br-real-get-children (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "Return list of child classes of CLASS-NAME listed in Environment parents htable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (delq nil (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 (cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (if (and (consp cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (br-member class-name (car cns)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (br-get-parents-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (defun br-real-build-alists (search-dirs)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
812 "Use SEARCH-DIRS to build 'br-paths-alist' and 'br-parents-alist'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (setq br-paths-alist nil br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (br-feature-tags-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (br-real-build-al search-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (setq br-paths-alist br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (br-feature-tags-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (defvar br-paths-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (defvar br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (defun br-skip-dir-p (dir-name)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
824 "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
825 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (lambda (dir-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (string-match dir-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (directory-file-name dir-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 br-skip-dir-regexps)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;;; If abbreviate-file-name is not defined, just make it return the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;;; string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (or (fboundp 'abbreviate-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (fset 'abbreviate-file-name 'identity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (defun br-real-build-al (search-dirs)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
839 "Descend SEARCH-DIRS and build 'br-paths-alist' and 'br-parents-alist'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
840 Does not initialize 'br-paths-alist' or 'br-parents-alist' to nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (let ((inhibit-local-variables nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (enable-local-variables t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (files)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
844 ;; These are used in the 'br-search-directory' function.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 classes parents paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (lambda (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (if (or (null dir) (equal dir "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (progn (setq dir (file-name-as-directory dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (br-skip-dir-p dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (setq files (if (and (file-directory-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (file-readable-p dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (directory-files dir t br-file-dir-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; Extract all class/parent names in all source files in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ;; particular directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (if files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (progn (message "Scanning %s in %s ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (or (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (br-search-directory dir files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; Call same function on all the directories below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;; this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (br-real-build-al
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (mapcar (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (if (file-directory-p f) f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 files)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 search-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (defun br-search-directory (dir files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (if (file-readable-p f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setq paths-parents-cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (let ((br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (message "Scanning %s in %s ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (or (file-name-directory f) default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (br-get-classes-from-source f nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 classes (car paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 parents (cdr paths-parents-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 br-paths-alist (if classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (cons (cons (sort classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 'string-lessp) f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 br-paths-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 br-parents-alist (if parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (append br-parents-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (message "(OO-Browser): Unreadable file: %s in %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (or (file-name-directory f) default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (sit-for 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; List of files potentially containing classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (and (string-match br-src-file-regexp f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (not (file-directory-p f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (defun br-real-build-parents-alist (paths-htable)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
914 "Build and return 'br-parents-alist' of (parent-list . class) elements built from PATHS-HTABLE.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
915 Initializes 'br-parents-alist' to nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (let ((inhibit-local-variables nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (enable-local-variables t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (br-view-file-function 'br-insert-file-contents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (setq br-parents-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (lambda (cl-dir-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (lambda (class-dir-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (let ((dir (cdr class-dir-cons)))
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 (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (setq br-parents-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (cons (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (and (stringp dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (file-exists-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (br-get-parents-from-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 dir class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 br-parents-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (car class-dir-cons)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 cl-dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 paths-htable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 br-parents-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (defun br-set-lang-env (func sym-list val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 "Use FUNC to set each element in SYM-LIST.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
944 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
945 element with the same name, otherwise set to symbol."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (let ((br) (lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (lambda (nm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (setq br (intern (concat "br-" nm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 lang (intern-soft (concat br-lang-prefix nm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (funcall func br (if val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (symbol-value lang)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (or lang 'br-undefined-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 sym-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defun br-undefined-function (&rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (error "(OO-Browser): That command is not supported for this language."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (defun br-setup-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 "Initialize appropriate function pointers for the current browser language."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (br-set-lang-env 'fset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 '("class-definition-regexp" "class-list-filter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 "get-classes-from-source" "get-parents-from-source"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 "insert-class-info" "set-case" "set-case-type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 "to-class-end" "to-comments-begin" "to-definition"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 "select-path"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 "feature-implementors" "feature-locate-p"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
970 "feature-name-to-regexp" "feature-signature-to-name"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 "feature-signature-to-regexp" "feature-tag-class"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
972 "feature-tree-command-p"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "list-categories" "list-features" "list-protocols"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 "view-friend" "view-protocol")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 nil))
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-setup-constants ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 "Initialize appropriate constant values for the current browser language."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;; Clear language-dependent hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (setq br-after-build-lib-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 br-after-build-sys-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; Set language-specific constants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (br-set-lang-env 'set '("class-def-regexp" "env-file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 "identifier" "identifier-chars"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "src-file-regexp" "narrow-view-to-class"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 "type-tag-separator")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (defvar br-lib-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 "List of directories below which library dirs and source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 A library is a stable group of classes. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (defvar br-sys-search-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 "List of directories below which system dirs and source files are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 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
999 language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (defvar br-lib-prev-search-dirs nil
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1002 "Used to check if 'br-lib-paths-htable' must be regenerated.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (defvar br-sys-prev-search-dirs nil
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1005 "Used to check if 'br-sys-paths-htable' must be regenerated.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (defun br-find-file (filename &optional other-win read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 "Edit file FILENAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 Switch to a buffer visiting file FILENAME, creating one if none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 already exists. Optional OTHER-WIN means show in other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 Optional READ-ONLY means make buffer read-only."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (interactive "FFind file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (funcall (if other-win 'switch-to-buffer-other-window 'switch-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (find-file-noselect filename))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1016 (and read-only (setq buffer-read-only t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (defun br-find-file-read-only (filename &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "Display file FILENAME read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 Switch to a buffer visiting file FILENAME, creating one if none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 already exists. Optional OTHER-WIN means show in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (interactive "FFind file read-only: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (br-find-file filename other-win t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (defvar br-edit-file-function 'br-find-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 "*Function to call to edit a class file within the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (defvar br-view-file-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (if (eq br-edit-file-function 'br-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 'br-find-file-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 br-edit-file-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 "*Function to call to view a class file within the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (defvar br-find-file-noselect-function 'find-file-noselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 "Function to call to load a browser file but not select it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 The function must return the buffer containing the file's contents.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (defvar *br-tmp-buffer* "*oobr-tmp*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 "Name of temporary buffer used by the OO-Browser for parsing source files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (defun br-insert-file-contents (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 "Insert FILENAME contents into a temporary buffer and select buffer.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1042 Does not run any find-file hooks. Marks buffer read-only to prevent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1043 any accidental editing.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1045 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
1046 files for fast loading of many files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (let ((buf (get-buffer-create *br-tmp-buffer*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (switch-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (buffer-disable-undo buf)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1050 (setq buffer-read-only nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (erase-buffer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1052 (insert-file-contents filename t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (defvar br-lang-prefix nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 "Prefix string that starts language-specific symbol names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (defvar br-children-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 "Htable whose elements are of the form: (LIST-OF-CHILD-CLASSES . CLASS-NAME).
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1059 Used to traverse class inheritance graph. 'br-build-children-htable' builds
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 this list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (defvar br-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1063 Used to traverse class inheritance graph. 'br-build-parents-htable' builds
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 this list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (defvar br-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
1068 'br-build-paths-htable' builds this list. Value is language-specific.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (defvar br-lib-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 Only classes from stable software libraries are used to build the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (defvar br-lib-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 Only classes from stable software libraries are used to build the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (defvar br-sys-parents-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 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
1083 list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (defvar br-sys-paths-htable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . DIRECTORY).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 DIRECTORY gives the location of classes found in LIST-OF-CLASS-NAMES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 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
1088 list. Value is language-specific.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defvar br-file-dir-regexp "\\`[^.~#]\\(.*[^.~#]\\)?\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 "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
1092 Others are ignored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (defvar br-src-file-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 "Regular expression matching a unique part of source file names and no others.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (defvar br-narrow-view-to-class nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 "Non-nil means narrow buffer to just the matching class definition when displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 Don't set this, use the language specific variable instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (provide 'br-lib)