annotate lisp/oobr/clos-brows.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 376386a54a3c
children 131b0175ea99
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: clos-brows.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Common Lisp/CLOS source code browser.
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: lisp, 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
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 29-Jul-90
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
12 ;; LAST-MOD: 21-Feb-97 at 17:23:09 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
14 ;; Copyright (C) 1990-1995, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Use 'clos-browse' to invoke the CLOS OO-Browser. Prefix arg prompts for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; name of Environment file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (mapcar 'require '(br-start br br-clos-ft))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun clos-browse (&optional env-file no-ui)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Invoke the CLOS OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 This allows browsing through CLOS library and system class hierarchies. With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 an optional non-nil prefix argument ENV-FILE, prompt for Environment file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 to use. Alternatively, a string value of ENV-FILE is used as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Environment file name. See also the file \"br-help\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (let ((same-lang (equal br-lang-prefix clos-lang-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (load-succeeded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 same-env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (if same-lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; Save other language Environment in memory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if br-lang-prefix (br-env-copy nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq br-lang-prefix clos-lang-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 *br-save-wconfig* nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (setq same-env (or (equal clos-env-file env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (and (null env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (or clos-lib-search-dirs clos-sys-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Continue browsing an Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ((and same-env same-lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ((and same-env (not same-lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (clos-browse-setup) (br-env-copy t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; Create default Environment file specification if needed and none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (t (or env-file (file-exists-p clos-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (br-env-create clos-env-file clos-lang-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (or env-file (setq env-file clos-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Start browsing a new Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (clos-browse-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq load-succeeded (br-env-init env-file same-lang nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (if load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq *br-save-wconfig* nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 clos-env-file load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 clos-sys-search-dirs br-sys-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 clos-lib-search-dirs br-lib-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (cond (load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (br-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (or no-ui (br-browse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (no-ui nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (t (message "(clos-browse): You must build the Environment to browse it.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Don't filter Environment classes when listed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (fset 'clos-class-list-filter 'identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defun clos-class-definition-regexp (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "Return regexp to uniquely match the definition of CLASS name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (concat clos-class-name-before (regexp-quote class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 clos-class-name-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; Internal functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun clos-browse-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Setup language-dependent functions for OO-Browser."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (br-setup-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Use this until an info function is implemented for the language.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (fmakunbound 'br-insert-class-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (fset 'br-store-class-info 'clos-store-class-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (fset 'br-lang-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (cond ((featurep 'clos-mode) 'clos-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ((load "clos-mode" 'missing-ok 'nomessage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (provide 'clos-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (t 'clos-browse-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (br-setup-constants)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; Setup to add default classes to system class table after building it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; This must come after br-setup-constants call since it clears these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (fboundp 'add-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (add-hook 'br-after-build-sys-hook 'clos-add-default-classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq br-after-build-sys-hook '(clos-add-default-classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defun clos-browse-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 "Select major mode for browsing the current buffer's file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if (and (stringp buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (not (memq major-mode '(lisp-mode emacs-lisp-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (cond ((string-match "\\.el$" buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (emacs-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (t (lisp-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (provide 'clos-brows)