From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: split-window-preferred-function Date: Sat, 22 Mar 2008 12:36:32 -0400 Message-ID: References: <47E188D5.5030502@gmx.at> <87hcf1rrdj.fsf@jurta.org> <87r6e3k3hc.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206203813 13086 80.91.229.12 (22 Mar 2008 16:36:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Mar 2008 16:36:53 +0000 (UTC) Cc: martin rudalics , emacs-devel To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 22 17:37:23 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 1Jd6ib-0004WY-0k for ged-emacs-devel@m.gmane.org; Sat, 22 Mar 2008 17:37:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jd6i0-0007LD-C2 for ged-emacs-devel@m.gmane.org; Sat, 22 Mar 2008 12:36:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jd6hw-0007Ke-N5 for emacs-devel@gnu.org; Sat, 22 Mar 2008 12:36:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jd6hu-0007KN-6w for emacs-devel@gnu.org; Sat, 22 Mar 2008 12:36:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jd6hu-0007KG-11 for emacs-devel@gnu.org; Sat, 22 Mar 2008 12:36:34 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jd6ht-00065g-Ne for emacs-devel@gnu.org; Sat, 22 Mar 2008 12:36:33 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApAFAOjR5EdMCrTo/2dsb2JhbACBW6Zn X-IronPort-AV: E=Sophos;i="4.25,539,1199682000"; d="scan'208";a="16397644" Original-Received: from smtp.pppoe.ca (HELO smtp.teksavvy.com) ([65.39.196.238]) by ironport2-out.teksavvy.com with ESMTP; 22 Mar 2008 12:36:33 -0400 Original-Received: from pastel.home ([76.10.180.232]) by smtp.teksavvy.com (Internet Mail Server v1.0) with ESMTP id CTG22633; Sat, 22 Mar 2008 12:36:33 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id E0FD17F5D; Sat, 22 Mar 2008 12:36:32 -0400 (EDT) In-Reply-To: <87r6e3k3hc.fsf@jurta.org> (Juri Linkov's message of "Sat, 22 Mar 2008 03:07:11 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:93188 Archived-At: >> I think we need to allow the function to return nil and in this case >> continue with the rest of the code. I.e. it should be possible to >> reproduce in Elisp what happens when split-window-preferred-function >> is nil. A good way to make sure that's true is to write the code in >> Elisp in the first place. > If I understand you correctly, this patch implements what you meant: Part of it, the missing parts: 1 - update the docstring of split_window_preferred_function. 2 - provide a non-nil default for split_window_preferred_function by moving the current C code that checks the size and calls split-window to Elisp. -- Stefan > 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 22 Mar 2008 01:07:04 -0000 > *************** > *** 3848,3853 **** > --- 3848,3859 ---- > else > window = Fget_largest_window (frames, Qt); > + if (!NILP (Vsplit_window_preferred_function)) > + tem = call1 (Vsplit_window_preferred_function, window); > + > + if (!NILP (tem)) > + window = tem; > + else > /* If the largest window is tall enough, full-width, and either eligible > for splitting or the only window, split it. */ > if (!NILP (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; > --- 3863,3869 ---- > || (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. */ > --- 3878,3884 ---- > || (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). > --- 7604,7610 ---- > 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/