From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#52491: 28.0.90; Regression in window deletion with minibuffer Date: Fri, 17 Dec 2021 10:25:52 +0200 Organization: LINKOV.NET Message-ID: <86tuf73aen.fsf@mail.linkov.net> References: <865yrqsxmu.fsf@mail.linkov.net> <865yro7csh.fsf@mail.linkov.net> <83h7b8fngd.fsf@gnu.org> <86v8zo4bma.fsf@mail.linkov.net> <83fsqsfh8i.fsf@gnu.org> 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="35847"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 52491@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 17 09:34:20 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 1my8h2-0009Aa-0J for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Dec 2021 09:34:20 +0100 Original-Received: from localhost ([::1]:44448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1my8h0-0000Gm-TL for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Dec 2021 03:34:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1my8gm-0000Ef-3o for bug-gnu-emacs@gnu.org; Fri, 17 Dec 2021 03:34:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1my8gl-0004bZ-S7 for bug-gnu-emacs@gnu.org; Fri, 17 Dec 2021 03:34:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1my8gl-0001bv-PM for bug-gnu-emacs@gnu.org; Fri, 17 Dec 2021 03:34:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Dec 2021 08:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52491 X-GNU-PR-Package: emacs Original-Received: via spool by 52491-submit@debbugs.gnu.org id=B52491.16397300096116 (code B ref 52491); Fri, 17 Dec 2021 08:34:03 +0000 Original-Received: (at 52491) by debbugs.gnu.org; 17 Dec 2021 08:33:29 +0000 Original-Received: from localhost ([127.0.0.1]:37881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my8gD-0001aZ-6f for submit@debbugs.gnu.org; Fri, 17 Dec 2021 03:33:29 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:44039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my8gA-0001a7-7s for 52491@debbugs.gnu.org; Fri, 17 Dec 2021 03:33:26 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 368681C000F; Fri, 17 Dec 2021 08:33:18 +0000 (UTC) In-Reply-To: <83fsqsfh8i.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 16 Dec 2021 22:05:17 +0200") 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:222552 Archived-At: --=-=-= Content-Type: text/plain >> > And the patch you proposed earlier doesn't fix this other problem? >> >> Unfortunately, it doesn't fix this, since 28.0.90 uses mru, >> but 27.2 didn't. > > FWIW, I don't see any catastrophe here: whoever plays such games with > switching windows during completion should know what they are doing, > and how to switch back to the minibuffer. Anyway, here is the patch for the release branch that fixes the previous regression: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=delete-window.patch diff --git a/lisp/window.el b/lisp/window.el index 0f17bb28b4..0a422b4305 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2531,14 +2531,15 @@ get-lru-window (setq best-window window))))) (or best-window second-best-window))) -(defun get-mru-window (&optional all-frames dedicated not-selected no-other) +(defun get-mru-window (&optional all-frames dedicated not-selected no-other minibuf) "Return the most recently used window on frames specified by ALL-FRAMES. -A minibuffer window is never a candidate. A dedicated window is -never a candidate unless DEDICATED is non-nil, so if all windows -are dedicated, the value is nil. Optional argument NOT-SELECTED -non-nil means never return the selected window. Optional +A dedicated window is never a candidate unless DEDICATED is non-nil, +so if all windows are dedicated, the value is nil. Optional argument +NOT-SELECTED non-nil means never return the selected window. Optional argument NO-OTHER non-nil means to never return a window whose -'no-other-window' parameter is non-nil. +'no-other-window' parameter is non-nil. A minibuffer window is never +a candidate when MINIBUF is nil or omitted. MINIBUF t means consider +the minibuffer window only if the minibuffer is active. The following non-nil values of the optional argument ALL-FRAMES have special meanings: @@ -2556,7 +2557,7 @@ get-mru-window Any other value of ALL-FRAMES means consider all windows on the selected frame and no others." (let (best-window best-time time) - (dolist (window (window-list-1 nil 'nomini all-frames)) + (dolist (window (window-list-1 nil (unless minibuf 'nomini) all-frames)) (setq time (window-use-time window)) (when (and (or dedicated (not (window-dedicated-p window))) (or (not not-selected) (not (eq window (selected-window)))) @@ -4205,6 +4206,7 @@ delete-window (let* ((frame (window-frame window)) (function (window-parameter window 'delete-window)) (parent (window-parent window)) + (choose-selected delete-window-choose-selected) atom-root) (window--check frame) (catch 'done @@ -4255,7 +4257,7 @@ delete-window ;; Can't do without resizing fixed-size windows. (window--resize-siblings window (- size) horizontal t))) - (when (eq delete-window-choose-selected 'pos) + (when (eq choose-selected 'pos) ;; Remember edges and position of point of the selected window ;; of WINDOW'S frame. (setq frame-selected-window-edges @@ -4289,9 +4291,9 @@ delete-window ;; Select window at WINDOW's position at point. (set-frame-selected-window frame new-frame-selected-window))))) - ((and (eq delete-window-choose-selected 'mru) + ((and (eq choose-selected 'mru) ;; Try to use the most recently used window. - (let ((mru-window (get-mru-window frame nil nil t))) + (let ((mru-window (get-mru-window frame nil nil t t))) (and mru-window (set-frame-selected-window frame mru-window))))) ((and (window-parameter diff --git a/lisp/simple.el b/lisp/simple.el index 84928caa31..73c5840e02 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9252,6 +9278,7 @@ completion-setup-function (setq-local completion-base-position base-position) (setq-local completion-list-insert-choice-function insert-fun)) (setq-local completion-reference-buffer mainbuf) + (setq-local delete-window-choose-selected 'mru) (if base-dir (setq default-directory base-dir)) (when completion-tab-width (setq tab-width completion-tab-width)) --=-=-=--