Path: utzoo!utgpu!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!agate!eos!amelia!orville.nas.nasa.gov!raible From: raible@orville.nas.nasa.gov (Eric L. Raible) Newsgroups: comp.emacs Subject: Re: GNU Emacs POLL: where should killed window space go? Message-ID: <1369@amelia.nas.nasa.gov> Date: 18 Jan 89 02:19:09 GMT References: <8901120359.AA07667@wheat-chex.ai.mit.edu> <8758@bloom-beacon.MIT.EDU> Sender: news@amelia.nas.nasa.gov Reply-To: raible@orville.nas.nasa.gov (Eric L. Raible) Organization: NASA Ames Research Center, Moffett Field, CA Lines: 43 In article <8758@bloom-beacon.MIT.EDU> wolfgang@mgm.mit.edu.UUCP (Wolfgang Rupprecht) writes: >Usually when I delete 1 of 3 windows, I usually end up resizing the 2 >resulting windows to be equal size again. I therefor would vote for >\C-x 0 to resize all remaining windows to be *equally* sized. > I got an initial copy of this code from someone else (but can't remember who). It doesn't work too well with horizontally-split windows, but is quite useful otherwise. (global-set-key "\eB" 'balance-windows) (defun balance-windows () "Makes all visible windows the same size." (interactive) (let ((size (/ (screen-height) (count-windows)))) (walk-windows (function (lambda () (enlarge-window (- size (window-height))))) 'no-mini))) (defun walk-windows (proc &optional no-mini) "Applies PROC to each visible window (after selecting it, for convenience). Optional arg NO-MINI non-nil means don't apply PROC to the minibuffer even if it is active." (let* ((start (selected-window)) (current start) (done nil)) (while (not done) (select-window current) (funcall proc) (setq current (next-window current no-mini)) (setq done (eq current start))) (select-window start))) (defun count-windows (&optional no-mini) "Returns the number of visible windows. Optional arg NO-MINI non-nil means don't count the minibuffer even if it is active." (let ((count 0)) (walk-windows (function (lambda () (setq count (+ count 1)))) no-mini) count))