help-gnu-emacs
[Top][All Lists]
Advanced

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

Help with windows and 'quit-restore


From: Eric Abrahamsen
Subject: Help with windows and 'quit-restore
Date: Mon, 27 Feb 2017 17:01:41 -0800
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0 (gnu/linux)

I'm having a heck of a time understanding how the 'quit-restore window
parameter actually works.

I've got a pop-up window that goes into special-mode, and I'm trying to
get the right level of control over both the window splitting, and the
behavior of "q" (quit-window).

First it was the "manual way":

#+BEGIN_SRC elisp
(let* ((buf (get-buffer-I-want-to-pop-up))
       (window (get-window-I-want-to-split))
       (buffer-window (split-window window 0.5
                                    'right)))
  (set-window-buffer buffer-window buf)
  (display-buffer-record-window 'window buffer-window buf))
#+END_SRC

The SIZE and SIDE args to `split-window' are calculated elsewhere, just
hard-coded in my cut-down example. This allows me to split windows
exactly as I want.

This call to `display-buffer-record-window', however, does *not* set up
the `quit-restore parameter correctly: when I hit "q" in the buffer, the
buffer quits but the popped-up window remains, displaying some other
buffer, usually a copy of a buffer that's already visible.

I can get a perfect 'quit-restore with the "automatic way":

#+BEGIN_SRC elisp
(display-buffer
 buf
 `(display-buffer-pop-up-window . ((window-height . 0.5))))
#+END_SRC

Again, cut down to show the final effect. This gives me exactly the
quit-restore behavior I want, but the window splitting is erratic: Emacs
tries to DTRT, but it isn't TRT, and no amount of fiddling with the
`split-*-threshold' variables works. It's forever splitting the wrong
window, or splitting it the wrong way.

So I think what I want is to stick with the former incantation, but learn
how to call `display-buffer-record-window' correctly. I followed
`display-buffer-pop-up-window' as far as I could, but really can't see
how it builds its 'quit-restore.

Can anyone point me to the correct call for that? Or reveal some better
solution to the problem?

Thanks,
Eric




reply via email to

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