comparison lisp/window.el @ 86337:161416156d88

(balance-windows): Remove unused var `counter'. (bw-balance-sub): Remove unused var `lastchild'. (split-window-vertically): Remove unused var `switch'. (recenter-top-bottom): Remove unused vars `bottom', `current', `total'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 22 Nov 2007 18:08:06 +0000
parents c679b91efdfa
children 44a6a92e5396
comparison
equal deleted inserted replaced
86336:5dde93581c8f 86337:161416156d88
213 This counts the windows in the selected frame and (if the minibuffer is 213 This counts the windows in the selected frame and (if the minibuffer is
214 to be counted) its minibuffer frame (if that's not the same frame). 214 to be counted) its minibuffer frame (if that's not the same frame).
215 The optional arg MINIBUF non-nil means count the minibuffer 215 The optional arg MINIBUF non-nil means count the minibuffer
216 even if it is inactive." 216 even if it is inactive."
217 (let ((count 0)) 217 (let ((count 0))
218 (walk-windows (function (lambda (w) 218 (walk-windows (lambda (w) (setq count (+ count 1)))
219 (setq count (+ count 1))))
220 minibuf) 219 minibuf)
221 count)) 220 count))
222 221
223 (defun window-safely-shrinkable-p (&optional window) 222 (defun window-safely-shrinkable-p (&optional window)
224 "Non-nil if the WINDOW can be shrunk without shrinking other windows. 223 "Non-nil if the WINDOW can be shrunk without shrinking other windows.
377 (wt (bw-get-tree window-or-frame)) 376 (wt (bw-get-tree window-or-frame))
378 (w) 377 (w)
379 (h) 378 (h)
380 (tried-sizes) 379 (tried-sizes)
381 (last-sizes) 380 (last-sizes)
382 (windows (window-list nil 0)) 381 (windows (window-list nil 0)))
383 (counter 0))
384 (when wt 382 (when wt
385 (while (not (member last-sizes tried-sizes)) 383 (while (not (member last-sizes tried-sizes))
386 (when last-sizes (setq tried-sizes (cons last-sizes tried-sizes))) 384 (when last-sizes (setq tried-sizes (cons last-sizes tried-sizes)))
387 (setq last-sizes (mapcar (lambda (w) 385 (setq last-sizes (mapcar (lambda (w)
388 (window-edges w)) 386 (window-edges w))
413 (if (windowp wt) 411 (if (windowp wt)
414 (progn 412 (progn
415 (when w 413 (when w
416 (let ((dw (- w (- (bw-r wt) (bw-l wt))))) 414 (let ((dw (- w (- (bw-r wt) (bw-l wt)))))
417 (when (/= 0 dw) 415 (when (/= 0 dw)
418 (bw-adjust-window wt dw t)))) 416 (bw-adjust-window wt dw t))))
419 (when h 417 (when h
420 (let ((dh (- h (- (bw-b wt) (bw-t wt))))) 418 (let ((dh (- h (- (bw-b wt) (bw-t wt)))))
421 (when (/= 0 dh) 419 (when (/= 0 dh)
422 (bw-adjust-window wt dh nil))))) 420 (bw-adjust-window wt dh nil)))))
423 (let* ((childs (cdr (assq 'childs wt))) 421 (let* ((childs (cdr (assq 'childs wt)))
424 (lastchild (car (last childs)))
425 (cw (when w (/ w (if (bw-eqdir 'hor wt) (length childs) 1)))) 422 (cw (when w (/ w (if (bw-eqdir 'hor wt) (length childs) 1))))
426 (ch (when h (/ h (if (bw-eqdir 'ver wt) (length childs) 1))))) 423 (ch (when h (/ h (if (bw-eqdir 'ver wt) (length childs) 1)))))
427 (dolist (c childs) 424 (dolist (c childs)
428 (bw-balance-sub c cw ch))))) 425 (bw-balance-sub c cw ch)))))
429 426
430 ;;; A different solution to balance-windows 427 ;;; A different solution to balance-windows
431 428
432 (defun window-fixed-size-p (&optional window direction) 429 (defun window-fixed-size-p (&optional window direction)
433 "Non-nil if WINDOW cannot be resized in DIRECTION. 430 "Non-nil if WINDOW cannot be resized in DIRECTION.
559 (interactive "P") 556 (interactive "P")
560 (let ((old-w (selected-window)) 557 (let ((old-w (selected-window))
561 (old-point (point)) 558 (old-point (point))
562 (size (and arg (prefix-numeric-value arg))) 559 (size (and arg (prefix-numeric-value arg)))
563 (window-full-p nil) 560 (window-full-p nil)
564 new-w bottom switch moved) 561 new-w bottom moved)
565 (and size (< size 0) (setq size (+ (window-height) size))) 562 (and size (< size 0) (setq size (+ (window-height) size)))
566 (setq new-w (split-window nil size)) 563 (setq new-w (split-window nil size))
567 (or split-window-keep-point 564 (or split-window-keep-point
568 (progn 565 (progn
569 (save-excursion 566 (save-excursion
902 (interactive "P") 899 (interactive "P")
903 (cond 900 (cond
904 (arg (recenter arg)) ; Always respect ARG. 901 (arg (recenter arg)) ; Always respect ARG.
905 ((not (eq this-command last-command)) 902 ((not (eq this-command last-command))
906 ;; First time - save mode and recenter. 903 ;; First time - save mode and recenter.
907 (let ((bottom (1+ (count-lines 1 (window-end)))) 904 (setq recenter-last-op 'middle)
908 (current (1+ (count-lines 1 (point)))) 905 (recenter))
909 (total (window-height)))
910 (setq recenter-last-op 'middle)
911 (recenter)))
912 (t ;; repeat: loop through various options. 906 (t ;; repeat: loop through various options.
913 (setq recenter-last-op 907 (setq recenter-last-op
914 (ecase recenter-last-op 908 (ecase recenter-last-op
915 (middle (recenter scroll-conservatively) 'top) 909 (middle (recenter scroll-conservatively) 'top)
916 (top (recenter (1- (- scroll-conservatively))) 'bottom) 910 (top (recenter (1- (- scroll-conservatively))) 'bottom)