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: Popping up a custom-shaped window compatible with quit-window Date: Mon, 12 Nov 2012 10:58:10 +0100 Message-ID: <50A0C832.9020708@gmx.at> References: <20638.53135.511315.127514@gargle.gargle.HOWL> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1352714325 24611 80.91.229.3 (12 Nov 2012 09:58:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Nov 2012 09:58:45 +0000 (UTC) Cc: emacs-devel@gnu.org To: Roland Winkler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 12 10:58:55 2012 Return-path: Envelope-to: ged-emacs-devel@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 1TXqn6-0002nb-TW for ged-emacs-devel@m.gmane.org; Mon, 12 Nov 2012 10:58:53 +0100 Original-Received: from localhost ([::1]:50659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXqmx-00023N-DD for ged-emacs-devel@m.gmane.org; Mon, 12 Nov 2012 04:58:43 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXqmr-0001n3-Kr for emacs-devel@gnu.org; Mon, 12 Nov 2012 04:58:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TXqmo-0006J2-IY for emacs-devel@gnu.org; Mon, 12 Nov 2012 04:58:37 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:33442) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TXqmo-0006Ip-9T for emacs-devel@gnu.org; Mon, 12 Nov 2012 04:58:34 -0500 Original-Received: (qmail invoked by alias); 12 Nov 2012 09:58:20 -0000 Original-Received: from 62-47-55-250.adsl.highway.telekom.at (EHLO [62.47.55.250]) [62.47.55.250] by mail.gmx.net (mp038) with SMTP; 12 Nov 2012 10:58:20 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18J6fA9S8oJgV4s7X4m5B60MuCZk7UagLmf47VoR1 wBxFVlqKNuqnqe In-Reply-To: <20638.53135.511315.127514@gargle.gargle.HOWL> X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 213.165.64.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154830 Archived-At: > BBDB uses the function bbdb-pop-up-window whenever it needs to pop > up a BBDB buffer. I have problems understanding `bbdb-pop-up-window'. What does (split-window-horizontally (if (integerp b-width) (- (window-width window) b-width) (round (* (- 1 b-width) (window-width window))))) (select-window (next-window window)) (let (pop-up-windows) (switch-to-buffer (get-buffer-create bbdb-buffer-name))) intend to do? IIUC (select-window (next-window window)) is supposed to select the window returned by `split-window-horizontally'. I'd rather (1) use the return value of the latter directly and (2) not select the window here. (let (pop-up-windows) (switch-to-buffer (get-buffer-create bbdb-buffer-name))) I'd remove the binding to `pop-up-windows' here and use plain `set-window-buffer' instead. If you need to select the new window you can do that afterwards. All this for Emacsen < 24. For Emacs 24 (where `display-buffer-record-window' is bound) do the same but also add a call like (display-buffer-record-window 'window window buffer) _before_ the `set-window-buffer' where WINDOW is the new window and BUFFER the buffer you want to display in it. This should record the necessary information for `quit-window'. For Emacs 24.3 it should be possible to use an alist entry with `display-buffer-pop-up-window' and `window-height' and/or `window-width' entries. Take, for example (defun bbdb-fix-width (window) (window-resize window -20 t)) (defun bbdb-fix-height (window) (window-resize window -10)) (display-buffer (get-buffer-create "*foo*") '(display-buffer-pop-up-window (window-width . bbdb-fix-width) (window-height . bbdb-fix-height))) with appropriately modified `bbdb-fix-height' and `bbdb-fix-width' functions (I was too lazy to figure them out here). In this case there's no need to record the window separately. Note that if `bbdb-fix-width' or `bbdb-fix-height' fail to resize the window appropriately, you have to live with the size supplied by `split-window'. If you don't like that, you have to write your own `split-window-preferred-function' and bind it around the `display-buffer' call. If you write your own `split-window-preferred-function', you can obviously also use it for earlier Emacsen - no window recording is needed in that case either. martin