0
|
1 ;;; Window management code for VM
|
98
|
2 ;;; Copyright (C) 1989-1997 Kyle E. Jones
|
0
|
3 ;;;
|
|
4 ;;; This program is free software; you can redistribute it and/or modify
|
|
5 ;;; it under the terms of the GNU General Public License as published by
|
|
6 ;;; the Free Software Foundation; either version 1, or (at your option)
|
|
7 ;;; any later version.
|
|
8 ;;;
|
|
9 ;;; This program is distributed in the hope that it will be useful,
|
|
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 ;;; GNU General Public License for more details.
|
|
13 ;;;
|
|
14 ;;; You should have received a copy of the GNU General Public License
|
|
15 ;;; along with this program; if not, write to the Free Software
|
|
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
|
18 (provide 'vm-window)
|
|
19
|
98
|
20 (defun vm-display (buffer display commands configs
|
|
21 &optional do-not-raise)
|
0
|
22 ;; the clearinghouse VM display function.
|
|
23 ;;
|
|
24 ;; First arg BUFFER non-nil is a buffer to display or undisplay.
|
|
25 ;; nil means there is no request to display or undisplay a
|
|
26 ;; buffer.
|
|
27 ;;
|
|
28 ;; Second arg DISPLAY non-nil means to display the buffer, nil means
|
|
29 ;; to undisplay it. This function guarantees to display the
|
|
30 ;; buffer if requested. Undisplay is not guaranteed.
|
|
31 ;;
|
|
32 ;; Third arg COMMANDS is a list of symbols. this-command must
|
|
33 ;; match one of these symbols for a window configuration to be
|
|
34 ;; applied.
|
|
35 ;;
|
|
36 ;; Fourth arg CONFIGS is a list of window configurations to try.
|
|
37 ;; vm-set-window-configuration will step through the list looking
|
|
38 ;; for an existing configuration, and apply the one it finds.
|
|
39 ;;
|
|
40 ;; Display is done this way:
|
|
41 ;; 1. if the buffer is visible in an invisible frame, make that frame visible
|
|
42 ;; 2. if the buffer is already displayed, quit
|
|
43 ;; 3. if vm-display-buffer-hook in non-nil
|
|
44 ;; run the hooks
|
|
45 ;; use the selected window/frame to display the buffer
|
|
46 ;; quit
|
|
47 ;; 4. apply a window configuration
|
|
48 ;; if the buffer is displayed now, quit
|
|
49 ;; 5. call vm-display-buffer which will display the buffer.
|
|
50 ;;
|
|
51 ;; Undisplay is done this way:
|
|
52 ;; 1. if the buffer is not displayed, quit
|
|
53 ;; 2. if vm-undisplay-buffer-hook is non-nil
|
|
54 ;; run the hooks
|
|
55 ;; quit
|
|
56 ;; 3. apply a window configuration
|
|
57 ;; 4, if a window configuration was applied
|
|
58 ;; quit
|
|
59 ;; 5. call vm-undisplay-buffer which will make the buffer
|
|
60 ;; disappear from at least one window/frame.
|
|
61 ;;
|
|
62 ;; If display/undisplay is not requested, only window
|
|
63 ;; configuration is done, and only then if the value of
|
|
64 ;; this-command is found in the COMMANDS list.
|
|
65 (vm-save-buffer-excursion
|
98
|
66 (let* ((w (and buffer (vm-get-buffer-window buffer)))
|
|
67 (wf (and w (vm-window-frame w))))
|
0
|
68 (and buffer (set-buffer buffer))
|
98
|
69 (if (and w display (not do-not-raise))
|
|
70 (vm-raise-frame wf))
|
|
71 (if (and w display (not (eq (vm-selected-frame) wf)))
|
|
72 (vm-select-frame wf))
|
0
|
73 (cond ((and buffer display)
|
|
74 (if (and vm-display-buffer-hook
|
|
75 (null (vm-get-visible-buffer-window buffer)))
|
|
76 (progn (run-hooks 'vm-display-buffer-hook)
|
155
|
77 (switch-to-buffer buffer))
|
0
|
78 (if (not (and (memq this-command commands)
|
|
79 (apply 'vm-set-window-configuration configs)
|
|
80 (vm-get-visible-buffer-window buffer)))
|
|
81 (vm-display-buffer buffer))))
|
|
82 ((and buffer (not display))
|
|
83 (if (and vm-undisplay-buffer-hook
|
|
84 (vm-get-visible-buffer-window buffer))
|
108
|
85 (progn (set-buffer buffer)
|
155
|
86 (run-hooks 'vm-undisplay-buffer-hook))
|
0
|
87 (if (not (and (memq this-command commands)
|
|
88 (apply 'vm-set-window-configuration configs)))
|
|
89 (vm-undisplay-buffer buffer))))
|
|
90 ((memq this-command commands)
|
|
91 (apply 'vm-set-window-configuration configs))))))
|
|
92
|
|
93 (defun vm-display-buffer (buffer)
|
|
94 (let ((pop-up-windows (eq vm-mutable-windows t))
|
155
|
95 (pop-up-frames (and pop-up-frames vm-mutable-frames)))
|
0
|
96 (if (or pop-up-frames
|
|
97 (and (eq vm-mutable-windows t)
|
|
98 (symbolp
|
|
99 (vm-buffer-to-label
|
|
100 (window-buffer
|
|
101 (selected-window))))))
|
|
102 (select-window (display-buffer buffer))
|
|
103 (switch-to-buffer buffer))))
|
|
104
|
|
105 (defun vm-undisplay-buffer (buffer)
|
|
106 (vm-save-buffer-excursion
|
175
|
107 (let ((vm-mutable-frames (and vm-mutable-frames pop-up-frames)))
|
|
108 (vm-maybe-delete-windows-or-frames-on buffer))
|
|
109 (let (w)
|
|
110 (while (setq w (vm-get-buffer-window buffer))
|
|
111 (set-window-buffer w (other-buffer buffer))))))
|
0
|
112
|
|
113 (defun vm-load-window-configurations (file)
|
|
114 (save-excursion
|
|
115 (let ((work-buffer nil))
|
|
116 (unwind-protect
|
|
117 (progn
|
|
118 (set-buffer (setq work-buffer (get-buffer-create "*vm-wconfig*")))
|
|
119 (erase-buffer)
|
|
120 (setq vm-window-configurations
|
|
121 (condition-case ()
|
|
122 (progn
|
|
123 (insert-file-contents file)
|
|
124 (read (current-buffer)))
|
|
125 (error nil))))
|
|
126 (and work-buffer (kill-buffer work-buffer))))))
|
|
127
|
|
128 (defun vm-store-window-configurations (file)
|
|
129 (save-excursion
|
|
130 (let ((work-buffer nil))
|
|
131 (unwind-protect
|
|
132 (progn
|
|
133 (set-buffer (setq work-buffer (get-buffer-create "*vm-wconfig*")))
|
100
|
134 ;; for XEmacs/MULE
|
120
|
135 (and vm-xemacs-mule-p
|
140
|
136 (set-buffer-file-coding-system 'no-conversion))
|
0
|
137 (erase-buffer)
|
|
138 (print vm-window-configurations (current-buffer))
|
|
139 (write-region (point-min) (point-max) file nil 0))
|
|
140 (and work-buffer (kill-buffer work-buffer))))))
|
|
141
|
|
142 (defun vm-set-window-configuration (&rest tags)
|
|
143 (catch 'done
|
|
144 (if (not vm-mutable-windows)
|
|
145 (throw 'done nil))
|
|
146 (let ((nonexistent " *vm-nonexistent*")
|
|
147 (nonexistent-summary " *vm-nonexistent-summary*")
|
|
148 (selected-frame (vm-selected-frame))
|
|
149 summary message composition edit config)
|
|
150 (while (and tags (null config))
|
|
151 (setq config (assq (car tags) vm-window-configurations)
|
|
152 tags (cdr tags)))
|
|
153 (or config (setq config (assq 'default vm-window-configurations)))
|
|
154 (or config (throw 'done nil))
|
|
155 (setq config (vm-copy config))
|
|
156 (setq composition (vm-find-composition-buffer t))
|
|
157 (cond ((eq major-mode 'vm-summary-mode)
|
|
158 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
159 (throw 'done nil)
|
|
160 (setq summary (current-buffer))
|
|
161 (setq message vm-mail-buffer)))
|
|
162 ((eq major-mode 'vm-mode)
|
|
163 (setq message (current-buffer)))
|
98
|
164 ((eq major-mode 'vm-presentation-mode)
|
|
165 (setq message vm-mail-buffer))
|
0
|
166 ((eq major-mode 'vm-virtual-mode)
|
|
167 (setq message (current-buffer)))
|
|
168 ((eq major-mode 'mail-mode)
|
|
169 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
170 (throw 'done nil)
|
98
|
171 (setq message vm-mail-buffer
|
|
172 ;; assume that the proximity implies affinity
|
|
173 composition (current-buffer))))
|
0
|
174 ((eq vm-system-state 'editing)
|
|
175 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
176 (throw 'done nil)
|
|
177 (setq edit (current-buffer))
|
|
178 (setq message vm-mail-buffer)))
|
|
179 ;; not in a VM related buffer, bail...
|
|
180 (t (throw 'done nil)))
|
|
181 (set-buffer message)
|
98
|
182 (vm-check-for-killed-presentation)
|
|
183 (if vm-presentation-buffer
|
|
184 (setq message vm-presentation-buffer))
|
0
|
185 (vm-check-for-killed-summary)
|
|
186 (or summary (setq summary (or vm-summary-buffer nonexistent-summary)))
|
|
187 (or composition (setq composition nonexistent))
|
|
188 (or edit (setq edit nonexistent))
|
|
189 (tapestry-replace-tapestry-element (nth 1 config) 'buffer-name
|
|
190 (function
|
|
191 (lambda (x)
|
|
192 (if (symbolp x)
|
|
193 (symbol-value x)
|
|
194 x ))))
|
|
195 (set-tapestry (nth 1 config) 1)
|
|
196 (and (get-buffer nonexistent)
|
155
|
197 (vm-maybe-delete-windows-or-frames-on nonexistent))
|
0
|
198 (if (and (vm-get-buffer-window nonexistent-summary)
|
|
199 (not (vm-get-buffer-window message)))
|
|
200 ;; user asked for summary to be displayed but doesn't
|
|
201 ;; have one, nor is the folder buffer displayed. Help
|
|
202 ;; the user not to lose here.
|
|
203 (vm-replace-buffer-in-windows nonexistent-summary message)
|
|
204 (and (get-buffer nonexistent-summary)
|
175
|
205 (vm-maybe-delete-windows-or-frames-on nonexistent-summary)))
|
|
206 config )))
|
70
|
207
|
0
|
208 (defun vm-save-window-configuration (tag)
|
|
209 "Name and save the current window configuration.
|
|
210 With this command you associate the current window setup with an
|
|
211 action. Each time you perform this action VM will duplicate this
|
|
212 window setup.
|
|
213
|
|
214 Nearly every VM command can have a window configuration
|
|
215 associated with it. VM also allows some category configurations,
|
|
216 `startup', `reading-message', `composing-message', `editing-message',
|
|
217 `marking-message' and `searching-message' for the commands that
|
|
218 do these things. There is also a `default' configuration that VM
|
|
219 will use if no other configuration is applicable. Command
|
|
220 specific configurations are searched for first, then the category
|
|
221 configurations and then the default configuration. The first
|
|
222 configuration found is the one that is applied.
|
|
223
|
|
224 The value of vm-mutable-windows must be non-nil for VM to use
|
155
|
225 window configurations."
|
0
|
226 (interactive
|
|
227 (let ((last-command last-command)
|
|
228 (this-command this-command))
|
|
229 (if (null vm-window-configuration-file)
|
|
230 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
231 (list
|
|
232 (intern
|
|
233 (completing-read "Name this window configuration: "
|
|
234 vm-supported-window-configurations
|
|
235 'identity t)))))
|
|
236 (if (null vm-window-configuration-file)
|
|
237 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
238 (let (map p)
|
|
239 (setq map (tapestry (list (vm-selected-frame))))
|
|
240 ;; set frame map to nil since we don't use it. this prevents
|
|
241 ;; cursor objects and any other objects that have an
|
|
242 ;; "unreadable" read syntax appearing in the window
|
|
243 ;; configuration file by way of frame-parameters.
|
|
244 (setcar map nil)
|
|
245 (tapestry-replace-tapestry-element map 'buffer-name 'vm-buffer-to-label)
|
|
246 (tapestry-nullify-tapestry-elements map t nil t t t nil)
|
|
247 (setq p (assq tag vm-window-configurations))
|
|
248 (if p
|
|
249 (setcar (cdr p) map)
|
|
250 (setq vm-window-configurations
|
|
251 (cons (list tag map) vm-window-configurations)))
|
|
252 (vm-store-window-configurations vm-window-configuration-file)
|
|
253 (message "%s configuration recorded" tag)))
|
|
254
|
|
255 (defun vm-buffer-to-label (buf)
|
|
256 (save-excursion
|
|
257 (set-buffer buf)
|
|
258 (cond ((eq major-mode 'vm-summary-mode)
|
|
259 'summary)
|
|
260 ((eq major-mode 'mail-mode)
|
|
261 'composition)
|
|
262 ((eq major-mode 'vm-mode)
|
|
263 'message)
|
|
264 ((eq major-mode 'vm-virtual-mode)
|
|
265 'message)
|
|
266 ((eq vm-system-state 'editing)
|
|
267 'edit)
|
|
268 (t buf))))
|
|
269
|
|
270 (defun vm-delete-window-configuration (tag)
|
|
271 "Delete the configuration saved for a particular action.
|
|
272 This action will no longer have an associated window configuration.
|
|
273 The action will be read from the minibuffer."
|
|
274 (interactive
|
|
275 (let ((last-command last-command)
|
|
276 (this-command this-command))
|
|
277 (if (null vm-window-configuration-file)
|
|
278 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
279 (list
|
|
280 (intern
|
|
281 (completing-read "Delete window configuration: "
|
|
282 (mapcar (function
|
|
283 (lambda (x)
|
|
284 (list (symbol-name (car x)))))
|
|
285 vm-window-configurations)
|
|
286 'identity t)))))
|
|
287 (if (null vm-window-configuration-file)
|
|
288 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
289 (let (p)
|
|
290 (setq p (assq tag vm-window-configurations))
|
|
291 (if p
|
|
292 (if (eq p (car vm-window-configurations))
|
|
293 (setq vm-window-configurations (cdr vm-window-configurations))
|
|
294 (setq vm-window-configurations (delq p vm-window-configurations)))
|
|
295 (error "No window configuration set for %s" tag)))
|
|
296 (vm-store-window-configurations vm-window-configuration-file)
|
|
297 (message "%s configuration deleted" tag))
|
|
298
|
|
299 (defun vm-apply-window-configuration (tag)
|
|
300 "Change the current window configuration to be one
|
|
301 associated with a particular action. The action will be read
|
|
302 from the minibuffer."
|
|
303 (interactive
|
|
304 (let ((last-command last-command)
|
|
305 (this-command this-command))
|
|
306 (list
|
|
307 (intern
|
|
308 (completing-read "Apply window configuration: "
|
|
309 (mapcar (function
|
|
310 (lambda (x)
|
|
311 (list (symbol-name (car x)))))
|
|
312 vm-window-configurations)
|
|
313 'identity t)))))
|
|
314 (vm-set-window-configuration tag))
|
|
315
|
|
316 (defun vm-window-help ()
|
|
317 (interactive)
|
|
318 (message "WS = save configuration, WD = delete configuration, WW = apply configuration"))
|
|
319
|
|
320 (defun vm-iconify-frame ()
|
|
321 "Iconify the current frame.
|
|
322 Run the hooks in vm-iconify-frame-hook before doing so."
|
|
323 (interactive)
|
|
324 (vm-check-for-killed-summary)
|
|
325 (vm-select-folder-buffer)
|
|
326 (if (vm-multiple-frames-possible-p)
|
|
327 (progn
|
|
328 (run-hooks 'vm-iconify-frame-hook)
|
|
329 (vm-iconify-frame-xxx))))
|
|
330
|
|
331 (defun vm-window-loop (action obj-1 &optional obj-2)
|
|
332 (let ((delete-me nil)
|
|
333 (done nil)
|
155
|
334 (all-frames (if vm-search-other-frames t nil))
|
0
|
335 start w)
|
|
336 (setq start (next-window (selected-window) 'nomini all-frames)
|
|
337 w start)
|
|
338 (and obj-1 (setq obj-1 (get-buffer obj-1)))
|
|
339 (while (not done)
|
|
340 (if (and delete-me (not (eq delete-me (next-window delete-me 'nomini))))
|
|
341 (progn
|
|
342 (delete-window delete-me)
|
|
343 (if (eq delete-me start)
|
|
344 (setq start nil))
|
|
345 (setq delete-me nil)))
|
|
346 (cond ((and (eq action 'delete) (eq obj-1 (window-buffer w)))
|
|
347 ;; a deleted window has no next window, so we
|
|
348 ;; defer the deletion until after we've moved
|
|
349 ;; to the next window.
|
|
350 (setq delete-me w))
|
|
351 ((and (eq action 'replace) (eq obj-1 (window-buffer w)))
|
|
352 (set-window-buffer w obj-2)))
|
|
353 (setq done (eq start
|
|
354 (setq w
|
|
355 (condition-case nil
|
|
356 (next-window w 'nomini all-frames)
|
|
357 (wrong-number-of-arguments
|
|
358 (next-window w 'nomini))))))
|
|
359 (if (null start)
|
|
360 (setq start w)))
|
|
361 (if (and delete-me (not (eq delete-me (next-window delete-me 'nomini))))
|
|
362 (delete-window delete-me))))
|
|
363
|
|
364 (defun vm-frame-loop (action obj-1)
|
|
365 (if (fboundp 'vm-next-frame)
|
|
366 (let ((start (vm-next-frame (vm-selected-frame)))
|
|
367 (delete-me nil)
|
|
368 (done nil)
|
|
369 f)
|
|
370 (setq f start)
|
|
371 (and obj-1 (setq obj-1 (get-buffer obj-1)))
|
|
372 (while (not done)
|
|
373 (if delete-me
|
|
374 (progn
|
|
375 (condition-case nil
|
|
376 (progn
|
98
|
377 (if (vm-created-this-frame-p delete-me)
|
|
378 (vm-delete-frame delete-me))
|
0
|
379 (if (eq delete-me start)
|
|
380 (setq start nil)))
|
|
381 (error nil))
|
|
382 (setq delete-me nil)))
|
|
383 (cond ((and (eq action 'delete)
|
|
384 ;; one-window-p doesn't take a frame argument
|
|
385 (eq (next-window (vm-frame-selected-window f) 'nomini)
|
|
386 (previous-window (vm-frame-selected-window f)
|
|
387 'nomini))
|
|
388 ;; the next-window call is to avoid looking
|
|
389 ;; at the minibuffer window
|
|
390 (eq obj-1 (window-buffer
|
|
391 (next-window
|
|
392 (vm-frame-selected-window f)
|
|
393 'nomini))))
|
|
394 ;; a deleted frame has no next frame, so we
|
|
395 ;; defer the deletion until after we've moved
|
|
396 ;; to the next frame.
|
|
397 (setq delete-me f))
|
|
398 ((eq action 'bury)
|
|
399 (bury-buffer obj-1)))
|
|
400 (setq done (eq start (setq f (vm-next-frame f))))
|
|
401 (if (null start)
|
|
402 (setq start f)))
|
|
403 (if delete-me
|
|
404 (progn
|
|
405 (vm-error-free-call 'vm-delete-frame delete-me)
|
|
406 (setq delete-me nil))))))
|
|
407
|
155
|
408 (defun vm-maybe-delete-windows-or-frames-on (buffer)
|
0
|
409 (and (eq vm-mutable-windows t) (vm-window-loop 'delete buffer))
|
|
410 (and vm-mutable-frames (vm-frame-loop 'delete buffer)))
|
|
411
|
|
412 (defun vm-replace-buffer-in-windows (old new)
|
|
413 (vm-window-loop 'replace old new))
|
|
414
|
|
415 (defun vm-bury-buffer (&optional buffer)
|
|
416 (or buffer (setq buffer (current-buffer)))
|
120
|
417 (if vm-xemacs-p
|
0
|
418 (if (vm-multiple-frames-possible-p)
|
|
419 (vm-frame-loop 'bury buffer)
|
|
420 (bury-buffer buffer))
|
|
421 (bury-buffer buffer)))
|
|
422
|
|
423 (defun vm-unbury-buffer (buffer)
|
|
424 (save-excursion
|
|
425 (save-window-excursion
|
|
426 (switch-to-buffer buffer))))
|
|
427
|
|
428 (defun vm-get-buffer-window (buffer)
|
|
429 (condition-case nil
|
|
430 (or (get-buffer-window buffer nil nil)
|
|
431 (and vm-search-other-frames
|
|
432 (get-buffer-window buffer t t)))
|
|
433 (wrong-number-of-arguments
|
|
434 (condition-case nil
|
|
435 (or (get-buffer-window buffer nil)
|
|
436 (and vm-search-other-frames
|
|
437 (get-buffer-window buffer t)))
|
|
438 (wrong-number-of-arguments
|
|
439 (get-buffer-window buffer))))))
|
|
440
|
|
441 (defun vm-get-visible-buffer-window (buffer)
|
|
442 (condition-case nil
|
|
443 (or (get-buffer-window buffer nil nil)
|
|
444 (and vm-search-other-frames
|
|
445 (get-buffer-window buffer t nil)))
|
|
446 (wrong-number-of-arguments
|
|
447 (condition-case nil
|
|
448 (or (get-buffer-window buffer nil)
|
|
449 (and vm-search-other-frames
|
|
450 (get-buffer-window buffer 'visible)))
|
|
451 (wrong-number-of-arguments
|
|
452 (get-buffer-window buffer))))))
|
|
453
|
|
454 (defun vm-set-hooks-for-frame-deletion ()
|
|
455 (make-local-variable 'vm-undisplay-buffer-hook)
|
|
456 (add-hook 'vm-undisplay-buffer-hook 'vm-delete-buffer-frame)
|
|
457 (add-hook 'kill-buffer-hook 'vm-delete-buffer-frame))
|
|
458
|
98
|
459 (defun vm-created-this-frame-p (&optional frame)
|
|
460 (memq (or frame (vm-selected-frame)) vm-frame-list))
|
|
461
|
0
|
462 (defun vm-delete-buffer-frame ()
|
98
|
463 ;; kludge. we only want to this to run on VM related buffers
|
|
464 ;; but this function is generally on a global hook. Check for
|
|
465 ;; vm-undisplay-buffer-hook set; this is a good sign that this
|
|
466 ;; is a VM buffer.
|
|
467 (if vm-undisplay-buffer-hook
|
|
468 (save-excursion
|
|
469 ;; run once only per buffer.
|
|
470 (remove-hook 'vm-undisplay-buffer-hook 'vm-delete-buffer-frame)
|
|
471 (let* ((w (vm-get-visible-buffer-window (current-buffer)))
|
|
472 (b (current-buffer))
|
|
473 (wf (and w (vm-window-frame w))))
|
|
474 (and w (eq (vm-selected-frame) wf) (vm-created-this-frame-p wf)
|
|
475 (vm-error-free-call 'vm-delete-frame wf))
|
|
476 (and w (let ((vm-mutable-frames t))
|
155
|
477 (vm-maybe-delete-windows-or-frames-on b)))))))
|
98
|
478
|
|
479 (defun vm-register-frame (frame)
|
|
480 (setq vm-frame-list (cons frame vm-frame-list)))
|
0
|
481
|
|
482 (defun vm-goto-new-frame (&rest types)
|
|
483 (let ((params nil))
|
|
484 (while (and types (null params))
|
|
485 (setq params (car (cdr (assq (car types) vm-frame-parameter-alist)))
|
|
486 types (cdr types)))
|
|
487 ;; these functions might be defined in an Emacs that isn't
|
|
488 ;; running under a window system, but VM always checks for
|
|
489 ;; multi-frame support before calling this function.
|
|
490 (cond ((fboundp 'make-frame)
|
|
491 (select-frame (make-frame params)))
|
|
492 ((fboundp 'make-screen)
|
|
493 (select-screen (make-screen params)))
|
|
494 ((fboundp 'new-screen)
|
|
495 (select-screen (new-screen params))))
|
98
|
496 (vm-register-frame (vm-selected-frame))
|
0
|
497 (and vm-warp-mouse-to-new-frame
|
|
498 (vm-warp-mouse-to-frame-maybe (vm-selected-frame)))))
|
|
499
|
98
|
500 (defun vm-goto-new-summary-frame-maybe ()
|
155
|
501 (if (and vm-mutable-frames vm-frame-per-summary
|
|
502 (vm-multiple-frames-possible-p))
|
98
|
503 (let ((w (vm-get-buffer-window vm-summary-buffer)))
|
|
504 (if (null w)
|
|
505 (progn
|
|
506 (vm-goto-new-frame 'summary)
|
|
507 (vm-set-hooks-for-frame-deletion))
|
|
508 (save-excursion
|
|
509 (select-window w)
|
|
510 (and vm-warp-mouse-to-new-frame
|
|
511 (vm-warp-mouse-to-frame-maybe (vm-window-frame w))))))))
|
|
512
|
|
513 (defun vm-goto-new-folder-frame-maybe (&rest types)
|
155
|
514 (if (and vm-mutable-frames vm-frame-per-folder
|
|
515 (vm-multiple-frames-possible-p))
|
98
|
516 (let ((w (or (vm-get-buffer-window (current-buffer))
|
|
517 ;; summary == folder for the purpose
|
|
518 ;; of frame reuse.
|
|
519 (and vm-summary-buffer
|
|
520 (vm-get-buffer-window vm-summary-buffer))
|
|
521 ;; presentation == folder for the purpose
|
|
522 ;; of frame reuse.
|
|
523 (and vm-presentation-buffer
|
|
524 (vm-get-buffer-window vm-presentation-buffer)))))
|
|
525 (if (null w)
|
|
526 (progn
|
|
527 (apply 'vm-goto-new-frame types)
|
|
528 (vm-set-hooks-for-frame-deletion))
|
|
529 (save-excursion
|
|
530 (select-window w)
|
|
531 (and vm-warp-mouse-to-new-frame
|
|
532 (vm-warp-mouse-to-frame-maybe (vm-window-frame w))))))))
|
|
533
|
0
|
534 (defun vm-warp-mouse-to-frame-maybe (&optional frame)
|
|
535 (or frame (setq frame (vm-selected-frame)))
|
155
|
536 (if (vm-mouse-support-possible-here-p)
|
0
|
537 (cond ((vm-mouse-xemacs-mouse-p)
|
|
538 (cond ((fboundp 'mouse-position);; XEmacs 19.12
|
|
539 (let ((mp (mouse-position)))
|
|
540 (if (and (car mp)
|
|
541 (eq (window-frame (car mp)) (selected-frame)))
|
|
542 nil
|
|
543 (set-mouse-position (frame-highest-window frame)
|
|
544 (/ (frame-width frame) 2)
|
|
545 (/ (frame-height frame) 2)))))
|
|
546 (t ;; XEmacs 19.11
|
|
547 ;; use (apply 'screen-...) instead of
|
|
548 ;; (screen-...) to avoid stimulating a
|
|
549 ;; byte-compiler bug in Emacs 19.29 that
|
|
550 ;; happens when it encounters 'obsolete'
|
|
551 ;; functions. puke, puke, puke.
|
|
552 (let ((mp (read-mouse-position frame)))
|
|
553 (if (and (>= (car mp) 0)
|
|
554 (<= (car mp) (apply 'screen-width frame))
|
|
555 (>= (cdr mp) 0)
|
|
556 (<= (cdr mp) (apply 'screen-height frame)))
|
|
557 nil
|
|
558 (set-mouse-position frame
|
|
559 (/ (apply 'screen-width frame) 2)
|
|
560 (/ (apply 'screen-height frame) 2)))))))
|
|
561 ((vm-fsfemacs-19-p)
|
|
562 (let ((mp (mouse-position)))
|
|
563 (if (and (eq (car mp) frame)
|
|
564 ;; nil coordinates mean that the mouse
|
|
565 ;; pointer isn't really within the frame
|
|
566 (car (cdr mp)))
|
|
567 nil
|
|
568 (set-mouse-position frame
|
|
569 (/ (frame-width frame) 2)
|
|
570 (/ (frame-height frame) 2))
|
|
571 ;; doc for set-mouse-position says to do this
|
|
572 (unfocus-frame)))))))
|
|
573
|
|
574 (fset 'vm-selected-frame
|
|
575 (symbol-function
|
|
576 (cond ((fboundp 'selected-frame) 'selected-frame)
|
|
577 ((fboundp 'selected-screen) 'selected-screen)
|
|
578 (t 'ignore))))
|
|
579
|
|
580 (fset 'vm-delete-frame
|
|
581 (symbol-function
|
|
582 (cond ((fboundp 'delete-frame) 'delete-frame)
|
|
583 ((fboundp 'delete-screen) 'delete-screen)
|
|
584 (t 'ignore))))
|
|
585
|
|
586 ;; xxx because vm-iconify-frame is a command
|
|
587 (defun vm-iconify-frame-xxx (&optional frame)
|
|
588 (cond ((fboundp 'iconify-frame)
|
|
589 (iconify-frame frame))
|
|
590 ((fboundp 'iconify-screen)
|
|
591 (iconify-screen (or frame (selected-screen))))))
|
|
592
|
|
593 (fset 'vm-raise-frame
|
|
594 (symbol-function
|
|
595 (cond ((fboundp 'raise-frame) 'raise-frame)
|
|
596 ((fboundp 'raise-screen) 'raise-screen)
|
|
597 (t 'ignore))))
|
|
598
|
|
599 (fset 'vm-frame-visible-p
|
|
600 (symbol-function
|
|
601 (cond ((fboundp 'frame-visible-p) 'frame-visible-p)
|
|
602 ((fboundp 'screen-visible-p) 'screen-visible-p)
|
|
603 (t 'ignore))))
|
|
604
|
98
|
605 (if (fboundp 'frame-iconified-p)
|
|
606 (fset 'vm-frame-iconified-p 'frame-iconified-p)
|
|
607 (defun vm-frame-iconified-p (&optional frame)
|
|
608 (eq (vm-frame-visible-p frame) 'icon)))
|
|
609
|
|
610 ;; frame-totally-visible-p is broken under XEmacs 19.14 and is
|
|
611 ;; absent under Emacs 19.34. So vm-frame-per-summary won't work
|
|
612 ;; quite right under these Emacs versions. XEmacs 19.15 should
|
|
613 ;; have a working version of this function.
|
120
|
614 ;; 2 April 1997, frame-totally-visible-p apparently still broken
|
|
615 ;; under 19.15. I give up for now.
|
118
|
616 ;;(if (and (fboundp 'frame-totally-visible-p)
|
120
|
617 ;; vm-xemacs-p
|
118
|
618 ;; (or (>= emacs-major-version 20)
|
|
619 ;; (>= emacs-minor-version 15)))
|
|
620 ;; (fset 'vm-frame-totally-visible-p 'frame-totally-visible-p)
|
|
621 ;; (fset 'vm-frame-totally-visible-p 'vm-frame-visible-p))
|
|
622 (fset 'vm-frame-totally-visible-p 'vm-frame-visible-p)
|
98
|
623
|
0
|
624 (fset 'vm-window-frame
|
|
625 (symbol-function
|
|
626 (cond ((fboundp 'window-frame) 'window-frame)
|
|
627 ((fboundp 'window-screen) 'window-screen)
|
|
628 (t 'ignore))))
|
|
629
|
|
630 (cond ((fboundp 'next-frame)
|
|
631 (fset 'vm-next-frame (symbol-function 'next-frame))
|
|
632 (fset 'vm-select-frame (symbol-function 'select-frame))
|
|
633 (fset 'vm-frame-selected-window
|
|
634 (symbol-function 'frame-selected-window)))
|
|
635 ((fboundp 'next-screen)
|
|
636 (fset 'vm-next-frame (symbol-function 'next-screen))
|
|
637 (fset 'vm-select-frame (symbol-function 'select-screen))
|
|
638 (fset 'vm-frame-selected-window
|
|
639 (if (fboundp 'epoch::selected-window)
|
|
640 (symbol-function 'epoch::selected-window)
|
|
641 (symbol-function 'screen-selected-window))))
|
|
642 (t
|
|
643 ;; it is useful for this to be a no-op, but don't bind the
|
|
644 ;; others.
|
|
645 (fset 'vm-select-frame 'ignore)))
|