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

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

Re: Help with windows and 'quit-restore


From: Eric Abrahamsen
Subject: Re: Help with windows and 'quit-restore
Date: Fri, 03 Mar 2017 11:27:42 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

martin rudalics <rudalics@gmx.at> writes:

>> Whatever the correct technical solution is, both the docs and the code
>> are pretty confusing. I think the key piece of missing information re
>> quit-restore is that, if there's a history of previously-displayed
>> buffers in this window, quitting the displayed buffer will display the
>> next buffer in the history. If there *isn't* such a history, quitting
>> the buffer will delete the window completely.
>>
>> (Is that always true? Are there any other factors that influence this
>> behavior?)
>
> I think it's true.

I found the root of the behavior that was making me think I was crazy.
Basically I'm trying to replicate the behavior of this call:

(display-buffer "some buffer" '(display-buffer-pop-up-window))

But in a way that I can reliably select which window gets split to show
the pop up. (I'd still rather just be using `display-buffer', but that's
a different subject.)

This should be the lower-level equivalent:

(let ((buf "*scratch*")
      (new-window
       (split-window (selected-window))))
  (set-window-buffer new-window buf)
  (display-buffer-record-window 'window new-window buf)
  (set-window-prev-buffers new-window nil))

But it doesn't kill the window after calling `quit-window'. This is
apparently because `quit-restore-window' decides whether or not to kill
the window by checking (window.el:4766):

(eq (nth 3 quit-restore) buffer)

There's no call to `get-buffer' anywhere down the line, so (nth 3
quit-restore) is a buffer string name, while buffer is a buffer object.
Ergo, no kill window. If I'd started with a `get-buffer' in the let form
above, all would have been well. `display-buffer' calls `get-buffer'
first thing, so you don't see it there.

I don't know if this is a bug -- I'm the one insisting on doing it
manually, after all -- but it also wouldn't hurt to put a `get-buffer'
in `display-buffer-record-window' and ensure that it's always a buffer
object that gets recorded in the quit-restore parameter.

Or maybe, because the buffer might get deleted at any time, allow a
string and improve the check in `quit-restore-window'?

Either way, I vote adding some sort of safety.

I'm still up for doc suggestions, once I'm confident I actually
understand what's happening.

Eric




reply via email to

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