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

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

bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly f


From: martin rudalics
Subject: bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly functions
Date: Wed, 25 Mar 2015 09:23:49 +0100

>> Then how comes you "eventually end up with three side-by-side windows
>> each of size 86x82"?
>
> No, I don't end up with that.  If I had the split function I imagined,
> then I would end up with that configuration.  So that's the goal I want
> to achieve but for which I have no solution.

I see.  I thought there was some black magic involved when I read your
first post ;-)

>> By default you should get one window with 135 columns and two windows
>> with 67 columns, approximately.
>
> Indeed, that's what I get with C-x 3 C-x 3 starting from a single window
> of size 269x82 and the default value of `window-combination-resize' and
> `window-combination-limit'.
>
> With
>
>    (setq window-combination-resize t
>          window-combination-limit nil)
>
> two consecutive C-x 3 starting from the big single window results in
> three side-by-side *balanced* windows, each being 86x82 large.  That's
> actually what I wanted.  However, I'd like that this splitting behavior
> was the default for `display-buffer'.  But that fails because after the
> first horizontal split, `window-splittable-p' says that both horizontal
> windows aren't horizontally splittable anymore because they are narrower
> than `split-width-threshold'.

If you set `split-width-threshold' to zero and `split-height-threshold'
to nil you should get the behavior you want.

> I've come up with a solution which seems to fit my preferences quite
> nicely although it's probably quite hackish and ignores possible
> contracts that might exist for dedicated windows, fixed-size windows,
> side windows and what else there might be.

You should be able to simplify your code by using idioms from the below.

(defun th/split-window-sensibly (_window)
  (let ((root (frame-root-window))
        (window-combination-resize 'resize))
    (cond
     ((>= (/ (window-total-width root) (window-combinations root t)) 80)
      (split-window (window-last-child root) nil 'right))
     ((>= (/ (window-total-height root) (window-combinations root)) 40)
      (split-window (window-last-child root) nil 'below))
     (t
      (split-window-sensibly window)))))

martin





reply via email to

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