emacs-devel
[Top][All Lists]
Advanced

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

Re: split-window-preferred-function


From: Juri Linkov
Subject: Re: split-window-preferred-function
Date: Sun, 23 Mar 2008 04:16:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

> 2 - provide a non-nil default for split_window_preferred_function
>     by moving the current C code that checks the size and calls
>     split-window to Elisp.

I tried to follow the current C code as close as possible, and the
result is the function `split-window-preferred-horizontally' below.
It is intended to be set as an option of `split-window-preferred-function'.
Then the other option for it should be nil that will continue the
standard processing of vertical splitting.

There is a comment in cus-start.el that says:

                      ;; FIXME: Add `sensibly' which chooses between
                      ;; vertical or horizontal splits depending on the size
                      ;; and shape of the window.

So `split-window-preferred-sensibly' could be implemented later too
as a similar function.

(defcustom split-width-threshold 100
  "A window must be at least this wide to be eligible for splitting
by `display-buffer'.  The value is in line units.
If there is only one window, it is split regardless of this value."
  :type 'integer
  :group 'windows)

(defun split-window-preferred-horizontally (window)
  (interactive)
  (if (and window
           (not (frame-parameter (window-frame window) 'unsplittable))
           (window-full-width-p window)
           (>= (window-width window) split-width-threshold)
           (>= (window-width window) (* 2 window-min-width)))
      (split-window window nil 'horiz)
    (get-lru-window)))

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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