emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Customizing how windows are split by display-buffer


From: Tassilo Horn
Subject: Re: Customizing how windows are split by display-buffer
Date: Mon, 19 Mar 2007 18:33:17 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux)

Hi Fredrik,

Hey, I had the same idea about a week ago and implemented it in elisp.

--8<---------------cut here---------------start------------->8---
(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)
--8<---------------cut here---------------end--------------->8---

But my function doesn't behave exactly like a "horizontalized"
`display-buffer', because it will always split if there's only one
window and never reuse the current window. That makes a difference for
e.g. `M-x info'.

I like this difference, but I was very surprised that there is no
standard way to tell emacs that I prefer horizontal splitting. In times
where most new computers have wide-screen displays your patch should
really be considered for inclusion, best before the release of Emacs 22.

Bye,
Tassilo
-- 
The glass is neither half-full nor half-empty: it's twice as big as it
needs to be.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]