I normally use Emacs in fullscreen mode. When I split a window horizontally I get 2 side-by-side windows and each is about 95 columns wide. But by default all pop-up-windows like completion or compilation buffers split the window vertically. mulligan pointed me to the variable display-buffer-function on the #emacs IRC channel. It should be a function symbol which will be called instead of display-buffer. In that function the user can manage the splitting and assigning of buffers to windows on his own.
I came up with this function, which makes a fullscreen emacs much more convenient and behaves like the default if emacs is not wide enough for 2 side-by-side windows that are at least 80 columns wide each.
(defun th-display-buffer (buffer force-other-window) "If BUFFER is visible, select it. If it's not visible and there's only one window, split the current window and select BUFFER in the new window. If the current window (before the split) is more than 165 columns wide, split horizontally, else split vertically. If the current buffer contains more than one window, select BUFFER in the least recently used window. This function returns the window which holds BUFFER. FORCE-OTHER-WINDOW is ignored." (or (get-buffer-window buffer) (if (one-window-p) (let ((new-win (if (> (window-width) 165) (split-window-horizontally) (split-window-vertically)))) (set-window-buffer new-win buffer) new-win) (let ((new-win (get-lru-window))) (set-window-buffer new-win buffer) new-win)))) (setq display-buffer-function 'th-display-buffer)
For the functions exact behavior see its docstring.
UPDATE: Fredrik Axelsson created a patch which adds a new variable prefer-window-split-horizontally. See his message on gmane.emacs.pretest.bugs. The patch is delayed at least till the release of Emacs 22.