[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: First split horizontally, and then vertically
From: |
Jorge A. Alfaro-Murillo |
Subject: |
Re: First split horizontally, and then vertically |
Date: |
Wed, 12 Aug 2015 12:45:42 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Alexander Shukaev writes:
which values should I put into
(setq-default split-width-threshold ?)
(setq-default split-height-threshold ?)
so that Emacs first splits windows horizontally (until the
limit) and only then splits them vertically.
I also prefer vertical splitting, I have it set up so that no
windows are split horizontally unless I do it myself:
#+BEGIN_SRC emacs-lisp
(setq split-height-threshold nil)
(setq split-width-threshold 150)
#+END_SRC
You can also try setting split-height-threshold to 0, to make a
vertical split more likely than a horizontal one.
That's the problem. I've tried this already, and as soon as I
have some integer (0, for example) in `split-height-threshold'
the first split by `split-window-sensibly' is vertical one
I think the problem is the way that split-window-sensibly works,
it first checks if the window is at least split-height-threshold
lines tall, if it is then it splits horizontally, if it is not
then it checks if the window is at least split-width-threshold
columns wide to split vertically. You want the opposite to happen.
You should look at the code of split-window-sensibly and make your
own function, one that first checks split-width-threshold. Then
you should set split-window-preferred-function to that function.
This is not tested but could work:
#+BEGIN_SRC emacs-lisp
(defun split-window-more-sensibly (&optional window)
(let ((window (or window (selected-window))))
(or (and (window-splittable-p window t)
;; Split window horizontally.
(with-selected-window window
(split-window-right)))
(and (window-splittable-p window)
;; Split window vertically.
(with-selected-window window
(split-window-below)))
(and (eq window (frame-root-window (window-frame window)))
(not (window-minibuffer-p window))
;; If WINDOW is the only window on its frame and is
not the
;; minibuffer window, try to split it vertically
;; disregarding the value of
`split-height-threshold'.
(let ((split-height-threshold 0)) (when
(window-splittable-p window)
(with-selected-window window
(split-window-below))))))))
(setq split-window-preferred-function
'split-window-more-sensibly)
#+END_SRC
--
Jorge.