all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Tassilo Horn <tsdh@gnu.org>
Cc: 20189@debbugs.gnu.org
Subject: bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly functions
Date: Wed, 25 Mar 2015 09:23:49 +0100	[thread overview]
Message-ID: <55127095.2010703@gmx.at> (raw)
In-Reply-To: <87384ubfwj.fsf@gnu.org>

 >> 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	other threads:[~2015-03-25  8:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24  9:18 bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly functions Tassilo Horn
2015-03-24 10:51 ` martin rudalics
2015-03-24 11:39   ` Tassilo Horn
2015-03-24 13:30     ` martin rudalics
2015-03-24 14:59       ` Tassilo Horn
2015-03-25  8:23         ` martin rudalics [this message]
2015-03-25  9:41           ` Tassilo Horn
2015-03-26 10:58             ` martin rudalics
2015-03-26 11:01             ` Tassilo Horn
2015-03-26 13:47               ` martin rudalics
2015-03-26 14:18                 ` Stefan Monnier
2015-03-26 14:31                   ` martin rudalics
2015-03-27 18:26                     ` Stefan Monnier
2015-03-26 15:15                 ` Tassilo Horn
2015-03-26 16:04                   ` martin rudalics
2015-03-24 17:05 ` Eli Zaretskii
2015-03-25  7:00   ` Tassilo Horn
2015-03-25  8:24     ` martin rudalics
2015-03-25 17:25     ` Eli Zaretskii
2015-03-25 19:33       ` Tassilo Horn
2015-03-25 19:38         ` Eli Zaretskii
2015-03-26  4:27           ` Tassilo Horn
2015-03-26 10:58             ` martin rudalics
2015-03-26 16:29             ` Eli Zaretskii
2015-03-25  8:23   ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55127095.2010703@gmx.at \
    --to=rudalics@gmx.at \
    --cc=20189@debbugs.gnu.org \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.