From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) Newsgroups: gmane.emacs.help Subject: Re: First split horizontally, and then vertically Date: Wed, 12 Aug 2015 12:45:42 -0400 Message-ID: <87si7oh2vd.fsf@yale.edu> References: <8737zoimzx.fsf@yale.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: ger.gmane.org 1439397959 7064 80.91.229.3 (12 Aug 2015 16:45:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2015 16:45:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 18:45:49 2015 Return-path: Envelope-to: geh-help-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 1ZPZ9x-000089-9p for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 18:45:49 +0200 Original-Received: from localhost ([::1]:39495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZ9w-0001IF-Rd for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 12:45:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZ85-0006p4-KY for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 12:43:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPZ7z-00010k-Ar for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 12:43:53 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:60293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZ7z-00010c-4I for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 12:43:47 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZPZ7x-0007DG-8Q for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 18:43:45 +0200 Original-Received: from 130.132.236.141 ([130.132.236.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Aug 2015 18:43:45 +0200 Original-Received: from jorge.alfaro-murillo by 130.132.236.141 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Aug 2015 18:43:45 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 130.132.236.141 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:vqVyK2Oqxn5YhsPX+kvdouvlGY4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106510 Archived-At: 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.