comparison lisp/window.el @ 90288:7432ca837c8d

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-9 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 16-33) - Update from CVS - Install ERC. - Fix ERC compiler warnings. - Use utf-8 encoding in ERC ChangeLogs. - Merge ERC-related Viper hacks into Viper. - Merge from erc--main--0 - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 8-13) - Merge from emacs--devo--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 01 Feb 2006 10:07:17 +0000
parents 7beb78bc1f8e bde0adf72ba8
children c5406394f567
comparison
equal deleted inserted replaced
90287:3cd97358d81a 90288:7432ca837c8d
295 subtree 295 subtree
296 )))) 296 ))))
297 297
298 ;;; Window or object edges 298 ;;; Window or object edges
299 299
300 (defun bw-l(obj) 300 (defun bw-l (obj)
301 "Left edge of OBJ." 301 "Left edge of OBJ."
302 (if (windowp obj) (nth 0 (window-edges obj)) (cdr (assq 'l obj)))) 302 (if (windowp obj) (nth 0 (window-edges obj)) (cdr (assq 'l obj))))
303 (defun bw-t(obj) 303 (defun bw-t (obj)
304 "Top edge of OBJ." 304 "Top edge of OBJ."
305 (if (windowp obj) (nth 1 (window-edges obj)) (cdr (assq 't obj)))) 305 (if (windowp obj) (nth 1 (window-edges obj)) (cdr (assq 't obj))))
306 (defun bw-r(obj) 306 (defun bw-r (obj)
307 "Right edge of OBJ." 307 "Right edge of OBJ."
308 (if (windowp obj) (nth 2 (window-edges obj)) (cdr (assq 'r obj)))) 308 (if (windowp obj) (nth 2 (window-edges obj)) (cdr (assq 'r obj))))
309 (defun bw-b(obj) 309 (defun bw-b (obj)
310 "Bottom edge of OBJ." 310 "Bottom edge of OBJ."
311 (if (windowp obj) (nth 3 (window-edges obj)) (cdr (assq 'b obj)))) 311 (if (windowp obj) (nth 3 (window-edges obj)) (cdr (assq 'b obj))))
312 312
313 ;;; Split directions 313 ;;; Split directions
314 314
315 (defun bw-dir(obj) 315 (defun bw-dir (obj)
316 "Return window split tree direction if OBJ. 316 "Return window split tree direction if OBJ.
317 If OBJ is a window return 'both. If it is a window split tree 317 If OBJ is a window return 'both. If it is a window split tree
318 then return its direction." 318 then return its direction."
319 (if (symbolp obj) 319 (if (symbolp obj)
320 obj 320 obj
321 (if (windowp obj) 321 (if (windowp obj)
322 'both 322 'both
323 (let ((dir (cdr (assq 'dir obj)))) 323 (let ((dir (cdr (assq 'dir obj))))
324 (unless (memq dir '(hor ver both)) 324 (unless (memq dir '(hor ver both))
325 (error "Can't find dir in %s" obj)) 325 (error "Can't find dir in %s" obj))
326 dir)))) 326 dir))))
327 327
328 (defun bw-eqdir(obj1 obj2) 328 (defun bw-eqdir (obj1 obj2)
329 "Return t if window split tree directions are equal. 329 "Return t if window split tree directions are equal.
330 OBJ1 and OBJ2 should be either windows or window split trees in 330 OBJ1 and OBJ2 should be either windows or window split trees in
331 our format. The directions returned by `bw-dir' are compared and 331 our format. The directions returned by `bw-dir' are compared and
332 t is returned if they are `eq' or one of them is 'both." 332 t is returned if they are `eq' or one of them is 'both."
333 (let ((dir1 (bw-dir obj1)) 333 (let ((dir1 (bw-dir obj1))
334 (dir2 (bw-dir obj2))) 334 (dir2 (bw-dir obj2)))
335 (or (eq dir1 dir2) 335 (or (eq dir1 dir2)
336 (eq dir1 'both) 336 (eq dir1 'both)
337 (eq dir2 'both)))) 337 (eq dir2 'both))))
338 338
339 ;;; Building split tree 339 ;;; Building split tree
340 340
341 (defun bw-refresh-edges(obj) 341 (defun bw-refresh-edges (obj)
342 "Refresh the edge information of OBJ and return OBJ." 342 "Refresh the edge information of OBJ and return OBJ."
343 (unless (windowp obj) 343 (unless (windowp obj)
344 (let ((childs (cdr (assq 'childs obj))) 344 (let ((childs (cdr (assq 'childs obj)))
345 (ol 1000) 345 (ol 1000)
346 (ot 1000) 346 (ot 1000)
362 )) 362 ))
363 obj) 363 obj)
364 364
365 ;;; Balance windows 365 ;;; Balance windows
366 366
367 (defun balance-windows(&optional window-or-frame) 367 (defun balance-windows (&optional window-or-frame)
368 "Make windows the same heights or widths in window split subtrees. 368 "Make windows the same heights or widths in window split subtrees.
369 369
370 When called non-interactively WINDOW-OR-FRAME may be either a 370 When called non-interactively WINDOW-OR-FRAME may be either a
371 window or a frame. It then balances the windows on the implied 371 window or a frame. It then balances the windows on the implied
372 frame. If the parameter is a window only the corresponding window 372 frame. If the parameter is a window only the corresponding window
373 subtree is balanced." 373 subtree is balanced."
374 (interactive) 374 (interactive)
375 (let ( 375 (let (
376 (wt (bw-get-tree window-or-frame)) 376 (wt (bw-get-tree window-or-frame))
377 (w) 377 (w)
381 (windows (window-list nil 0)) 381 (windows (window-list nil 0))
382 (counter 0)) 382 (counter 0))
383 (when wt 383 (when wt
384 (while (not (member last-sizes tried-sizes)) 384 (while (not (member last-sizes tried-sizes))
385 (when last-sizes (setq tried-sizes (cons last-sizes tried-sizes))) 385 (when last-sizes (setq tried-sizes (cons last-sizes tried-sizes)))
386 (setq last-sizes (mapcar (lambda(w) 386 (setq last-sizes (mapcar (lambda (w)
387 (window-edges w)) 387 (window-edges w))
388 windows)) 388 windows))
389 (when (eq 'hor (bw-dir wt)) 389 (when (eq 'hor (bw-dir wt))
390 (setq w (- (bw-r wt) (bw-l wt)))) 390 (setq w (- (bw-r wt) (bw-l wt))))
391 (when (eq 'ver (bw-dir wt)) 391 (when (eq 'ver (bw-dir wt))
392 (setq h (- (bw-b wt) (bw-t wt)))) 392 (setq h (- (bw-b wt) (bw-t wt))))
393 (bw-balance-sub wt w h))))) 393 (bw-balance-sub wt w h)))))
394 394
395 (defun bw-adjust-window(window delta horizontal) 395 (defun bw-adjust-window (window delta horizontal)
396 "Wrapper around `adjust-window-trailing-edge' with error checking. 396 "Wrapper around `adjust-window-trailing-edge' with error checking.
397 Arguments WINDOW, DELTA and HORIZONTAL are passed on to that function." 397 Arguments WINDOW, DELTA and HORIZONTAL are passed on to that function."
398 (condition-case err 398 (condition-case err
399 (adjust-window-trailing-edge window delta horizontal) 399 (adjust-window-trailing-edge window delta horizontal)
400 (error 400 (error
401 ;;(message "adjust: %s" (error-message-string err)) 401 ;;(message "adjust: %s" (error-message-string err))
402 ))) 402 )))
403 403
404 (defun bw-balance-sub(wt w h) 404 (defun bw-balance-sub (wt w h)
405 (setq wt (bw-refresh-edges wt)) 405 (setq wt (bw-refresh-edges wt))
406 (unless w (setq w (- (bw-r wt) (bw-l wt)))) 406 (unless w (setq w (- (bw-r wt) (bw-l wt))))
407 (unless h (setq h (- (bw-b wt) (bw-t wt)))) 407 (unless h (setq h (- (bw-b wt) (bw-t wt))))
408 (if (windowp wt) 408 (if (windowp wt)
409 (progn 409 (progn
432 If nil, adjust point in each of the two windows to minimize redisplay. 432 If nil, adjust point in each of the two windows to minimize redisplay.
433 This is convenient on slow terminals, but point can move strangely. 433 This is convenient on slow terminals, but point can move strangely.
434 434
435 This option applies only to `split-window-vertically' and 435 This option applies only to `split-window-vertically' and
436 functions that call it. `split-window' always keeps the original 436 functions that call it. `split-window' always keeps the original
437 point in both children," 437 point in both children."
438 :type 'boolean 438 :type 'boolean
439 :group 'windows) 439 :group 'windows)
440 440
441 (defun split-window-vertically (&optional arg) 441 (defun split-window-vertically (&optional arg)
442 "Split current window into two windows, one above the other. 442 "Split current window into two windows, one above the other.