From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: pillule Newsgroups: gmane.emacs.bugs Subject: bug#48367: 28.0.50; quit-restore-window may jam Date: Wed, 12 May 2021 11:25:51 +0000 Message-ID: <87v97o42io.fsf@host.localdomain> References: <87h7j9xbj3.fsf@host.localdomain> <13f5a988-f78b-11ed-fcde-fc03ad841390@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1558"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pillule , 48367@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 12 13:29:45 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgn3g-0000Ht-08 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 May 2021 13:29:44 +0200 Original-Received: from localhost ([::1]:56854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgn3d-0001ju-U0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 May 2021 07:29:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgn15-0006jW-KN for bug-gnu-emacs@gnu.org; Wed, 12 May 2021 07:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgn14-00009X-JT for bug-gnu-emacs@gnu.org; Wed, 12 May 2021 07:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lgn14-0006Lh-Ez for bug-gnu-emacs@gnu.org; Wed, 12 May 2021 07:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: pillule Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 May 2021 11:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48367 X-GNU-PR-Package: emacs Original-Received: via spool by 48367-submit@debbugs.gnu.org id=B48367.162081876824320 (code B ref 48367); Wed, 12 May 2021 11:27:02 +0000 Original-Received: (at 48367) by debbugs.gnu.org; 12 May 2021 11:26:08 +0000 Original-Received: from localhost ([127.0.0.1]:38287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgn0C-0006K9-9S for submit@debbugs.gnu.org; Wed, 12 May 2021 07:26:08 -0400 Original-Received: from mx1.riseup.net ([198.252.153.129]:56552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgn09-0006Ja-As for 48367@debbugs.gnu.org; Wed, 12 May 2021 07:26:07 -0400 Original-Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4FgCCW4nSczDxX9; Wed, 12 May 2021 04:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1620818759; bh=VcBLy0c5fhA28fVkgSChmM23Y8XSf1ycLcdyANR+9Eo=; h=References:From:To:Cc:Subject:In-reply-to:Date:From; b=Nz/xzRlpQK4iPWuO9m71BmWLH2vTaqyZxKVsliD8Ff4o3hMopO845MDcam/HQAwKb uLceRMMAJ76jRc5XxP0j0e+DMXkgzrLGTMS4Z5/Cf6d4hhgKnLWsgIolWr4QS07RVd 9ysRN9Ld4HHg/wGJY635pOhR2NUSe3iQ0qS8P4bs= X-Riseup-User-ID: 88C5EC57608A4D2E93D09B6D6C2F6A1767CB5E2C2D61C7F7379E45E0CC4F569D Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4FgCCV0y7Wz5vqb; Wed, 12 May 2021 04:25:57 -0700 (PDT) In-reply-to: <13f5a988-f78b-11ed-fcde-fc03ad841390@gmx.at> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206312 Archived-At: --=-=-= Content-Type: text/plain; format=flowed martin rudalics writes: >> The first patch adress this, and a similar one : when there is >> a previous-buffer available, but it referes to the same buffer. >> (eg: try the recipe again but exchange the role of *Messages* >> and *Backtrace*, you will finish with a blank buffer for >> backtrace, that you can quit again to end up to the same point) >> >> The second patch is a proposition to clarify a little the code. > > LGTM. Can you please provide a ChangeLog entry and add a short > comment > in the code that mentions the bug number of your report. Looking at the CONTRIBUTE file, I have done this new version with `git format-patch -l1', Is that overall better ? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=quit-restore-window.patch Content-Description: reformated-patchs >From b0e58a68a2f67b3ef2b2467f6473929fc6a720e9 Mon Sep 17 00:00:00 2001 From: Trust me I am a doctor Date: Wed, 12 May 2021 10:23:39 +0000 Subject: [PATCH 1/2] Unjam quit-restore-window (bug #48367) Deleting previous buffers of a window may result in a state where quit-window have no more effect, using the variable `prev-buffer', we can avoid it by asking to simply close the window in this case. --- lisp/window.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/window.el b/lisp/window.el index db62d3308f..24b5df3396 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5114,7 +5114,10 @@ nil means to not handle the buffer in a particular way. This (set-window-parameter window 'quit-restore nil) ;; Make sure that WINDOW is no more dedicated. (set-window-dedicated-p window nil) - (switch-to-prev-buffer window bury-or-kill))) + (if prev-buffer + (switch-to-prev-buffer window bury-or-kill) + ;; delete the window if there is no previous-buffer (bug #48367) + (window--delete window nil (eq bury-or-kill 'kill))))) ;; Deal with the buffer. (cond -- 2.20.1 >From 55ec1b7a2ba50be0b55cc32601a88ec554c19034 Mon Sep 17 00:00:00 2001 From: Trust me I am a doctor Date: Wed, 12 May 2021 10:34:40 +0000 Subject: [PATCH 2/2] Clarifying code of quit-restore-window Still (bug #48367) This portion may be expressed more succinctly with an higher function. --- lisp/window.el | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index 24b5df3396..a530761028 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5036,14 +5036,9 @@ nil means to not handle the buffer in a particular way. This (setq window (window-normalize-window window t)) (let* ((buffer (window-buffer window)) (quit-restore (window-parameter window 'quit-restore)) - (prev-buffer - (let* ((prev-buffers (window-prev-buffers window)) - (prev-buffer (caar prev-buffers))) - (and (or (not (eq prev-buffer buffer)) - (and (cdr prev-buffers) - (not (eq (setq prev-buffer (cadr prev-buffers)) - buffer)))) - prev-buffer))) + (prev-buffer (car (cl-find-if-not + (lambda (buf) (eq (car buf) buffer)) + (window-prev-buffers window)))) quad entry) (cond ((and (not prev-buffer) -- 2.20.1 --=-=-= Content-Type: text/plain; format=flowed Is that OK to call a cl-lib function in the second patch even if this library is not required in window.el ? > Also, have you signed the copyright agreement for Emacs? How > should I > call you in the commit? "pillule"? No, I have not yet signed the agreement, I contact assign@gnu.org today to do so. I was hoping sloppily that you consider these contributions as trivial. If it is fine for you to use my pseudonym, it is fine for me. -- --=-=-=--