annotate lisp/vm/vm-window.el @ 110:fe104dbd9147 r20-1b7

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