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-buffer may jam Date: Tue, 11 May 2021 20:26:08 +0000 Message-ID: <87h7j9xbj3.fsf@host.localdomain> 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="37154"; mail-complaints-to="usenet@ciao.gmane.io" To: 48367@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 11 22:27:24 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 1lgYyR-0009Tp-9L for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 22:27:23 +0200 Original-Received: from localhost ([::1]:57838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgYyP-0003kU-C4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 16:27:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgYy6-0003il-Tw for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 16:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgYy6-00046u-Lh for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 16:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lgYy6-00036w-Ip for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 16: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: Tue, 11 May 2021 20:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48367 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162076478511908 (code B ref -1); Tue, 11 May 2021 20:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 May 2021 20:26:25 +0000 Original-Received: from localhost ([127.0.0.1]:37600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgYxV-000360-14 for submit@debbugs.gnu.org; Tue, 11 May 2021 16:26:25 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgYxT-00035s-Hk for submit@debbugs.gnu.org; Tue, 11 May 2021 16:26:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgYxT-0002tS-AZ for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 16:26:23 -0400 Original-Received: from mx1.riseup.net ([198.252.153.129]:49406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgYxR-0003cb-0T for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 16:26:22 -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 4FfqFQ53zWzDxXW for ; Tue, 11 May 2021 13:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1620764778; bh=ua5r690v+PiTfXk678b4+rhuCxGMjW58GV5diF33i80=; h=From:To:Subject:Date:From; b=n+NCKo0IumoJ7dmeJgTMAbVJNbRueY1CCd0NY5ljZCU58hi3Bul99cmJ9NIox/LKa 9eG21K7vUU5smrGsZzRQu8PgpWl7SEWN3W83/TwLsEdE/vKJ3REwJF225CekEMi+YZ R3QOzyStl6Wimerm6CFZGTBwCiEPjWEcB5vZOA0Y= X-Riseup-User-ID: A844B4E9461AFF5AD33DE3608D22CD2D8C9B3B4D455BD35F4562D48AF6E60366 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4FfqFP2mNHz5vbR for ; Tue, 11 May 2021 13:26:16 -0700 (PDT) Received-SPF: pass client-ip=198.252.153.129; envelope-from=pillule@riseup.net; helo=mx1.riseup.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:206293 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Hello there, I think there is a small bug with quit-window / quit-restore-window : with emacs -Q ;; set some rules (setq display-buffer-alist '(("\\*\\(Backtrace\\|Messages\\)\\*" (display-buffer-in-side-window) (window-height . 0.2) (side . bottom)))) ;; trigger a logical error to display the *Backtrace* buffer (> vim emacs) ;; display the *Messages* buffer (view-echo-area-messages) ;; mess the `quit-restore' window parameter (kill-buffer (get-buffer "*Backtrace*")) ;; which looks now like that in the *Messages* window : ;; ((quit-restore) (window-slot . 0) (window-side . bottom)) ;; try to quit the *Messages* window (progn (select-window (view-echo-area-messages)) (quit-window)) ;; nothing happens : The first `cond' of quit-restore-window end up to 't, it calls (switch-to-prev-buffer window bury-or-kill) but there is no previous-window available. 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=quit-restore-window.patch Content-Description: quit-restore-window-patch1 diff -u --label /usr/share/emacs/28.0.50/lisp/window.el.gz --label /home/user/src/patches/window.el /tmp/jka-comHlW7wF /home/user/src/patches/window.el --- /usr/share/emacs/28.0.50/lisp/window.el.gz +++ /home/user/src/patches/window.el @@ -5151,7 +5151,9 @@ (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) + (window--delete window nil (eq bury-or-kill 'kill))))) ;; Deal with the buffer. (cond Diff finished. Tue May 11 21:26:38 2021 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=quit-restore-window2.patch Content-Description: quit-restore-window-patch2 diff -u --label /usr/share/emacs/28.0.50/lisp/window.el.gz --label /home/user/src/patches/window.el /tmp/jka-comAXCNZa /home/user/src/patches/window.el --- /usr/share/emacs/28.0.50/lisp/window.el.gz +++ /home/user/src/patches/window.el @@ -5073,14 +5073,9 @@ (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) Diff finished. Tue May 11 22:00:30 2021 --=-=-= Content-Type: text/plain; format=flowed -- --=-=-=--