Several utilities to ease the pain of working with a single monitor
I. Enlarge one of two horizontally split windows
"Enlarge this window horizontally."
(interactive)
(enlarge-window-horizontally 20))
II. Flip flop: Move to other window and swap widths.
"Swap HORIZONTAL window sizes; move into the other window. This function
enables one to have two windows visible, but with one very narrow."
(interactive)
(let ((current-window-width (window-width))
(new-window-width nil)
(delta-window-width nil))
(other-window 1)
(setq new-window-width (window-width))
(setq delta-window-width (- current-window-width new-window-width))
(enlarge-window-horizontally delta-window-width)))
III. Flip flop vertically (like the above)
This version works with vertically split windows. This might work better in some cases. These utilities are minimal, written by a naive emacs user. I feel certain they can be modified and improved in various ways. I would like to find a way that the tool above, for horizontally split windows, can move back and forth, even when either or both sides is split into two or more windows vertically. They sky's the limit, but these utilities are simple, and therefore easy to use and remember.
"Swap window sizes; move into the other window. This function
enables one to have two windows visible, but with one reduced to two lines."
(interactive)
(let ((current-window-height (window-height))
(new-window-height nil)
(delta-window-height nil))
(other-window 1)
(setq new-window-height (window-height))
(setq delta-window-height (- current-window-height new-window-height))
(enlarge-window delta-window-height)))
IV. Swap positions of two windows with contents.
"Swap the positions of this window and the next one.
(credit to gildea Nov 88)"
(interactive)
(let ((other-window (next-window (selected-window) 'no-minibuf)))
(let ((other-window-buffer (window-buffer other-window))
(other-window-hscroll (window-hscroll other-window))
(other-window-point (window-point other-window))
(other-window-start (window-start other-window)))
(set-window-buffer other-window (current-buffer))
(set-window-hscroll other-window (window-hscroll (selected-window)))
(set-window-point other-window (point))
(set-window-start other-window (window-start (selected-window)))
(set-window-buffer (selected-window) other-window-buffer)
(set-window-hscroll (selected-window) other-window-hscroll)
(set-window-point (selected-window) other-window-point)
(set-window-start (selected-window) other-window-start))
(select-window other-window)))