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: Tue, 14 Dec 2021 23:08:09 +0200 Organization: LINKOV.NET Message-ID: <865yrqsxmu.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28072"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) To: 52491@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 14 22:11:15 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 1mxF4s-00077k-VV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Dec 2021 22:11:14 +0100 Original-Received: from localhost ([::1]:33240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxF4r-0000Js-39 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Dec 2021 16:11:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxF4g-0000JU-TG for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 16:11:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxF4g-0001Ao-Jn for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 16:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mxF4g-0007vT-9O for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 16:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Dec 2021 21:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52491 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.163951626030457 (code B ref -1); Tue, 14 Dec 2021 21:11:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Dec 2021 21:11:00 +0000 Original-Received: from localhost ([127.0.0.1]:59766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxF4e-0007v6-2V for submit@debbugs.gnu.org; Tue, 14 Dec 2021 16:11:00 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:34894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxF4c-0007uw-8y for submit@debbugs.gnu.org; Tue, 14 Dec 2021 16:10:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxF4c-0000JC-5e for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 16:10:58 -0500 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:56273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxF4Z-0001AC-VI for bug-gnu-emacs@gnu.org; Tue, 14 Dec 2021 16:10:57 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id DE888240004 for ; Tue, 14 Dec 2021 21:10:53 +0000 (UTC) Received-SPF: pass client-ip=217.70.178.230; envelope-from=juri@linkov.net; helo=relay10.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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:222396 Archived-At: emacs-28 -Q M-x ;; execute-extended-command ;; minibuffer-complete ;; switch-to-completions q ;; quit-window Point moves to the *scratch* buffer. This is a regression. In emacs-27 it moved to the minibuffer. The problem is that delete-window now uses get-mru-window to get the window to select after deleting the completions window. But get-mru-window ignores the minibuffer window. This could be fixed by: diff --git a/lisp/window.el b/lisp/window.el index 0f17bb28b4..507eaab705 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2556,7 +2556,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 nil 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)))) Maybe better to add a new argument to get-mru-window and pass it down to window-list-1. This problem exists for the default value 'mru' of delete-window-choose-selected. When its value is customized to 'pos' then the *scratch* buffer is selected too, but for a different reason. In this case, the *scratch* buffer is selected instead of the minibuffer because frame coordinates of point that was previously in the completions window now belongs to the window of the *scratch* buffer that now takes screen space previously used by completions. To prevent this, maybe completion-setup-function should set buffer-local delete-window-choose-selected to 'mru' in the completions buffer: diff --git a/lisp/simple.el b/lisp/simple.el index 0a58297bd2..08932c689a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9256,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)) diff --git a/lisp/window.el b/lisp/window.el index 0f17bb28b4..507eaab705 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4205,6 +4205,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 +4256,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,7 +4290,7 @@ 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))) (and mru-window --