annotate lisp/oobr/objc-brows.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 4103f0995bd7
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: objc-brows.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Objective-C 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: c, 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; ORG: Motorola Inc.
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: 12-Dec-89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 20-Sep-95 at 14:31:42 by Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; Copyright (C) 1989-1995 Free Software Foundation, Inc.
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 'objc-browse' to invoke the Objective-C OO-Browser. Prefix arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; prompts for 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 (mapcar 'require '(br-start br br-objc-ft))
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 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Cases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; env-file = nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Use default environment, objc-env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; if objc not loaded, load it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; if objc-env-file != br-env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; switch to objc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; env-file = t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Prompt for env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; if env != objc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; load it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; else if env != br-env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; switch to env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; env-file = filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; if env != objc-env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; objc-env-file = br-env-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defun objc-browse (&optional env-file no-ui)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "Invoke the Objective-C OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 This allows browsing through Objective-C library and system class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 hierarchies. With an optional non-nil prefix argument ENV-FILE, prompt for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Environment file to use. Alternatively, a string value of ENV-FILE is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 as the Environment file name. See also the file \"br-help\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (let ((same-lang (equal br-lang-prefix objc-lang-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (load-succeeded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 same-env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (if same-lang
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Save other language Environment in memory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (if br-lang-prefix (br-env-copy nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (setq br-lang-prefix objc-lang-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 *br-save-wconfig* nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq same-env (or (equal objc-env-file env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (and (null env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (or objc-lib-search-dirs objc-sys-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; Continue browsing an Environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ((and same-env same-lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ((and same-env (not same-lang))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (objc-browse-setup) (br-env-copy t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Create default Environment file specification if needed and none
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (t (or env-file (file-exists-p objc-env-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (br-env-create objc-env-file objc-lang-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (or env-file (setq env-file objc-env-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Start browsing a new Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (objc-browse-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq load-succeeded (br-env-init env-file same-lang nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (if load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq *br-save-wconfig* nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 objc-env-file load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 objc-sys-search-dirs br-sys-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 objc-lib-search-dirs br-lib-search-dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (cond (load-succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (br-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (or no-ui (br-browse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (no-ui nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (t (message "(objc-browse): You must build the Environment to browse it.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun objc-class-list-filter (class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Return CLASS-LIST sans any protocol or class category entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Used when Environment classes are listed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (delq nil (mapcar (function (lambda (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (if (string-match "[\(\<]" class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 class-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun objc-mode-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "Load best available Objective-C major mode and set 'br-lang-mode' to the function that invokes it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (fset 'br-lang-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (cond ((or (fboundp 'objc-mode) (featurep 'objc-mode)) 'objc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ((load "objc-mode" t 'nomessage) 'objc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ((featurep 'c-mode) 'c-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ((load "cc-mode" 'missing-ok 'nomessage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if (fboundp 'objc-mode) 'objc-mode 'c-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ((load "c-mode" nil 'nomessage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (provide 'c-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; Internal functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; ************************************************************************
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 objc-browse-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "Setup language-dependent functions for OO-Browser."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (br-setup-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; Use this until an info function is implemented for the language.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (fmakunbound 'br-insert-class-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (fset 'br-store-class-info 'objc-store-class-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (objc-mode-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (br-setup-constants)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; Setup to add default classes ([category] and [protocol]) to system class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; table after building it. This must come after br-setup-constants call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; since it clears these hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if (fboundp 'add-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (add-hook 'br-after-build-sys-hook 'objc-add-default-classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq br-after-build-sys-hook '(objc-add-default-classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (provide 'objc-brows)