Article View: comp.emacs
Article #8320Re: GNU Emacs POLL: where should killed window space go?
From: Eric L. Raible
Date: Wed, 18 Jan 1989 02:19
Date: Wed, 18 Jan 1989 02:19
43 lines
2177 bytes
2177 bytes
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))
Technical Details
Message-ID:
<1369@amelia.nas.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!agate!eos!amelia!orville.nas.nasa.gov!raibleReferences:
<8901120359.AA07667@wheat-chex.ai.mit.edu> <8758@bloom-beacon.MIT.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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