From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#20189: 25.0.50; Feature request: Alternative split-window-sensibly functions Date: Wed, 25 Mar 2015 09:23:49 +0100 Message-ID: <55127095.2010703@gmx.at> References: <87iodqbvoz.fsf@gnu.org> <551141AC.40003@gmx.at> <87egoebp60.fsf@gnu.org> <551166DE.9070007@gmx.at> <87384ubfwj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1427271937 18381 80.91.229.3 (25 Mar 2015 08:25:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Mar 2015 08:25:37 +0000 (UTC) Cc: 20189@debbugs.gnu.org To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 25 09:25:20 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yagci-0004im-Cz for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 09:25:12 +0100 Original-Received: from localhost ([::1]:36756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yagch-0004Ad-N7 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Mar 2015 04:25:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yagcd-00048S-QI for bug-gnu-emacs@gnu.org; Wed, 25 Mar 2015 04:25:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YagcZ-0001Mn-5X for bug-gnu-emacs@gnu.org; Wed, 25 Mar 2015 04:25:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YagcZ-0001MX-26 for bug-gnu-emacs@gnu.org; Wed, 25 Mar 2015 04:25:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YagcY-0005SQ-OF for bug-gnu-emacs@gnu.org; Wed, 25 Mar 2015 04:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Mar 2015 08:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20189 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20189-submit@debbugs.gnu.org id=B20189.142727184820868 (code B ref 20189); Wed, 25 Mar 2015 08:25:02 +0000 Original-Received: (at 20189) by debbugs.gnu.org; 25 Mar 2015 08:24:08 +0000 Original-Received: from localhost ([127.0.0.1]:35582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YagbZ-0005Q2-Uh for submit@debbugs.gnu.org; Wed, 25 Mar 2015 04:24:08 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:57198) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YagbX-0005Pj-U0 for 20189@debbugs.gnu.org; Wed, 25 Mar 2015 04:24:00 -0400 Original-Received: from [178.189.204.62] ([178.189.204.62]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LlV4F-1ZAqy643J1-00bHvW; Wed, 25 Mar 2015 09:23:54 +0100 In-Reply-To: <87384ubfwj.fsf@gnu.org> X-Provags-ID: V03:K0:1pXN8A5fNgdZRirkZ7mhPS9ulzFDKPsD/e9CH2RueGA8/PTZwsH +YpMwFwGrr+N1ApHyNVvCGine+uJ8usieRQuHk9Y4gCWHC86AZURvN0dynetTQpKA5B3QrT 03OLksqWLkW0icPDTFpKkCwhDAEA3oEJBB66lRiFHiwixxfAOo1oqW0vfbTAPHxvc+Ejd04 DRVsKtJgtKOqwkW8OBslg== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:100917 Archived-At: >> 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