-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecb-winman-support.el
319 lines (257 loc) · 13 KB
/
ecb-winman-support.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
;; ecb-winman-support.el - support of several window managers
;; Copyright (C) 2000 - 2005 Klaus Berndl,
;; Free Software Foundation, Inc.
;; Author: Klaus Berndl <[email protected]>
;; Maintainer: Klaus Berndl <[email protected]>
;; Keywords: browser, code, programming, tools, escreen, winring
;; Created: 2003
;; This program is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free Software
;; Foundation; either version 2, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
;; details.
;; You should have received a copy of the GNU General Public License along with
;; GNU Emacs; see the file COPYING. If not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;; $Id: ecb-winman-support.el,v 1.16 2009/05/15 15:19:53 berndl Exp $
;;; Commentary
;;
;; This library contains support for several window-managers so they interact
;; well with ECB. Currently the following window-managers are supported by ECB:
;; - winring.el: Written by Barry A. Warsaw <[email protected]>, get it from
;; http://www.python.org/emacs/winring
;; - escreen.el: Written by Noah Friedman <[email protected]>, get it from
;; http://www.splode.com/~friedman/software/emacs-lisp/#ui
;;
;; Note: With one of these window-managers installed and active you can run
;; applications like Gnus, VM or BBDB in the same frame as ECB! Just use
;; different window-configurations (winring.el) or escreens (escreen.el) for
;; ECB and the other applications. Especially with winring.el you can give
;; every configuration a descriptive name like "ECB" or "Gnus" ; afterwards
;; you can jump to a window-configuration by name!
;;; Installation and enabling
;;
;; This library is installed autom. with ECB. But every support must be
;; enabled explicitly:
;; - winring: Call `ecb-winman-winring-enable-support'. This *must* be done
;; *before* the first call to any winring-command, so also before calling
;; `winring-initialize'!
;; - escreen: Call `ecb-winman-escreen-enable-support'. This *must* be done
;; *before* the first call to any escreen-command, so also before calling
;; `escreen-install'!
;;
;; You can also put into your .emacs:
;; (ecb-winman-winring-enable-support) or/and
;; (ecb-winman-escreen-enable-support)
;;; Deinstallation
;;
;; Just run `ecb-winman-escreen-disable-support' rsp.
;; `ecb-winman-winring-disable-support'.
;;; Usage
;;
;; After enabling the support of one of the supported window-managers just go
;; on as described in the commentary or introduction of the respective
;; library-file(s) of the window-manager. Here is a short description:
;; - winring: Run `winring-initialize'. If ECB is active then the resulting
;; window-configuration is the ECB-window-configuration. Otherwise you can
;; create the ECB-window-configuration when you first time call
;; `winring-new-configuration' with name equal to `ecb-winman-winring-name'.
;; In general you can run all commands of the winring-library. If you jump
;; to the ECB-window-configuration then ECB will be autom. activated and if
;; you leave the ECB-window-configuration then ECB will autom. deactivated.
;; - escreen: Run `escreen-install' (deactivates ECB if currently
;; running), `escreen-create-screen', `escreen-goto-screen' etc. The latter
;; ones activate autom. ECB if creating or selecting the escreen with number
;; `ecb-escreen-number' (default = 1) and deactivate ECB autom. if leaving
;; the ECB-escreen.
;;; BUGS
;;
;; Currently not known
;; Thanks to Johann "Myrkraverk" Oskarsson <[email protected]>
;; for the first trigger for this support-library. He has suggested to
;; integrate ECB with escreen.
;;; Code
(eval-when-compile
(require 'silentcomp))
(require 'ecb-util)
(require 'ecb-common-browser)
(silentcomp-defvar escreen-current-screen-number)
(defgroup ecb-winman-support nil
"Settings for supporting several window-managers.
Currently winring and escreen are supported."
:group 'ecb
:prefix "ecb-winman-")
(defcustom ecb-winman-escreen-number 1
"*Number of the escreen which is reserved for ECB.
If you go to the escreen with this number you go always to the escreen with
activated ECB. All other escreen-numbers are escreens with deactivated ECB!"
:group 'ecb-winman-support
:group 'ecb-most-important
:type 'integer)
(defcustom ecb-winman-winring-name "ECB"
"*Name of the winring-window-configuration reserved for ECB.
If you go to the window-configuration with this name you go always to the
window-configuration with activated ECB. All other window-configuration are
configurations with deactivated ECB!"
:group 'ecb-winman-support
:group 'ecb-most-important
:type 'string)
;; support for the library escreen.el ----------------------------------------
(defecb-advice-set ecb-winman-escreen-adviced-functions
"These functions of escreen are adviced if escreen is active during ECB is
active. This advice is a permanent advice set!"
t)
(defun ecb-winman-escreen-enable-support ()
"Load the escreen-library and enable the ECB-support for it.
This does not install or activate escreen! For this you have still to call
`escreen-install'! For further documentation about escreen see the file
escreen.el!"
(interactive)
(if (locate-library "escreen")
(condition-case nil
(progn
(require 'escreen)
(ecb-enable-advices 'ecb-winman-escreen-adviced-functions)
(add-hook 'escreen-goto-screen-hook
'ecb-winman-escreen-goto-escreen-hook)
(ecb-info-message "Support for escreen enabled."))
(error
(ecb-winman-escreen-disable-support)
(ecb-error "The escreen-support can not be properly installed!")))
(ecb-error "The library escreen.el can not be found!")))
(defun ecb-winman-escreen-disable-support ()
"Disable the escreen-support of ECB."
(interactive)
(ecb-disable-advices 'ecb-winman-escreen-adviced-functions t)
(when (featurep 'escreen)
(remove-hook 'escreen-goto-screen-hook
'ecb-winman-escreen-goto-escreen-hook)))
(defun ecb-winman-escreen-goto-escreen-hook ()
"Activate ECB if we go to the escreen with number `ecb-escreen-number'."
(if (and (boundp 'ecb-minor-mode)
(not ecb-minor-mode)
(= escreen-current-screen-number
ecb-winman-escreen-number))
(let ((ecb-split-edit-window-after-start 'before-deactivation))
(ecb-activate))))
(defecb-advice escreen-save-current-screen-configuration
before
ecb-winman-escreen-adviced-functions
"escreen can only handle screen-configurations if ECB is deactivated. This
is because ECB handles its window-creation completely by itself and because it
uses dedicated windows. So we deactivate ECB before running this function."
(if (and (boundp 'ecb-minor-mode)
ecb-minor-mode
(equal ecb-frame (selected-frame)))
(let ((ecb-split-edit-window-after-start 'before-deactivation))
(ecb-deactivate))))
;; support for the library winring.el ---------------------------------------
(defecb-advice-set ecb-winman-winring-adviced-functions
"These functions of winring are adviced if winring is active during ECB is
active. This advice is a permanent advice set!"
t)
(defun ecb-winman-winring-enable-support ()
"Load the winring-library and enable the ECB-support for it.
This does not install or activate winring! For this you have still to call
`winring-initialize'! For further documentation about winring see the file
winring.el!"
(interactive)
(if (locate-library "winring")
(condition-case nil
(progn
(require 'winring)
(ecb-enable-advices 'ecb-winman-winring-adviced-functions)
(ecb-info-message "Support for winring enabled."))
(error
(ecb-winman-winring-disable-support)
(ecb-error "The winring-support can not be properly installed!")))
(ecb-error "The library winring.el can not be found!")))
(defun ecb-winman-winring-disable-support ()
"Disable the winring-support of ECB."
(interactive)
(ecb-disable-advices 'ecb-winman-winring-adviced-functions t))
(defvar ecb-winman-winring-ecb-frame nil
"Frame for which the ECB-window-configuration was set first time.")
(defecb-advice winring-set-name after ecb-winman-winring-adviced-functions
"Store frame if name is equal with `ecb-winman-winring-name' and activate
ECB if we set the name `ecb-winman-winring-name'."
;; Because this is an after advice of winring-name-of-current returns here
;; already the new name!
(when (ecb-string= (winring-name-of-current) ecb-winman-winring-name)
;; we do this only the first time
(when (null ecb-winman-winring-ecb-frame)
(setq ecb-winman-winring-ecb-frame
(or (ad-get-arg 1) (selected-frame))))
;; now we activate ECB if necessary
(when (and (boundp 'ecb-minor-mode)
(not ecb-minor-mode)
(equal (or (ad-get-arg 1)
(selected-frame)) ecb-winman-winring-ecb-frame))
(let ((ecb-split-edit-window-after-start 'before-deactivation))
(ecb-activate)))))
(defecb-advice winring-duplicate-configuration before ecb-winman-winring-adviced-functions
"Prevent the ECB-window-configuration from being duplicated."
(if (ecb-string= (winring-name-of-current) ecb-winman-winring-name)
(ecb-error "The ECB-window-configuration can not be duplicated!")))
(defecb-advice winring-restore-configuration before ecb-winman-winring-adviced-functions
"Deactivates ECB if the ECB-window-configuration is active."
(if (and (ecb-string= (winring-name-of-current) ecb-winman-winring-name)
(boundp 'ecb-minor-mode)
ecb-minor-mode)
(let ((ecb-split-edit-window-after-start 'before-deactivation))
(ecb-deactivate))))
(defecb-advice winring-save-current-configuration before ecb-winman-winring-adviced-functions
"winring can only handle window-configurations if ECB is deactivated. This
is because ECB handles its window-creation completely by itself and because it
uses dedicated windows. So we deactivate ECB before running this function."
(if (and (boundp 'ecb-minor-mode)
ecb-minor-mode
(equal ecb-frame (selected-frame)))
(let ((ecb-split-edit-window-after-start 'before-deactivation))
(ecb-deactivate))))
(defecb-advice winring-initialize after ecb-winman-winring-adviced-functions
"If ECB is active when winring is initialized then this initial
window-configuration gets always the name `ecb-winman-winring-name'."
(if (and (boundp 'ecb-minor-mode)
ecb-minor-mode
(equal ecb-frame (selected-frame)))
(winring-set-name ecb-winman-winring-name)))
;; not supported window-managing functions------------------------------------
(defecb-advice-set ecb-winman-not-supported-function-advices
"These function will be adviced so an error is reported when executed in the
ecb-frame. This advice is a permanent advice set!"
t)
(defecb-advice winner-mode before ecb-winman-not-supported-function-advices
"Prevents `winner-mode' from being activated for the ECB-frame."
(if (equal (selected-frame) ecb-frame)
(ecb-error "Can't use winner-mode functions in the ecb-frame.")))
(defecb-advice winner-redo before ecb-winman-not-supported-function-advices
"Prevents `winner-redo' from being used within the ECB-frame."
(if (equal (selected-frame) ecb-frame)
(ecb-error "Can't use winner-mode functions in the ecb-frame.")))
(defecb-advice winner-undo before ecb-winman-not-supported-function-advices
"Prevents `winner-undo' from being used within the ECB-frame."
(if (equal (selected-frame) ecb-frame)
(ecb-error "Can't use winner-mode functions in the ecb-frame.")))
(when-ecb-running-xemacs
(defecb-advice push-window-configuration before ecb-winman-not-supported-function-advices
(if (and (equal (selected-frame) ecb-frame)
(interactive-p))
(ecb-error "Can't use interactive push-window-configuration in the ecb-frame.")))
(defecb-advice pop-window-configuration before ecb-winman-not-supported-function-advices
(if (and (equal (selected-frame) ecb-frame)
(interactive-p))
(ecb-error "Can't use interactive pop-window-configuration in the ecb-frame.")))
(defecb-advice unpop-window-configuration before ecb-winman-not-supported-function-advices
(if (and (equal (selected-frame) ecb-frame)
(interactive-p))
(ecb-error "Can't use interactive unpop-window-configuration in the ecb-frame.")))
)
;; we disable all advices per default.
(ecb-disable-advices 'ecb-winman-winring-adviced-functions t)
(ecb-disable-advices 'ecb-winman-escreen-adviced-functions t)
(ecb-disable-advices 'ecb-winman-not-supported-function-advices t)
(silentcomp-provide 'ecb-winman-support)
;;; ecb-winman-support.el ends here