From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: `split-window-preferred-horizontally' Date: Sat, 07 Jun 2008 16:36:36 +0200 Message-ID: <484A9CF4.2050603@gmx.at> References: <87k5h28i23.fsf@localhorst.mine.nu> <4849B3D7.6090809@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030508010603030902090908" X-Trace: ger.gmane.org 1212849423 27288 80.91.229.12 (7 Jun 2008 14:37:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Jun 2008 14:37:03 +0000 (UTC) Cc: David Hansen , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 07 16:37:44 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K4zXj-0003oA-EP for ged-emacs-devel@m.gmane.org; Sat, 07 Jun 2008 16:37:19 +0200 Original-Received: from localhost ([127.0.0.1]:53841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K4zWw-0007SA-Dn for ged-emacs-devel@m.gmane.org; Sat, 07 Jun 2008 10:36:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K4zWs-0007Qe-68 for emacs-devel@gnu.org; Sat, 07 Jun 2008 10:36:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K4zWr-0007PU-7l for emacs-devel@gnu.org; Sat, 07 Jun 2008 10:36:25 -0400 Original-Received: from [199.232.76.173] (port=57331 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K4zWq-0007PJ-UH for emacs-devel@gnu.org; Sat, 07 Jun 2008 10:36:24 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:40813) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1K4zWq-0000Uc-5u for emacs-devel@gnu.org; Sat, 07 Jun 2008 10:36:24 -0400 Original-Received: (qmail invoked by alias); 07 Jun 2008 14:36:22 -0000 Original-Received: from 88-117-33-134.adsl.highway.telekom.at (EHLO [88.117.33.134]) [88.117.33.134] by mail.gmx.net (mp002) with SMTP; 07 Jun 2008 16:36:22 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19Lk3k3ff5LK1KM+QH2N1BmWm0fEVSk7X1jH+72RE 0utHUNyfD3uF2f User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:98588 Archived-At: This is a multi-part message in MIME format. --------------030508010603030902090908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > BTW, shouldn't `sensibly' be the default? > Or even the only acceptable setting (besides setting it to > a home-cooked function)? > I mean the nil value can be simulated with > > (setq split-width-threshold most-positive-fixnum) > > and the `horizontal' value can be emulated with > > (setq split-height-threshold most-positive-fixnum) > > If most-positive-fixnum is too inconvenient, we could accept a nil > setting for the thresholds to mean the same as most-positive-fixnum. Is the attached patch what you mean? There's yet no clever default for handling the height/width aspect ratio. --------------030508010603030902090908 Content-Type: text/plain; name="window.el.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="window.el.patch" *** window.el.~1.137.~ Fri Jun 6 10:01:10 2008 --- window.el Sat Jun 7 16:34:44 2008 *************** *** 741,771 **** :group 'windows) (defcustom split-window-preferred-function nil ! "How `display-buffer' shall split windows. ! Choices are `Vertically', `Horizontally', and `Sensibly' where ! the latter attempts to split wide windows horizontally, narrow ! ones vertically. Alternatively, you can set this to a function ! called with a window as single argument to split that window in ! two and return the new window." ! :type '(choice ! (const :tag "Vertically" nil) ! (const :tag "Horizontally" horizontally) ! (const :tag "Sensibly" sensibly) ! (function :tag "Function")) :version "23.1" :group 'windows) ! (defcustom split-height-threshold 80 ! "Minimum height of window to be split vertically by `display-buffer'. ! If there is only one window, it can be split regardless of this." :type 'number :version "23.1" :group 'windows) ! (defcustom split-width-threshold 160 ! "Minimum width of window to be split horizontally by `display-buffer'. ! If there is only one window, it can be split regardless of this." ! :type 'number :version "23.1" :group 'windows) --- 741,775 ---- :group 'windows) (defcustom split-window-preferred-function nil ! "Function for `display-buffer' to split windows. ! If non-nil a function called with a window as single argument to ! split that window in two and return the new window. If nil ! `display-buffer' will split the window according to the values of ! `split-height-threshold' and `split-width-threshold'." ! :type '(choice (const nil) (function :tag "Function")) :version "23.1" :group 'windows) ! (defcustom split-height-threshold nil ! "Minimum height of window to be split vertically. ! If the value is a number `display-buffer' can split a window only ! if it has at least as many lines. If the value is nil ! `display-buffer' cannot split the window vertically. If the ! window is the only window on its frame it can be split regardless ! of this value." ! :type '(choice (const :tag "inhibit" nil) ! (number :tag "lines")) :type 'number :version "23.1" :group 'windows) ! (defcustom split-width-threshold nil ! "Minimum width of window to be split horizontally. ! If the value is a number `display-buffer' can split a window only ! if it has at least as many columns. If the value is nil ! `display-buffer' cannot split the window horizontally." ! :type '(choice (const :tag "inhibit" nil) ! (number :tag "columns")) :version "23.1" :group 'windows) *************** *** 780,787 **** - `window-size-fixed' is either nil or equals `width' for the buffer of WINDOW. ! - WINDOW is at least as high as `split-height-threshold' or it is ! the only window on its frame. - When WINDOW is split evenly, the emanating windows are at least `window-min-height' lines tall and can accomodate at least one --- 784,790 ---- - `window-size-fixed' is either nil or equals `width' for the buffer of WINDOW. ! - WINDOW is at least as high as `split-height-threshold'. - When WINDOW is split evenly, the emanating windows are at least `window-min-height' lines tall and can accomodate at least one *************** *** 805,861 **** ;; and at least twice as wide as `window-min-width' and 2 (the ;; latter value is hardcoded). (and (memq window-size-fixed '(nil height)) (>= (window-width window) (max split-width-threshold (* 2 (max window-min-width 2))))) ;; A window can be split vertically when its height is not ! ;; fixed, it is at least `split-height-threshold' lines high or ! ;; the only window on its frame, and it is at least twice as ! ;; high as `window-min-height' and 2 if it has a modeline or 1. (and (memq window-size-fixed '(nil width)) (>= (window-height window) ! (max (if (one-window-p 'nomini) 0 split-height-threshold) (* 2 (max window-min-height (if mode-line-format 2 1)))))))))) (defun window--try-to-split-window (window) "Split window WINDOW if it is splittable. ! See `split-window-preferred-function' for how WINDOW shall be ! split. See `window--splittable-p' for how to determine whether a ! window is splittable. If WINDOW can be split, return the value ! returned by `split-window' or `split-window-preferred-function'." (when (and (window-live-p window) ;; Testing `window-full-width-p' here hardly makes any ;; sense nowadays. This can be done more intuitively by ;; setting up `split-width-threshold' appropriately. (not (frame-parameter (window-frame window) 'unsplittable))) ! (or (and (not split-window-preferred-function) ! (window--splittable-p window) (split-window window)) ! (and (eq split-window-preferred-function 'horizontally) ! (window--splittable-p window t) (split-window window nil t)) ! (and (eq split-window-preferred-function 'sensibly) ! ;; The following naive aspect-ratio test should become ! ;; more sensible. ! (or (and (> (window-width window) (window-height window)) ! (window--splittable-p window t) ! (split-window window nil t)) ! (and (window--splittable-p window) ! (split-window window)))) (and (functionp split-window-preferred-function) (funcall split-window-preferred-function window))))) (defun window--frame-usable-p (frame) "Return frame FRAME if it can be used to display another buffer." ! (let ((window (frame-root-window frame))) ! ;; `frame-root-window' may be an internal window which is considered ! ;; "dead" by `window-live-p'. Hence if `window' is not live we ! ;; implicitly know that `frame' has a visible window we can use. ! (when (or (not (window-live-p window)) ! (and (not (window-minibuffer-p window)) ! (not (window-dedicated-p window)))) ! frame))) (defcustom even-window-heights t "If non-nil `display-buffer' will try to even window heights. --- 808,861 ---- ;; and at least twice as wide as `window-min-width' and 2 (the ;; latter value is hardcoded). (and (memq window-size-fixed '(nil height)) + (numberp split-width-threshold) (>= (window-width window) (max split-width-threshold (* 2 (max window-min-width 2))))) ;; A window can be split vertically when its height is not ! ;; fixed, it is at least `split-height-threshold' lines high, ! ;; and it is at least twice as high as `window-min-height' and 2 ! ;; if it has a modeline or 1. (and (memq window-size-fixed '(nil width)) + (numberp split-height-threshold) (>= (window-height window) ! (max split-height-threshold (* 2 (max window-min-height (if mode-line-format 2 1)))))))))) (defun window--try-to-split-window (window) "Split window WINDOW if it is splittable. ! See `window--splittable-p' for how to determine whether a window ! is splittable. If WINDOW can be split, return the value returned ! by `split-window' or `split-window-preferred-function'." (when (and (window-live-p window) ;; Testing `window-full-width-p' here hardly makes any ;; sense nowadays. This can be done more intuitively by ;; setting up `split-width-threshold' appropriately. (not (frame-parameter (window-frame window) 'unsplittable))) ! (or (and (window--splittable-p window) (split-window window)) ! (and (window--splittable-p window t) (split-window window nil t)) ! (and (with-selected-window window ! (one-window-p 'nomini)) ! (let ((split-height-threshold 0)) ! (window--splittable-p window) ! (split-window window))) (and (functionp split-window-preferred-function) (funcall split-window-preferred-function window))))) (defun window--frame-usable-p (frame) "Return frame FRAME if it can be used to display another buffer." ! (when (framep frame) ! (let ((window (frame-root-window frame))) ! ;; `frame-root-window' may be an internal window which is considered ! ;; "dead" by `window-live-p'. Hence if `window' is not live we ! ;; implicitly know that `frame' has a visible window we can use. ! (when (or (not (window-live-p window)) ! (and (not (window-minibuffer-p window)) ! (not (window-dedicated-p window)))) ! frame)))) (defcustom even-window-heights t "If non-nil `display-buffer' will try to even window heights. --------------030508010603030902090908--