Mercurial > emacs
annotate lisp/gnus/gnus-win.el @ 34178:0ee954140c53
Add index files and dvi/pdf/...
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 04 Dec 2000 16:14:34 +0000 |
parents | dc1ebf25e048 |
children | 57a15e35e75b |
rev | line source |
---|---|
17493 | 1 ;;; gnus-win.el --- window configuration functions for Gnus |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
17493 | 4 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 6 ;; Keywords: news |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 | |
33 (defgroup gnus-windows nil | |
34 "Window configuration." | |
35 :group 'gnus) | |
36 | |
37 (defcustom gnus-use-full-window t | |
38 "*If non-nil, use the entire Emacs screen." | |
39 :group 'gnus-windows | |
40 :type 'boolean) | |
41 | |
42 (defvar gnus-window-configuration nil | |
43 "Obsolete variable. See `gnus-buffer-configuration'.") | |
44 | |
45 (defcustom gnus-window-min-width 2 | |
46 "*Minimum width of Gnus buffers." | |
47 :group 'gnus-windows | |
48 :type 'integer) | |
49 | |
50 (defcustom gnus-window-min-height 1 | |
51 "*Minimum height of Gnus buffers." | |
52 :group 'gnus-windows | |
53 :type 'integer) | |
54 | |
55 (defcustom gnus-always-force-window-configuration nil | |
56 "*If non-nil, always force the Gnus window configurations." | |
57 :group 'gnus-windows | |
58 :type 'boolean) | |
59 | |
60 (defvar gnus-buffer-configuration | |
61 '((group | |
62 (vertical 1.0 | |
63 (group 1.0 point) | |
64 (if gnus-carpal '(group-carpal 4)))) | |
65 (summary | |
66 (vertical 1.0 | |
67 (summary 1.0 point) | |
68 (if gnus-carpal '(summary-carpal 4)))) | |
69 (article | |
70 (cond | |
71 ((and gnus-use-picons | |
72 (eq gnus-picons-display-where 'picons)) | |
73 '(frame 1.0 | |
74 (vertical 1.0 | |
75 (summary 0.25 point) | |
76 (if gnus-carpal '(summary-carpal 4)) | |
77 (article 1.0)) | |
78 (vertical ((height . 5) (width . 15) | |
79 (user-position . t) | |
80 (left . -1) (top . 1)) | |
81 (picons 1.0)))) | |
82 (gnus-use-trees | |
83 '(vertical 1.0 | |
84 (summary 0.25 point) | |
85 (tree 0.25) | |
86 (article 1.0))) | |
87 (t | |
88 '(vertical 1.0 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
89 (summary 0.25 point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
90 (if gnus-carpal '(summary-carpal 4)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
91 (article 1.0))))) |
17493 | 92 (server |
93 (vertical 1.0 | |
94 (server 1.0 point) | |
95 (if gnus-carpal '(server-carpal 2)))) | |
96 (browse | |
97 (vertical 1.0 | |
98 (browse 1.0 point) | |
99 (if gnus-carpal '(browse-carpal 2)))) | |
100 (message | |
101 (vertical 1.0 | |
102 (message 1.0 point))) | |
103 (pick | |
104 (vertical 1.0 | |
105 (article 1.0 point))) | |
106 (info | |
107 (vertical 1.0 | |
108 (info 1.0 point))) | |
109 (summary-faq | |
110 (vertical 1.0 | |
111 (summary 0.25) | |
112 (faq 1.0 point))) | |
113 (edit-article | |
114 (vertical 1.0 | |
115 (article 1.0 point))) | |
116 (edit-form | |
117 (vertical 1.0 | |
118 (group 0.5) | |
119 (edit-form 1.0 point))) | |
120 (edit-score | |
121 (vertical 1.0 | |
122 (summary 0.25) | |
123 (edit-score 1.0 point))) | |
124 (post | |
125 (vertical 1.0 | |
126 (post 1.0 point))) | |
127 (reply | |
128 (vertical 1.0 | |
129 (article-copy 0.5) | |
130 (message 1.0 point))) | |
131 (forward | |
132 (vertical 1.0 | |
133 (message 1.0 point))) | |
134 (reply-yank | |
135 (vertical 1.0 | |
136 (message 1.0 point))) | |
137 (mail-bounce | |
138 (vertical 1.0 | |
139 (article 0.5) | |
140 (message 1.0 point))) | |
141 (pipe | |
142 (vertical 1.0 | |
143 (summary 0.25 point) | |
144 (if gnus-carpal '(summary-carpal 4)) | |
145 ("*Shell Command Output*" 1.0))) | |
146 (bug | |
147 (vertical 1.0 | |
148 ("*Gnus Help Bug*" 0.5) | |
149 ("*Gnus Bug*" 1.0 point))) | |
150 (score-trace | |
151 (vertical 1.0 | |
152 (summary 0.5 point) | |
153 ("*Score Trace*" 1.0))) | |
154 (score-words | |
155 (vertical 1.0 | |
156 (summary 0.5 point) | |
157 ("*Score Words*" 1.0))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
158 (split-trace |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
159 (vertical 1.0 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
160 (summary 0.5 point) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
161 ("*Split Trace*" 1.0))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
162 (category |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
163 (vertical 1.0 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
164 (category 1.0))) |
17493 | 165 (compose-bounce |
166 (vertical 1.0 | |
167 (article 0.5) | |
168 (message 1.0 point)))) | |
169 "Window configuration for all possible Gnus buffers. | |
170 See the Gnus manual for an explanation of the syntax used.") | |
171 | |
172 (defvar gnus-window-to-buffer | |
173 '((group . gnus-group-buffer) | |
174 (summary . gnus-summary-buffer) | |
175 (article . gnus-article-buffer) | |
176 (server . gnus-server-buffer) | |
177 (browse . "*Gnus Browse Server*") | |
178 (edit-group . gnus-group-edit-buffer) | |
179 (edit-form . gnus-edit-form-buffer) | |
180 (edit-server . gnus-server-edit-buffer) | |
181 (group-carpal . gnus-carpal-group-buffer) | |
182 (summary-carpal . gnus-carpal-summary-buffer) | |
183 (server-carpal . gnus-carpal-server-buffer) | |
184 (browse-carpal . gnus-carpal-browse-buffer) | |
185 (edit-score . gnus-score-edit-buffer) | |
186 (message . gnus-message-buffer) | |
187 (mail . gnus-message-buffer) | |
188 (post-news . gnus-message-buffer) | |
189 (faq . gnus-faq-buffer) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
190 (picons . gnus-picons-buffer-name) |
17493 | 191 (tree . gnus-tree-buffer) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
192 (score-trace . "*Score Trace*") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
193 (split-trace . "*Split Trace*") |
17493 | 194 (info . gnus-info-buffer) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
195 (category . gnus-category-buffer) |
17493 | 196 (article-copy . gnus-article-copy) |
197 (draft . gnus-draft-buffer)) | |
198 "Mapping from short symbols to buffer names or buffer variables.") | |
199 | |
200 ;;; Internal variables. | |
201 | |
202 (defvar gnus-current-window-configuration nil | |
203 "The most recently set window configuration.") | |
204 | |
205 (defvar gnus-created-frames nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
206 (defvar gnus-window-frame-focus nil) |
17493 | 207 |
208 (defun gnus-kill-gnus-frames () | |
209 "Kill all frames Gnus has created." | |
210 (while gnus-created-frames | |
211 (when (frame-live-p (car gnus-created-frames)) | |
212 ;; We slap a condition-case around this `delete-frame' to ensure | |
213 ;; against errors if we try do delete the single frame that's left. | |
214 (ignore-errors | |
215 (delete-frame (car gnus-created-frames)))) | |
216 (pop gnus-created-frames))) | |
217 | |
218 (defun gnus-window-configuration-element (list) | |
219 (while (and list | |
220 (not (assq (car list) gnus-window-configuration))) | |
221 (pop list)) | |
222 (cadr (assq (car list) gnus-window-configuration))) | |
223 | |
224 (defun gnus-windows-old-to-new (setting) | |
225 ;; First we take care of the really, really old Gnus 3 actions. | |
226 (when (symbolp setting) | |
227 (setq setting | |
228 ;; Take care of ooold GNUS 3.x values. | |
229 (cond ((eq setting 'SelectArticle) 'article) | |
230 ((memq setting '(SelectNewsgroup SelectSubject ExpandSubject)) | |
231 'summary) | |
232 ((memq setting '(ExitNewsgroup)) 'group) | |
233 (t setting)))) | |
234 (if (or (listp setting) | |
235 (not (and gnus-window-configuration | |
236 (memq setting '(group summary article))))) | |
237 setting | |
238 (let* ((elem | |
239 (cond | |
240 ((eq setting 'group) | |
241 (gnus-window-configuration-element | |
242 '(group newsgroups ExitNewsgroup))) | |
243 ((eq setting 'summary) | |
244 (gnus-window-configuration-element | |
245 '(summary SelectNewsgroup SelectSubject ExpandSubject))) | |
246 ((eq setting 'article) | |
247 (gnus-window-configuration-element | |
248 '(article SelectArticle))))) | |
249 (total (apply '+ elem)) | |
250 (types '(group summary article)) | |
251 (pbuf (if (eq setting 'newsgroups) 'group 'summary)) | |
252 (i 0) | |
253 perc out) | |
254 (while (< i 3) | |
255 (or (not (numberp (nth i elem))) | |
256 (zerop (nth i elem)) | |
257 (progn | |
258 (setq perc (if (= i 2) | |
259 1.0 | |
260 (/ (float (nth i elem)) total))) | |
261 (push (if (eq pbuf (nth i types)) | |
262 (list (nth i types) perc 'point) | |
263 (list (nth i types) perc)) | |
264 out))) | |
265 (incf i)) | |
266 `(vertical 1.0 ,@(nreverse out))))) | |
267 | |
268 ;;;###autoload | |
269 (defun gnus-add-configuration (conf) | |
270 "Add the window configuration CONF to `gnus-buffer-configuration'." | |
271 (setq gnus-buffer-configuration | |
272 (cons conf (delq (assq (car conf) gnus-buffer-configuration) | |
273 gnus-buffer-configuration)))) | |
274 | |
275 (defvar gnus-frame-list nil) | |
276 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
277 (defun gnus-window-to-buffer-helper (obj) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
278 (cond ((not (symbolp obj)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
279 obj) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
280 ((boundp obj) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
281 (symbol-value obj)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
282 ((fboundp obj) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
283 (funcall obj)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
284 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
285 nil))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
286 |
17493 | 287 (defun gnus-configure-frame (split &optional window) |
288 "Split WINDOW according to SPLIT." | |
289 (unless window | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
290 (setq window (or (get-buffer-window (current-buffer)) (selected-window)))) |
17493 | 291 (select-window window) |
292 ;; This might be an old-stylee buffer config. | |
293 (when (vectorp split) | |
294 (setq split (append split nil))) | |
295 (when (or (consp (car split)) | |
296 (vectorp (car split))) | |
297 (push 1.0 split) | |
298 (push 'vertical split)) | |
299 ;; The SPLIT might be something that is to be evaled to | |
300 ;; return a new SPLIT. | |
301 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
302 (gnus-functionp (car split))) | |
303 (setq split (eval split))) | |
304 (let* ((type (car split)) | |
305 (subs (cddr split)) | |
306 (len (if (eq type 'horizontal) (window-width) (window-height))) | |
307 (total 0) | |
308 (window-min-width (or gnus-window-min-width window-min-width)) | |
309 (window-min-height (or gnus-window-min-height window-min-height)) | |
310 s result new-win rest comp-subs size sub) | |
311 (cond | |
312 ;; Nothing to do here. | |
313 ((null split)) | |
314 ;; Don't switch buffers. | |
315 ((null type) | |
316 (and (memq 'point split) window)) | |
317 ;; This is a buffer to be selected. | |
318 ((not (memq type '(frame horizontal vertical))) | |
319 (let ((buffer (cond ((stringp type) type) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
320 (t (cdr (assq type gnus-window-to-buffer)))))) |
17493 | 321 (unless buffer |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
322 (error "Invalid buffer type: %s" type)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
323 (let ((buf (gnus-get-buffer-create |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
324 (gnus-window-to-buffer-helper buffer)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
325 (if (eq buf (window-buffer (selected-window))) (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
326 (switch-to-buffer buf))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
327 (when (memq 'frame-focus split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
328 (setq gnus-window-frame-focus window)) |
17493 | 329 ;; We return the window if it has the `point' spec. |
330 (and (memq 'point split) window))) | |
331 ;; This is a frame split. | |
332 ((eq type 'frame) | |
333 (unless gnus-frame-list | |
334 (setq gnus-frame-list (list (window-frame | |
335 (get-buffer-window (current-buffer)))))) | |
336 (let ((i 0) | |
337 params frame fresult) | |
338 (while (< i (length subs)) | |
339 ;; Frame parameter is gotten from the sub-split. | |
340 (setq params (cadr (elt subs i))) | |
341 ;; It should be a list. | |
342 (unless (listp params) | |
343 (setq params nil)) | |
344 ;; Create a new frame? | |
345 (unless (setq frame (elt gnus-frame-list i)) | |
346 (nconc gnus-frame-list (list (setq frame (make-frame params)))) | |
347 (push frame gnus-created-frames)) | |
348 ;; Is the old frame still alive? | |
349 (unless (frame-live-p frame) | |
350 (setcar (nthcdr i gnus-frame-list) | |
351 (setq frame (make-frame params)))) | |
352 ;; Select the frame in question and do more splits there. | |
353 (select-frame frame) | |
354 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult)) | |
355 (incf i)) | |
356 ;; Select the frame that has the selected buffer. | |
357 (when fresult | |
358 (select-frame (window-frame fresult))))) | |
359 ;; This is a normal split. | |
360 (t | |
361 (when (> (length subs) 0) | |
362 ;; First we have to compute the sizes of all new windows. | |
363 (while subs | |
364 (setq sub (append (pop subs) nil)) | |
365 (while (and (not (assq (car sub) gnus-window-to-buffer)) | |
366 (gnus-functionp (car sub))) | |
367 (setq sub (eval sub))) | |
368 (when sub | |
369 (push sub comp-subs) | |
370 (setq size (cadar comp-subs)) | |
371 (cond ((equal size 1.0) | |
372 (setq rest (car comp-subs)) | |
373 (setq s 0)) | |
374 ((floatp size) | |
375 (setq s (floor (* size len)))) | |
376 ((integerp size) | |
377 (setq s size)) | |
378 (t | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
379 (error "Invalid size: %s" size))) |
17493 | 380 ;; Try to make sure that we are inside the safe limits. |
381 (cond ((zerop s)) | |
382 ((eq type 'horizontal) | |
383 (setq s (max s window-min-width))) | |
384 ((eq type 'vertical) | |
385 (setq s (max s window-min-height)))) | |
386 (setcar (cdar comp-subs) s) | |
387 (incf total s))) | |
388 ;; Take care of the "1.0" spec. | |
389 (if rest | |
390 (setcar (cdr rest) (- len total)) | |
391 (error "No 1.0 specs in %s" split)) | |
392 ;; The we do the actual splitting in a nice recursive | |
393 ;; fashion. | |
394 (setq comp-subs (nreverse comp-subs)) | |
395 (while comp-subs | |
396 (if (null (cdr comp-subs)) | |
397 (setq new-win window) | |
398 (setq new-win | |
399 (split-window window (cadar comp-subs) | |
400 (eq type 'horizontal)))) | |
401 (setq result (or (gnus-configure-frame | |
402 (car comp-subs) window) | |
403 result)) | |
404 (select-window new-win) | |
405 (setq window new-win) | |
406 (setq comp-subs (cdr comp-subs)))) | |
407 ;; Return the proper window, if any. | |
408 (when result | |
409 (select-window result)))))) | |
410 | |
411 (defvar gnus-frame-split-p nil) | |
412 | |
413 (defun gnus-configure-windows (setting &optional force) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
414 (if (window-configuration-p setting) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
415 (set-window-configuration setting) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
416 (setq gnus-current-window-configuration setting) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
417 (setq force (or force gnus-always-force-window-configuration)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
418 (setq setting (gnus-windows-old-to-new setting)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
419 (let ((split (if (symbolp setting) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
420 (cadr (assq setting gnus-buffer-configuration)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
421 setting)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
422 all-visible) |
17493 | 423 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
424 (setq gnus-frame-split-p nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
425 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
426 (unless split |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
427 (error "No such setting in `gnus-buffer-configuration': %s" setting)) |
17493 | 428 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
429 (if (and (setq all-visible (gnus-all-windows-visible-p split)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
430 (not force)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
431 ;; All the windows mentioned are already visible, so we just |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
432 ;; put point in the assigned buffer, and do not touch the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
433 ;; winconf. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
434 (select-window all-visible) |
17493 | 435 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
436 ;; Either remove all windows or just remove all Gnus windows. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
437 (let ((frame (selected-frame))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
438 (unwind-protect |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
439 (if gnus-use-full-window |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
440 ;; We want to remove all other windows. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
441 (if (not gnus-frame-split-p) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
442 ;; This is not a `frame' split, so we ignore the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
443 ;; other frames. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
444 (delete-other-windows) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
445 ;; This is a `frame' split, so we delete all windows |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
446 ;; on all frames. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
447 (gnus-delete-windows-in-gnusey-frames)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
448 ;; Just remove some windows. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
449 (gnus-remove-some-windows) |
33711
dc1ebf25e048
(gnus-configure-windows): switch-to-buffer -> set-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31716
diff
changeset
|
450 (set-buffer nntp-server-buffer)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
451 (select-frame frame))) |
17493 | 452 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
453 (let (gnus-window-frame-focus) |
33711
dc1ebf25e048
(gnus-configure-windows): switch-to-buffer -> set-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31716
diff
changeset
|
454 (set-buffer nntp-server-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
455 (gnus-configure-frame split) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
456 (when gnus-window-frame-focus |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
457 (select-frame (window-frame gnus-window-frame-focus)))))))) |
17493 | 458 |
459 (defun gnus-delete-windows-in-gnusey-frames () | |
460 "Do a `delete-other-windows' in all frames that have Gnus windows." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
461 (let ((buffers (gnus-buffers))) |
17493 | 462 (mapcar |
463 (lambda (frame) | |
464 (unless (eq (cdr (assq 'minibuffer | |
465 (frame-parameters frame))) | |
466 'only) | |
467 (select-frame frame) | |
468 (let (do-delete) | |
469 (walk-windows | |
470 (lambda (window) | |
471 (when (memq (window-buffer window) buffers) | |
472 (setq do-delete t)))) | |
473 (when do-delete | |
474 (delete-other-windows))))) | |
475 (frame-list)))) | |
476 | |
477 (defun gnus-all-windows-visible-p (split) | |
478 "Say whether all buffers in SPLIT are currently visible. | |
479 In particular, the value returned will be the window that | |
480 should have point." | |
481 (let ((stack (list split)) | |
482 (all-visible t) | |
483 type buffer win buf) | |
484 (while (and (setq split (pop stack)) | |
485 all-visible) | |
486 ;; Be backwards compatible. | |
487 (when (vectorp split) | |
488 (setq split (append split nil))) | |
489 (when (or (consp (car split)) | |
490 (vectorp (car split))) | |
491 (push 1.0 split) | |
492 (push 'vertical split)) | |
493 ;; The SPLIT might be something that is to be evaled to | |
494 ;; return a new SPLIT. | |
495 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
496 (gnus-functionp (car split))) | |
497 (setq split (eval split))) | |
498 | |
499 (setq type (elt split 0)) | |
500 (cond | |
501 ;; Nothing here. | |
502 ((null split) t) | |
503 ;; A buffer. | |
504 ((not (memq type '(horizontal vertical frame))) | |
505 (setq buffer (cond ((stringp type) type) | |
506 (t (cdr (assq type gnus-window-to-buffer))))) | |
507 (unless buffer | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
508 (error "Invalid buffer type: %s" type)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
509 (if (and (setq buf (get-buffer (gnus-window-to-buffer-helper buffer))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
510 (setq win (get-buffer-window buf t))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
511 (if (memq 'point split) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
512 (setq all-visible win)) |
17493 | 513 (setq all-visible nil))) |
514 (t | |
515 (when (eq type 'frame) | |
516 (setq gnus-frame-split-p t)) | |
517 (setq stack (append (cddr split) stack))))) | |
518 (unless (eq all-visible t) | |
519 all-visible))) | |
520 | |
521 (defun gnus-window-top-edge (&optional window) | |
522 (nth 1 (window-edges window))) | |
523 | |
524 (defun gnus-remove-some-windows () | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
525 (let ((buffers (gnus-buffers)) |
17493 | 526 buf bufs lowest-buf lowest) |
527 (save-excursion | |
528 ;; Remove windows on all known Gnus buffers. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
529 (while (setq buf (pop buffers)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
530 (when (get-buffer-window buf) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
531 (push buf bufs) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
532 (pop-to-buffer buf) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
533 (when (or (not lowest) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
534 (< (gnus-window-top-edge) lowest)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
535 (setq lowest (gnus-window-top-edge) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
536 lowest-buf buf)))) |
17493 | 537 (when lowest-buf |
538 (pop-to-buffer lowest-buf) | |
539 (switch-to-buffer nntp-server-buffer)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
540 (mapcar (lambda (b) (delete-windows-on b t)) bufs)))) |
17493 | 541 |
542 (provide 'gnus-win) | |
543 | |
544 ;;; gnus-win.el ends here |