annotate lisp/oobr/python-browse.el @ 164:4e0740e5aab2

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