From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Help with windows and 'quit-restore Date: Fri, 03 Mar 2017 11:27:42 -0800 Message-ID: <874lzajh3l.fsf@ericabrahamsen.net> References: <58B72B70.7080606@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1488572230 32021 195.159.176.226 (3 Mar 2017 20:17:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2017 20:17:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 03 21:17:06 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjtdL-0006x2-Ao for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2017 21:16:59 +0100 Original-Received: from localhost ([::1]:60095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjtdP-0008ME-RA for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2017 15:17:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjtcz-0008Lx-1H for help-gnu-emacs@gnu.org; Fri, 03 Mar 2017 15:16:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjtcv-000539-1p for help-gnu-emacs@gnu.org; Fri, 03 Mar 2017 15:16:37 -0500 Original-Received: from [195.159.176.226] (port=46774 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjtcu-00052u-RW for help-gnu-emacs@gnu.org; Fri, 03 Mar 2017 15:16:32 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cjtch-0003DU-RP for help-gnu-emacs@gnu.org; Fri, 03 Mar 2017 21:16:19 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:WjCEuw3JKY/dxPiT6h6wPLLqKXs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112417 Archived-At: martin rudalics 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