From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: split-window-preferred-function Date: Fri, 21 Mar 2008 01:02:27 +0200 Organization: JURTA Message-ID: <87hcf1rrdj.fsf@jurta.org> References: <47E188D5.5030502@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206055118 6424 80.91.229.12 (20 Mar 2008 23:18:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Mar 2008 23:18:38 +0000 (UTC) Cc: emacs-devel To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 21 00:19:08 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 1JcU2K-00040d-FX for ged-emacs-devel@m.gmane.org; Fri, 21 Mar 2008 00:19:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JcU1j-0001Ni-RH for ged-emacs-devel@m.gmane.org; Thu, 20 Mar 2008 19:18:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JcU0L-0008IH-Or for emacs-devel@gnu.org; Thu, 20 Mar 2008 19:17:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JcU0K-0008GM-1d for emacs-devel@gnu.org; Thu, 20 Mar 2008 19:17:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JcU0J-0008GA-Ss for emacs-devel@gnu.org; Thu, 20 Mar 2008 19:16:59 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JcU0I-0002Wj-S7 for emacs-devel@gnu.org; Thu, 20 Mar 2008 19:16:59 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JcU05-0002dv-Sg; Fri, 21 Mar 2008 01:16:46 +0200 In-Reply-To: <47E188D5.5030502@gmx.at> (martin rudalics's message of "Wed, 19 Mar 2008 22:42:45 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 0a40947aa5a9674afbdd30b0de777e4b X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2450 [Mar 20 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 11 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) 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:93082 Archived-At: > `split-window-preferred-function' appears half-baked: In > `display-buffer' its calls are preceded by things like > > && (window_height (window) >= split_height_threshold > ... > && (window_height (window) > >= (2 * window_min_size_2 (XWINDOW (window), 0)))) > > Set to some horizontal splitting function, splitting will be wrongly > rejected when the original window is not sufficiently high and wrongly > accepted when the window is not wide enough. Hence it seems that we > need something like `split-width-threshold' and a way to detect how > `split-window-preferred-function' is going to split the window in order > to know which of our checks should be applied. Maybe a function in `split-window-preferred-function' should take care of all these conditions to decide how to split within a given window configuration? This means we could remove `split-window' from the default value of `split-window-preferred-function', and then check in `display-buffer' if `split-window-preferred-function' is non-nil, then call it without checking any condition. Otherwise, call `split-window', i.e. exactly as it was implemented before introducing `split-window-preferred-function'. The following patch implements this (note that checking for non-nil Vsplit_window_preferred_function is not necessary in the else-branch because when Vsplit_window_preferred_function is called unconditionally it never reaches this else-branch with the second place where Fsplit_window is called). Index: src/window.c =================================================================== RCS file: /sources/emacs/emacs/src/window.c,v retrieving revision 1.604 diff -c -w -b -r1.604 window.c *** src/window.c 19 Mar 2008 15:18:29 -0000 1.604 --- src/window.c 20 Mar 2008 22:01:17 -0000 *************** *** 3850,3855 **** --- 3850,3858 ---- /* If the largest window is tall enough, full-width, and either eligible for splitting or the only window, split it. */ + if (!NILP (Vsplit_window_preferred_function)) + window = call1 (Vsplit_window_preferred_function, window); + else if (!NILP (window) && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) && WINDOW_FULL_WIDTH_P (XWINDOW (window)) *************** *** 3857,3863 **** || (NILP (XWINDOW (window)->parent))) && (window_height (window) >= (2 * window_min_size_2 (XWINDOW (window), 0)))) ! window = call1 (Vsplit_window_preferred_function, window); else { Lisp_Object upper, other; --- 3860,3866 ---- || (NILP (XWINDOW (window)->parent))) && (window_height (window) >= (2 * window_min_size_2 (XWINDOW (window), 0)))) ! window = Fsplit_window (window, Qnil, Qnil); else { Lisp_Object upper, other; *************** *** 3872,3878 **** || (NILP (XWINDOW (window)->parent))) && (window_height (window) >= (2 * window_min_size_2 (XWINDOW (window), 0)))) ! window = call1 (Vsplit_window_preferred_function, window); else window = Fget_lru_window (frames, Qnil); /* If Fget_lru_window returned nil, try other approaches. */ --- 3875,3881 ---- || (NILP (XWINDOW (window)->parent))) && (window_height (window) >= (2 * window_min_size_2 (XWINDOW (window), 0)))) ! window = Fsplit_window (window, Qnil, Qnil); else window = Fget_lru_window (frames, Qnil); /* If Fget_lru_window returned nil, try other approaches. */ *************** *** 7598,7604 **** to split windows horizontally or vertically or some mix of the two. It is called with a window as single argument and should split it in two and return the new window. */); ! Vsplit_window_preferred_function = intern ("split-window"); DEFVAR_INT ("window-min-height", &window_min_height, doc: /* *Delete any window less than this tall (including its mode line). --- 7601,7607 ---- to split windows horizontally or vertically or some mix of the two. It is called with a window as single argument and should split it in two and return the new window. */); ! Vsplit_window_preferred_function = Qnil; DEFVAR_INT ("window-min-height", &window_min_height, doc: /* *Delete any window less than this tall (including its mode line). -- Juri Linkov http://www.jurta.org/emacs/