0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: python-browse.el
|
|
4 ;; SUMMARY: Python source code browser.
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: oop, tools, python
|
|
7 ;;
|
|
8 ;; AUTHOR: Harri Pasanen, based on Smalltalk and C++ browsers
|
|
9 ;; by Bob Weiner
|
|
10 ;; ORG: Tekla Oy
|
|
11 ;;
|
|
12 ;; ORIG-DATE: 5-Apr-96
|
|
13 ;; LAST-MOD: 12-Apr-96
|
|
14 ;;
|
|
15 ;; Copyright (C) 1990-1995 Free Software Foundation, Inc.
|
|
16 ;; See the file BR-COPY for license information.
|
|
17 ;;
|
|
18 ;; This file is part of the OO-Browser.
|
|
19 ;;
|
|
20 ;; DESCRIPTION:
|
|
21 ;;
|
|
22 ;; Use 'Python-browse' to invoke the Python OO-Browser. Prefix arg
|
|
23 ;; prompts for name of Environment file.
|
|
24 ;;
|
|
25 ;; DESCRIP-END.
|
|
26
|
|
27 ;;; ************************************************************************
|
|
28 ;;; Other required Elisp libraries
|
|
29 ;;; ************************************************************************
|
|
30
|
|
31 (mapcar 'require '(br-start br br-python-ft))
|
|
32
|
|
33 ;;; ************************************************************************
|
|
34 ;;; Public functions
|
|
35 ;;; ************************************************************************
|
|
36
|
|
37 ;;;###autoload
|
|
38 (defun python-browse (&optional env-file no-ui)
|
|
39 "Invoke the Python OO-Browser.
|
|
40 This allows browsing through Python library and system class hierarchies.
|
|
41 With an optional non-nil prefix argument ENV-FILE, prompt for Environment
|
|
42 file to use. Alternatively, a string value of ENV-FILE is used as the
|
|
43 Environment file name. See also the file \"br-help\"."
|
|
44 (interactive "P")
|
|
45 (let ((same-lang (equal br-lang-prefix python-lang-prefix))
|
|
46 (load-succeeded t)
|
|
47 same-env)
|
|
48 (if same-lang
|
|
49 nil
|
|
50 ;; Save other language Environment in memory
|
|
51 (if br-lang-prefix (br-env-copy nil))
|
|
52 (setq br-lang-prefix python-lang-prefix
|
|
53 *br-save-wconfig* nil))
|
|
54 (setq same-env (or (equal python-env-file env-file)
|
|
55 (and (null env-file)
|
|
56 (or python-lib-search-dirs python-sys-search-dirs))))
|
|
57 (cond
|
|
58 ;; Continue browsing an Environment
|
|
59 ((and same-env same-lang))
|
|
60 ((and same-env (not same-lang))
|
|
61 (python-browse-setup) (br-env-copy t))
|
|
62 ;;
|
|
63 ;; Create default Environment file specification if needed and none
|
|
64 ;; exists.
|
|
65 ;;
|
|
66 (t (or env-file (file-exists-p python-env-file)
|
|
67 (br-env-create python-env-file python-lang-prefix))
|
|
68 (or env-file (setq env-file python-env-file))
|
|
69 ;;
|
|
70 ;; Start browsing a new Environment.
|
|
71 ;;
|
|
72 (python-browse-setup)
|
|
73 (setq load-succeeded (br-env-init env-file same-lang nil))
|
|
74 (if load-succeeded
|
|
75 (setq *br-save-wconfig* nil
|
|
76 python-env-file load-succeeded
|
|
77 python-sys-search-dirs br-sys-search-dirs
|
|
78 python-lib-search-dirs br-lib-search-dirs))))
|
|
79 (cond (load-succeeded
|
|
80 (br-init)
|
|
81 (or no-ui (br-browse)))
|
|
82 (no-ui nil)
|
|
83 (t (message "(python-browse): You must build the Environment to browse it.")))))
|
|
84
|
|
85 ;; Don't filter Environment classes when listed.
|
|
86 (fset 'python-class-list-filter 'identity)
|
|
87
|
|
88
|
|
89 ;;; ************************************************************************
|
|
90 ;;; Internal functions
|
|
91 ;;; ************************************************************************
|
|
92
|
|
93 (defun python-browse-setup ()
|
|
94 "Setup language-dependent functions for OO-Browser."
|
|
95 (br-setup-functions)
|
|
96 ;; Use this until an info function is implemented for the language.
|
|
97 ;; (fmakunbound 'br-insert-class-info)
|
|
98 (fset 'br-store-class-info 'python-store-class-info)
|
|
99 (fset 'br-lang-mode
|
|
100 (cond ((featurep 'python-mode) 'python-mode)
|
|
101 ((load "python-mode" 'missing-ok 'nomessage)
|
|
102 (provide 'python-mode))
|
|
103 (t 'fundamental-mode)))
|
|
104 (br-setup-constants)
|
|
105 ;; Setup to add default classes to system class table after building it.
|
|
106 ;; This must come after br-setup-constants call since it clears these
|
|
107 ;; hooks.
|
|
108 (if (fboundp 'add-hook)
|
|
109 (add-hook 'br-after-build-sys-hook 'python-add-default-classes)
|
|
110 (setq br-after-build-sys-hook '(python-add-default-classes))))
|
|
111
|
|
112
|
|
113 (provide 'python-browse)
|