Initial Commit
[packages] / xemacs-packages / oo-browser / br-site.el
1 ;;!emacs
2 ;;
3 ;; FILE:         br-site.el
4 ;; SUMMARY:      Site OO-Browser per Emacs session initialization.
5 ;; USAGE:        GNU Emacs Lisp Library
6 ;; KEYWORDS:     local, oop, tools
7 ;;
8 ;; AUTHOR:       Bob Weiner
9 ;; ORG:          BeOpen.com
10 ;;
11 ;; ORIG-DATE:    18-May-90
12 ;; LAST-MOD:      9-Jun-99 at 18:05:14 by Bob Weiner
13 ;;
14 ;; Copyright (C) 1990-1995, 1997, 1998 BeOpen.com
15 ;; See the file BR-COPY for license information.
16 ;;
17 ;; This file is part of the OO-Browser.
18 ;;
19 ;; DESCRIPTION:  
20 ;; DESCRIP-END.
21
22 ;;; ************************************************************************
23 ;;; Public variables
24 ;;; ************************************************************************
25
26 (defvar smart-scroll-proportional t
27   "*Non-nil means Smart Keys should scroll relative to current line when pressed at the end of a line.
28 Action Key moves current line to top of window.  Assist Key moves current
29 line to bottom of window.  Repeated presses then scroll up or down a
30 windowful.  Nil value instead ignores current line and always scrolls up or
31 down a windowful.")
32
33 ;;; ************************************************************************
34 ;;; Public functions
35 ;;; ************************************************************************
36
37 (defun br-setup-internal ()
38   "Site customizable function to configure the OO-Browser for Emacs-based editing.
39 This must be run after \"br-init\" has been loaded."
40   (setq br-editor-cmd nil br-ed1 nil br-ed2 nil))
41
42 (defun br-setup-external ()
43   "Site customizable function to configure the OO-Browser for non-Emacs editing.
44 This must be run after \"br-init\" has been loaded."
45   (setq br-editor-cmd "xterm"
46         br-ed1 "-e" br-ed2 "vi"
47         ;; In general, users will want to view within the textual browser
48         ;; itself, even when using an external editor.
49         ;; br-viewer-cmd "xterm"
50         ;; br-vw1 "-e" br-vw2 "more"
51         ))
52
53 (defun br-setup-mouse-keys ()
54   "Binds the Action Key within OO-Browser listing buffers under XEmacs and GNU Emacs."
55   ;; Do nothing when running in batch mode.
56   (if (or noninteractive (featurep 'infodock))
57       nil
58     (cond ;; GNU Emacs 19
59      (hyperb:emacs19-p
60       (if (= hyperb:mouse-buttons 2)
61           ;; With 2 mouse buttons, we have to use the left as the Action Key.
62           ;; We move the mouse-set-point command to shift-left.
63           (progn
64             (define-key br-mode-map [S-down-mouse-1] 'mouse-drag-region)
65             (define-key br-mode-map [S-mouse-1] 'mouse-set-point)
66             (define-key br-mode-map [down-mouse-1] 'action-key-depress-emacs19)
67             (define-key br-mode-map [mouse-1] 'action-mouse-key-emacs19)
68             (define-key br-mode-map [double-mouse-1] 'action-mouse-key-emacs19)
69             (define-key br-mode-map [triple-mouse-1] 'action-mouse-key-emacs19)
70             (define-key br-mode-map [vertical-line down-mouse-1]
71               'action-key-depress-emacs19)
72             (define-key br-mode-map [vertical-line mouse-1]
73               'action-mouse-key-emacs19))
74         ;; X
75         (define-key br-mode-map [down-mouse-2]   'action-key-depress-emacs19)
76         (define-key br-mode-map [mouse-2]        'action-mouse-key-emacs19)
77         (define-key br-mode-map [double-mouse-2] 'action-mouse-key-emacs19)
78         (define-key br-mode-map [triple-mouse-2] 'action-mouse-key-emacs19)
79         (define-key br-mode-map [vertical-line down-mouse-2]
80           'action-key-depress-emacs19)
81         (define-key br-mode-map [vertical-line mouse-2]
82           'action-mouse-key-emacs19)))
83      ;;
84      ;; XEmacs
85      (hyperb:xemacs-p
86       ;; Set mouse bindings under XEmacs, even if not under a window
87       ;; system since it can have frames on ttys and windowed displays at
88       ;; the same time.
89       ;;
90       (if (= hyperb:mouse-buttons 2)
91           ;; With 2 mouse buttons, we have to use the left as the Action Key.
92           ;; We move the mouse-set-point command to shift-left.
93           (progn (define-key br-mode-map '(shift button1)
94                    (lookup-key global-map 'button1))
95                  (define-key br-mode-map '(shift button1up)
96                    (lookup-key global-map 'button1up))
97                  (define-key br-mode-map 'button1     'action-key-depress)
98                  (define-key br-mode-map 'button1up   'action-mouse-key))
99         (define-key br-mode-map 'button2     'action-key-depress)
100         (define-key br-mode-map 'button2up   'action-mouse-key))))))
101
102 (defun br-site-after-term-init ()
103   (interactive)
104   (if noninteractive
105       (br-init-autoloads)
106     (br-after-term-init)
107     (br-setup-mouse-keys))
108   ;;
109   ;;     DON'T PUT IN br-init.el
110   ;;
111   (require 'br)
112   (if noninteractive
113       nil
114     (setq c++-cpp-include-dirs '("/usr/include/")
115           c++-include-dirs 
116           (delq nil (mapcar 
117                      (function (lambda (dir) (if (file-exists-p dir) dir)))
118                      '("/usr/include/X11/" "/usr/openwin/include/X11/"))))))
119
120 ;; Execute
121 (br-site-after-term-init)
122 (if hyperb:window-system (require 'br-tree))
123
124 ;; Add global browser-related keys.
125 ;;
126 ;; Adds or replaces class entry in an Environment
127 ;   (global-set-key "\C-c^" 'br-add-class-file)
128 ;;
129 ;; Goes to and from class viewer window
130 (global-set-key "\C-c\C-v" 'br-to-from-viewer)
131 ;;
132 ;; Completes symbols using OO-Browser Environments when available.
133 (global-set-key "\M-\C-i" 'br-complete-symbol)
134
135 ;; Add mode-specific browser-related keys.
136 ;;
137 (if (locate-file "c++-browse.elc" load-path)
138     (add-hook
139      'c++-mode-hook
140      (function
141       (lambda ()
142         (define-key c++-mode-map       "\C-c\M-j" 'br-feature-edit-declaration)
143         (define-key c++-mode-map       "\C-c\M-f" 'br-find)
144         (define-key c++-mode-map       "\C-\M-i"  'br-complete-symbol)
145         (define-key c++-mode-map       "\C-c\M-w" 'br-where)
146         ;; Prevent these bindings from interfering with the global
147         ;; OO-Browser bindings.
148         (define-key c++-mode-map       "\C-c\C-o"  nil)
149         (define-key c++-mode-map       "\C-c\C-v"  nil)
150         (if (boundp 'c-mode-map)
151             (progn (define-key c-mode-map "\C-c\C-o"  nil)
152                    (define-key c-mode-map "\C-c\C-v"  nil)))))))
153
154 (if (locate-file "eif-browse.elc" load-path)
155     (add-hook
156      'eiffel-mode-hook
157      (function
158       (lambda ()
159         (define-key eiffel-mode-map    "\C-c\M-f" 'br-find)
160         (define-key eiffel-mode-map    "\C-\M-i"  'br-complete-symbol)
161         (define-key eiffel-mode-map    "\C-c\M-w" 'br-where)))))
162
163 (if (locate-file "java-brows.elc" load-path)
164     (add-hook
165      'java-mode-hook
166      (function
167       (lambda ()
168         (define-key java-mode-map      "\C-c\M-f" 'br-find)
169         (define-key java-mode-map      "\C-\M-i"  'br-complete-symbol)
170         (define-key java-mode-map      "\C-c\M-w" 'br-where)
171         (define-key java-mode-map      "\C-c\C-o"  nil)
172         (define-key java-mode-map      "\C-c\C-v"  nil)
173         (if (boundp 'c-mode-map)
174             ;; Prevent these bindings from interfering with the global
175             ;; OO-Browser bindings.
176             (progn (define-key c-mode-map "\C-c\C-o"  nil)
177                    (define-key c-mode-map "\C-c\C-v"  nil)))))))
178
179 (if (locate-file "clos-brows.elc" load-path)
180     (add-hook
181      'lisp-mode-hook
182      (function
183       (lambda ()
184         (define-key lisp-mode-map      "\C-c\M-f" 'br-find)
185         (define-key lisp-mode-map      "\C-\M-i"  'br-complete-symbol)
186         (define-key lisp-mode-map      "\C-c\M-w" 'br-where)))))
187
188 (if (locate-file "objc-brows.elc" load-path)
189     (add-hook
190      'objc-mode-hook
191      (function
192       (lambda ()
193         (define-key objc-mode-map      "\C-c\M-f" 'br-find)
194         (define-key objc-mode-map      "\C-\M-i"  'br-complete-symbol)
195         (define-key objc-mode-map      "\C-c\M-w" 'br-where)
196         (if (boundp 'c-mode-map)
197             ;; Prevent these bindings from interfering with the global
198             ;; OO-Browser bindings.
199             (progn (define-key c-mode-map "\C-c\C-o"  nil)
200                    (define-key c-mode-map "\C-c\C-v"  nil)))))))
201
202 (if (locate-file "pyth-brows.elc" load-path)
203     (add-hook
204      'python-mode-hook
205      (function
206       (lambda ()
207         (let ((keymap (if (and (boundp 'py-mode-map) (keymapp py-mode-map))
208                           py-mode-map
209                         python-mode-map)))
210           (define-key keymap    "\C-c\M-f" 'br-find)
211           (define-key keymap    "\C-\M-i"  'br-complete-symbol)
212           (define-key keymap    "\C-c\M-w" 'br-where)
213           ;; Prevent these bindings from interfering with the global
214           ;; OO-Browser bindings.
215           (define-key keymap "\C-c\C-o"  nil)
216           (define-key keymap "\C-c\C-v"  nil))))))
217
218 (if (locate-file "smt-browse.elc" load-path)
219     (add-hook
220      'smalltalk-mode-hook
221      (function
222       (lambda ()
223         (define-key smalltalk-mode-map "\C-c\M-f" 'br-find)
224         (define-key smalltalk-mode-map "\C-\M-i"  'br-complete-symbol)
225         (define-key smalltalk-mode-map "\C-c\M-w" 'br-where)))))
226
227 (provide 'br-site)