diff options
| author | ShengHuo ZHU | 2000-12-05 05:18:31 +0000 |
|---|---|---|
| committer | ShengHuo ZHU | 2000-12-05 05:18:31 +0000 |
| commit | ca3ab2d8060e8d9671bad7d97bb2d5c70a5fd103 (patch) | |
| tree | 446eb1676a2f3bd2df693d6ded6ed68100b12a4e | |
| parent | 25fc4fd5b853e3dfca6a3780347f5fdfcdab888c (diff) | |
| download | emacs-ca3ab2d8060e8d9671bad7d97bb2d5c70a5fd103.tar.gz emacs-ca3ab2d8060e8d9671bad7d97bb2d5c70a5fd103.zip | |
(gnus-configure-frame): Save selected window.
| -rw-r--r-- | lisp/gnus/ChangeLog | 1 | ||||
| -rw-r--r-- | lisp/gnus/gnus-win.el | 243 |
2 files changed, 123 insertions, 121 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 16086b54ca4..414f3af96d0 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | * gnus-win.el (gnus-configure-windows): Make sure | 6 | * gnus-win.el (gnus-configure-windows): Make sure |
| 7 | nntp-server-buffer is live. | 7 | nntp-server-buffer is live. |
| 8 | (gnus-remove-some-windows): switch-to-buffer -> set-buffer. | 8 | (gnus-remove-some-windows): switch-to-buffer -> set-buffer. |
| 9 | (gnus-configure-frame): Save selected window. | ||
| 9 | 10 | ||
| 10 | 2000-12-04 Andreas Jaeger <aj@suse.de> | 11 | 2000-12-04 Andreas Jaeger <aj@suse.de> |
| 11 | 12 | ||
diff --git a/lisp/gnus/gnus-win.el b/lisp/gnus/gnus-win.el index 3abf46f5f36..51934fd9b5f 100644 --- a/lisp/gnus/gnus-win.el +++ b/lisp/gnus/gnus-win.el | |||
| @@ -286,127 +286,128 @@ See the Gnus manual for an explanation of the syntax used.") | |||
| 286 | 286 | ||
| 287 | (defun gnus-configure-frame (split &optional window) | 287 | (defun gnus-configure-frame (split &optional window) |
| 288 | "Split WINDOW according to SPLIT." | 288 | "Split WINDOW according to SPLIT." |
| 289 | (unless window | 289 | (let ((current-window |
| 290 | (setq window (or (get-buffer-window (current-buffer)) (selected-window)))) | 290 | (or (get-buffer-window (current-buffer)) (selected-window)))) |
| 291 | (select-window window) | 291 | (unless window |
| 292 | ;; This might be an old-stylee buffer config. | 292 | (setq window current-window)) |
| 293 | (when (vectorp split) | 293 | (select-window window) |
| 294 | (setq split (append split nil))) | 294 | ;; This might be an old-stylee buffer config. |
| 295 | (when (or (consp (car split)) | 295 | (when (vectorp split) |
| 296 | (vectorp (car split))) | 296 | (setq split (append split nil))) |
| 297 | (push 1.0 split) | 297 | (when (or (consp (car split)) |
| 298 | (push 'vertical split)) | 298 | (vectorp (car split))) |
| 299 | ;; The SPLIT might be something that is to be evaled to | 299 | (push 1.0 split) |
| 300 | ;; return a new SPLIT. | 300 | (push 'vertical split)) |
| 301 | (while (and (not (assq (car split) gnus-window-to-buffer)) | 301 | ;; The SPLIT might be something that is to be evaled to |
| 302 | (gnus-functionp (car split))) | 302 | ;; return a new SPLIT. |
| 303 | (setq split (eval split))) | 303 | (while (and (not (assq (car split) gnus-window-to-buffer)) |
| 304 | (let* ((type (car split)) | 304 | (gnus-functionp (car split))) |
| 305 | (subs (cddr split)) | 305 | (setq split (eval split))) |
| 306 | (len (if (eq type 'horizontal) (window-width) (window-height))) | 306 | (let* ((type (car split)) |
| 307 | (total 0) | 307 | (subs (cddr split)) |
| 308 | (window-min-width (or gnus-window-min-width window-min-width)) | 308 | (len (if (eq type 'horizontal) (window-width) (window-height))) |
| 309 | (window-min-height (or gnus-window-min-height window-min-height)) | 309 | (total 0) |
| 310 | s result new-win rest comp-subs size sub) | 310 | (window-min-width (or gnus-window-min-width window-min-width)) |
| 311 | (cond | 311 | (window-min-height (or gnus-window-min-height window-min-height)) |
| 312 | ;; Nothing to do here. | 312 | s result new-win rest comp-subs size sub) |
| 313 | ((null split)) | 313 | (cond |
| 314 | ;; Don't switch buffers. | 314 | ;; Nothing to do here. |
| 315 | ((null type) | 315 | ((null split)) |
| 316 | (and (memq 'point split) window)) | 316 | ;; Don't switch buffers. |
| 317 | ;; This is a buffer to be selected. | 317 | ((null type) |
| 318 | ((not (memq type '(frame horizontal vertical))) | 318 | (and (memq 'point split) window)) |
| 319 | (let ((buffer (cond ((stringp type) type) | 319 | ;; This is a buffer to be selected. |
| 320 | (t (cdr (assq type gnus-window-to-buffer)))))) | 320 | ((not (memq type '(frame horizontal vertical))) |
| 321 | (unless buffer | 321 | (let ((buffer (cond ((stringp type) type) |
| 322 | (error "Invalid buffer type: %s" type)) | 322 | (t (cdr (assq type gnus-window-to-buffer)))))) |
| 323 | (let ((buf (gnus-get-buffer-create | 323 | (unless buffer |
| 324 | (gnus-window-to-buffer-helper buffer)))) | 324 | (error "Invalid buffer type: %s" type)) |
| 325 | (if (eq buf (window-buffer (selected-window))) (set-buffer buf) | 325 | (let ((buf (gnus-get-buffer-create |
| 326 | (switch-to-buffer buf))) | 326 | (gnus-window-to-buffer-helper buffer)))) |
| 327 | (when (memq 'frame-focus split) | 327 | (if (eq buf (window-buffer (selected-window))) (set-buffer buf) |
| 328 | (setq gnus-window-frame-focus window)) | 328 | (switch-to-buffer buf))) |
| 329 | ;; We return the window if it has the `point' spec. | 329 | (when (memq 'frame-focus split) |
| 330 | (and (memq 'point split) window))) | 330 | (setq gnus-window-frame-focus window)) |
| 331 | ;; This is a frame split. | 331 | ;; We return the window if it has the `point' spec. |
| 332 | ((eq type 'frame) | 332 | (and (memq 'point split) window))) |
| 333 | (unless gnus-frame-list | 333 | ;; This is a frame split. |
| 334 | (setq gnus-frame-list (list (window-frame | 334 | ((eq type 'frame) |
| 335 | (get-buffer-window (current-buffer)))))) | 335 | (unless gnus-frame-list |
| 336 | (let ((i 0) | 336 | (setq gnus-frame-list (list (window-frame current-window)))) |
| 337 | params frame fresult) | 337 | (let ((i 0) |
| 338 | (while (< i (length subs)) | 338 | params frame fresult) |
| 339 | ;; Frame parameter is gotten from the sub-split. | 339 | (while (< i (length subs)) |
| 340 | (setq params (cadr (elt subs i))) | 340 | ;; Frame parameter is gotten from the sub-split. |
| 341 | ;; It should be a list. | 341 | (setq params (cadr (elt subs i))) |
| 342 | (unless (listp params) | 342 | ;; It should be a list. |
| 343 | (setq params nil)) | 343 | (unless (listp params) |
| 344 | ;; Create a new frame? | 344 | (setq params nil)) |
| 345 | (unless (setq frame (elt gnus-frame-list i)) | 345 | ;; Create a new frame? |
| 346 | (nconc gnus-frame-list (list (setq frame (make-frame params)))) | 346 | (unless (setq frame (elt gnus-frame-list i)) |
| 347 | (push frame gnus-created-frames)) | 347 | (nconc gnus-frame-list (list (setq frame (make-frame params)))) |
| 348 | ;; Is the old frame still alive? | 348 | (push frame gnus-created-frames)) |
| 349 | (unless (frame-live-p frame) | 349 | ;; Is the old frame still alive? |
| 350 | (setcar (nthcdr i gnus-frame-list) | 350 | (unless (frame-live-p frame) |
| 351 | (setq frame (make-frame params)))) | 351 | (setcar (nthcdr i gnus-frame-list) |
| 352 | ;; Select the frame in question and do more splits there. | 352 | (setq frame (make-frame params)))) |
| 353 | (select-frame frame) | 353 | ;; Select the frame in question and do more splits there. |
| 354 | (setq fresult (or (gnus-configure-frame (elt subs i)) fresult)) | 354 | (select-frame frame) |
| 355 | (incf i)) | 355 | (setq fresult (or (gnus-configure-frame (elt subs i)) fresult)) |
| 356 | ;; Select the frame that has the selected buffer. | 356 | (incf i)) |
| 357 | (when fresult | 357 | ;; Select the frame that has the selected buffer. |
| 358 | (select-frame (window-frame fresult))))) | 358 | (when fresult |
| 359 | ;; This is a normal split. | 359 | (select-frame (window-frame fresult))))) |
| 360 | (t | 360 | ;; This is a normal split. |
| 361 | (when (> (length subs) 0) | 361 | (t |
| 362 | ;; First we have to compute the sizes of all new windows. | 362 | (when (> (length subs) 0) |
| 363 | (while subs | 363 | ;; First we have to compute the sizes of all new windows. |
| 364 | (setq sub (append (pop subs) nil)) | 364 | (while subs |
| 365 | (while (and (not (assq (car sub) gnus-window-to-buffer)) | 365 | (setq sub (append (pop subs) nil)) |
| 366 | (gnus-functionp (car sub))) | 366 | (while (and (not (assq (car sub) gnus-window-to-buffer)) |
| 367 | (setq sub (eval sub))) | 367 | (gnus-functionp (car sub))) |
| 368 | (when sub | 368 | (setq sub (eval sub))) |
| 369 | (push sub comp-subs) | 369 | (when sub |
| 370 | (setq size (cadar comp-subs)) | 370 | (push sub comp-subs) |
| 371 | (cond ((equal size 1.0) | 371 | (setq size (cadar comp-subs)) |
| 372 | (setq rest (car comp-subs)) | 372 | (cond ((equal size 1.0) |
| 373 | (setq s 0)) | 373 | (setq rest (car comp-subs)) |
| 374 | ((floatp size) | 374 | (setq s 0)) |
| 375 | (setq s (floor (* size len)))) | 375 | ((floatp size) |
| 376 | ((integerp size) | 376 | (setq s (floor (* size len)))) |
| 377 | (setq s size)) | 377 | ((integerp size) |
| 378 | (t | 378 | (setq s size)) |
| 379 | (error "Invalid size: %s" size))) | 379 | (t |
| 380 | ;; Try to make sure that we are inside the safe limits. | 380 | (error "Invalid size: %s" size))) |
| 381 | (cond ((zerop s)) | 381 | ;; Try to make sure that we are inside the safe limits. |
| 382 | ((eq type 'horizontal) | 382 | (cond ((zerop s)) |
| 383 | (setq s (max s window-min-width))) | 383 | ((eq type 'horizontal) |
| 384 | ((eq type 'vertical) | 384 | (setq s (max s window-min-width))) |
| 385 | (setq s (max s window-min-height)))) | 385 | ((eq type 'vertical) |
| 386 | (setcar (cdar comp-subs) s) | 386 | (setq s (max s window-min-height)))) |
| 387 | (incf total s))) | 387 | (setcar (cdar comp-subs) s) |
| 388 | ;; Take care of the "1.0" spec. | 388 | (incf total s))) |
| 389 | (if rest | 389 | ;; Take care of the "1.0" spec. |
| 390 | (setcar (cdr rest) (- len total)) | 390 | (if rest |
| 391 | (error "No 1.0 specs in %s" split)) | 391 | (setcar (cdr rest) (- len total)) |
| 392 | ;; The we do the actual splitting in a nice recursive | 392 | (error "No 1.0 specs in %s" split)) |
| 393 | ;; fashion. | 393 | ;; The we do the actual splitting in a nice recursive |
| 394 | (setq comp-subs (nreverse comp-subs)) | 394 | ;; fashion. |
| 395 | (while comp-subs | 395 | (setq comp-subs (nreverse comp-subs)) |
| 396 | (if (null (cdr comp-subs)) | 396 | (while comp-subs |
| 397 | (setq new-win window) | 397 | (if (null (cdr comp-subs)) |
| 398 | (setq new-win | 398 | (setq new-win window) |
| 399 | (split-window window (cadar comp-subs) | 399 | (setq new-win |
| 400 | (eq type 'horizontal)))) | 400 | (split-window window (cadar comp-subs) |
| 401 | (setq result (or (gnus-configure-frame | 401 | (eq type 'horizontal)))) |
| 402 | (car comp-subs) window) | 402 | (setq result (or (gnus-configure-frame |
| 403 | result)) | 403 | (car comp-subs) window) |
| 404 | (select-window new-win) | 404 | result)) |
| 405 | (setq window new-win) | 405 | (select-window new-win) |
| 406 | (setq comp-subs (cdr comp-subs)))) | 406 | (setq window new-win) |
| 407 | ;; Return the proper window, if any. | 407 | (setq comp-subs (cdr comp-subs)))) |
| 408 | (when result | 408 | ;; Return the proper window, if any. |
| 409 | (select-window result)))))) | 409 | (when result |
| 410 | (select-window result))))))) | ||
| 410 | 411 | ||
| 411 | (defvar gnus-frame-split-p nil) | 412 | (defvar gnus-frame-split-p nil) |
| 412 | 413 | ||