[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Popping up a custom-shaped window compatible with quit-window

From: martin rudalics
Subject: Re: Popping up a custom-shaped window compatible with quit-window
Date: Mon, 12 Nov 2012 10:58:10 +0100

> 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

                         (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 

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 

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))

 (get-buffer-create "*foo*")
   (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]