4 ;; SUMMARY: Common Lisp/CLOS source code browser.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: lisp, oop, tools
11 ;; ORIG-DATE: 29-Jul-90
12 ;; LAST-MOD: 10-May-01 at 12:49:43 by Bob Weiner
14 ;; Copyright (C) 1990-1995, 1997 BeOpen.com
15 ;; See the file BR-COPY for license information.
17 ;; This file is part of the OO-Browser.
21 ;; Use 'clos-browse' to invoke the CLOS OO-Browser. Prefix arg prompts for
22 ;; name of Environment file.
26 ;;; ************************************************************************
27 ;;; Other required Elisp libraries
28 ;;; ************************************************************************
30 (mapcar 'require '(br-start br br-clos-ft))
32 ;;; ************************************************************************
34 ;;; ************************************************************************
37 (defun clos-browse (&optional env-file no-ui)
38 "Invoke the CLOS OO-Browser.
39 This allows browsing through CLOS library and system class hierarchies. With
40 an optional non-nil prefix argument ENV-FILE, prompt for Environment file
41 to use. Alternatively, a string value of ENV-FILE is used as the
42 Environment file name. See also the file \"br-help\"."
44 (let ((same-lang (equal br-lang-prefix clos-lang-prefix))
49 ;; Save other language Environment in memory
50 (if br-lang-prefix (br-env-copy nil))
51 (setq br-lang-prefix clos-lang-prefix
52 *br-save-wconfig* nil))
53 ;; `same-env' non-nil means the new Env is the previous Env or the most
54 ;; recent previous Env of the same language as the new Env
55 (setq same-env (or (equal clos-env-file env-file)
57 (or clos-lib-search-dirs clos-sys-search-dirs))))
60 ;; If we just switched languages, restore the cached data for the new
62 (if same-lang nil (br-env-copy t))
63 ;; Environment may appear to be the same but its loading may have
64 ;; been interrupted, so ensure all variables are initialized properly.
65 (clos-browse-setup env-file)
66 (if (or (null br-paths-htable) (equal br-paths-htable br-empty-htable))
68 (br-env-try-load (or env-file br-env-file) br-env-file))))
70 ;; Create default Environment file specification if needed and none
73 (t (or env-file (file-exists-p clos-env-file)
74 (br-env-create clos-env-file clos-lang-prefix))
75 (or env-file (setq env-file clos-env-file))
77 ;; Start browsing a new Environment.
79 (clos-browse-setup env-file)
80 (setq load-succeeded (br-env-init env-file same-lang nil))
82 (setq *br-save-wconfig* nil
83 clos-env-file br-env-file
84 clos-env-name br-env-name
85 clos-sys-search-dirs br-sys-search-dirs
86 clos-lib-search-dirs br-lib-search-dirs))))
91 (or (and same-lang same-env) (br-refresh))))
93 (t (message "(clos-browse): You must build the Environment to browse it.")))))
95 ;; Don't filter Environment classes when listed.
96 (defalias 'clos-class-list-filter 'br-class-list-identity)
98 (defun clos-class-definition-regexp (class)
99 "Return regexp to uniquely match the definition of CLASS name."
100 (concat clos-class-name-before (regexp-quote class)
101 clos-class-name-after))
103 ;;; ************************************************************************
104 ;;; Internal functions
105 ;;; ************************************************************************
107 (defun clos-browse-setup (env-file)
108 "Setup language-dependent functions for OO-Browser."
110 (defalias 'br-lang-mode
111 (cond ((featurep 'clos-mode) 'clos-mode)
112 ((load "clos-mode" 'missing-ok 'nomessage)
113 (provide 'clos-mode))
114 (t 'clos-browse-mode)))
115 (br-setup-constants env-file)
116 ;; Setup to add default classes to system class table after building it.
117 ;; This must come after br-setup-constants call since it clears these
119 (if (fboundp 'add-hook)
120 (add-hook 'br-after-build-sys-hook 'clos-add-default-classes)
121 (setq br-after-build-sys-hook '(clos-add-default-classes))))
123 (defun clos-browse-mode ()
124 "Select major mode for browsing the current buffer's file."
126 (if (and (stringp buffer-file-name)
127 (not (memq major-mode '(lisp-mode emacs-lisp-mode))))
128 (cond ((string-match "\\.el$" buffer-file-name)
132 (provide 'clos-brows)