From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.help Subject: Re: Help with windows and 'quit-restore Date: Wed, 01 Mar 2017 08:10:06 +0100 Message-ID: <58B673CE.9030605@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1488352263 3280 195.159.176.226 (1 Mar 2017 07:11:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 1 Mar 2017 07:11:03 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: eric@ericabrahamsen.net Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 01 08:10:57 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 1ciyPV-0008J3-JA for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Mar 2017 08:10:53 +0100 Original-Received: from localhost ([::1]:38829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciyPb-0007hv-EK for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Mar 2017 02:10:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciyPB-0007hp-0c for help-gnu-emacs@gnu.org; Wed, 01 Mar 2017 02:10:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciyP6-0002vo-2N for help-gnu-emacs@gnu.org; Wed, 01 Mar 2017 02:10:32 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:63472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ciyP5-0002vL-MJ for help-gnu-emacs@gnu.org; Wed, 01 Mar 2017 02:10:27 -0500 Original-Received: from [192.168.1.100] ([213.162.68.90]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LlV71-1c8XS42eSl-00bJL1; Wed, 01 Mar 2017 08:10:15 +0100 Original-References: 87shmz86x6.fsf@ericabrahamsen.net X-Provags-ID: V03:K0:3VfGQLQQGJSOdtjr3OClDqRXVadSRcnbF/1isUN9vJ0AAmSVueP PR8EW14nVw1Vt3cCZZSib4PxqC86PPZdrRqe5IyfCgBAL04/Aq+MoQDMcHeZphp4cYuDTXu /jnps7EjHr0NujO2JBZ53kgH7J9CD6sR66AJjBOjCGlwnPmUnXfmZfi7zmPN9SSsl/A28Sn o9HhNymANq3q0GgYwe2hw== X-UI-Out-Filterresults: notjunk:1;V01:K0:ccSq/K6BP34=:OJk72yp3f826MzzAGz6lyf yka0HbKSpzSNdKOWDHg1JMC7Wa97IQBHgwj4CuG8mWGdQFcosG2yCeU1Qxt5wft7h5efXZeTS dsAueDPf1KyeF/wmJ/YPZbKC97CqxPAHmXkfS3HM6dJRwbBXcmg4atemC1Sl45/h3qEsG6T31 1pAbN4CWnKpkcWfu+/UF0DD/4hTA/0MTIlnEP6nJm5oiwMuSWbWejkYW8xkgHUtAdDM8baLc3 CfycxZgHx6OQyGl2na9TUdFeewOKrRJ10aewBV7ydxpn1sw/7yUAVzLJ0f2YJPEQDuxuGwxDi VAbx8hGtGQNscogBdtZcZwBWQPtf28uA+3ZM0Q2liGcSLj0KpfI6NxamfprrF1NpwIU0rdH6w 5zFHwWsxt79VY2EPI+z+RFdlmzoLGhu3bSS2bRqmLCXo17SKjJQptjCGReUIMJ53fPAjcTKTZ oxFOGMl2mvfM1HZg7TmRxsdGf8dJg8mekQtIfAGd9uEMxFmbTE/7WWDwYCjCNFMD0Lss9Up1T +rFXSDn7ELY9oSQXANecPXiuj6KPia7PTk6G9SUu34mvRg3m5ZsD6Goe4mhsjgLD3QWv38x94 mhQ5C9f5F8klaagrfMzmsV1v/ha+9lBkSGHQanYkj4t7Q6PVfp08CW+IFBJTyUgHT3+4TS2nP WKh7YWOQovhibN8anAgJ/EiX3xoHLoTHbwCmCUwIcN9LC1QS2XTVbmor5SCIoxnRe/L1xAy17 V1KQ4isrZUCBcjz03+dndTWFR5Q1wVGyBVVmAymlgLGlmKZv7fF7XT9tzdxMlDQEFv5aBG7L X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.18 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:112400 Archived-At: > 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 t= o > 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 Do these 0.5 mean that you have advised =E2=80=98split-window=E2=80=99? > '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, jus= t > 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 u= p > the `quit-restore parameter correctly: when I hit "q" in the buffer, t= he > buffer quits but the popped-up window remains, displaying some other > buffer, usually a copy of a buffer that's already visible. It does set up the =E2=80=98quit-restore=E2=80=99 parameter correctly. T= he one missing piece is that you didn't clear the new window's previous buffers by doing something like (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) (set-window-prev-buffers buffer-window nil)) This is a technical issue I can't solve at a lower level: When Emacs creates a new window, it first displays the buffer displayed in the selected window in that new window and that buffer becomes the first "previous" buffer of the new window. So the new window ("buffer-window" in your parlance) already showed a buffer _before_ it did show the buffer you specify by `get-buffer-I-want-to-pop-up=C2=B4. In order to ma= ke =E2=80=98quit-window=E2=80=99 do what you mean, you have to clear that re= membrance first. I'll probably add a sentence about this to the doc-string of =E2=80=98display-buffer-record-window=E2=80=99 although there will be no = warranty that that function will always work outside the scope of =E2=80=98display-buff= er=E2=80=99. martin