From: martin rudalics <rudalics@gmx.at>
To: Roland Winkler <winkler@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Popping up a custom-shaped window compatible with quit-window
Date: Mon, 12 Nov 2012 10:58:10 +0100 [thread overview]
Message-ID: <50A0C832.9020708@gmx.at> (raw)
In-Reply-To: <20638.53135.511315.127514@gargle.gargle.HOWL>
> 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
next prev parent reply other threads:[~2012-11-12 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-10 22:05 Popping up a custom-shaped window compatible with quit-window Roland Winkler
2012-11-12 9:58 ` martin rudalics [this message]
2012-11-13 2:41 ` Roland Winkler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50A0C832.9020708@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=winkler@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).