From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#63967: 28.2; switch-to-buffer in normal window fails if minibuffer window is active Date: Fri, 09 Jun 2023 14:16:17 +0300 Message-ID: <83o7lo28e6.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7076"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63967@debbugs.gnu.org To: Al Petrofsky , martin rudalics , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 09 16:37:39 2023 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 1q7dFC-0001aN-CQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 09 Jun 2023 16:37:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7a76-000894-F2; Fri, 09 Jun 2023 07:17:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7a75-00088w-21 for bug-gnu-emacs@gnu.org; Fri, 09 Jun 2023 07:17:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7a74-0008Ov-PW for bug-gnu-emacs@gnu.org; Fri, 09 Jun 2023 07:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q7a74-0004Gz-AA for bug-gnu-emacs@gnu.org; Fri, 09 Jun 2023 07:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Jun 2023 11:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63967 X-GNU-PR-Package: emacs Original-Received: via spool by 63967-submit@debbugs.gnu.org id=B63967.168630939416384 (code B ref 63967); Fri, 09 Jun 2023 11:17:02 +0000 Original-Received: (at 63967) by debbugs.gnu.org; 9 Jun 2023 11:16:34 +0000 Original-Received: from localhost ([127.0.0.1]:58479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7a6c-0004GC-9z for submit@debbugs.gnu.org; Fri, 09 Jun 2023 07:16:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7a6Z-0004Fw-Nn for 63967@debbugs.gnu.org; Fri, 09 Jun 2023 07:16:32 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7a6S-0008IY-1k; Fri, 09 Jun 2023 07:16:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=TUtqXOnYZtjbfAEQQDSQMBGaxKQHmjOrjfAUreu/tLQ=; b=XU9BAVud+5U4 yMS0l5r90++VhFM3sW7ck7snuGq13gjQkUyjPrfkPC4028tRUp3+TbQQ+yH7w3xbTdu4nyoWX8uSw XNEItE42xCacqBtY0QZ9jhLnMB8beFmh9fxMU1FLD5X3ByrUdu5AQbD1paz1GIJochG8Zw0jtstMv +dpDOaPm0lmfgOGwA5JEpdTrmf2Fpyjxe/dxHv9UXJbMp0CTz7XGGeMio1xKFb+aM6MN2m+R6A5Mm IiHb3NojZWmw34F9acl2roPSFKIkccfSbVJ89L4pNuxr3hNAZprR0PumltCJyJhj3putmJmUZE0yg qNBXynSDsxlw2DXKD1+42A==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7a6D-0004tg-C3; Fri, 09 Jun 2023 07:16:23 -0400 In-Reply-To: (message from Al Petrofsky on Thu, 8 Jun 2023 17:32:56 -0400) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263160 Archived-At: > From: Al Petrofsky > Date: Thu, 8 Jun 2023 17:32:56 -0400 > > While the minibuffer window is active, attempt to switch buffers in > an ordinary window like so: > > emacs -Q > M-: (setq enable-recursive-minibuffers t) RET > M-x C-x o C-x b foo RET > > In emacs 27 and earlier, that will switch the buffer in the main > window to the new buffer named "foo", but in emacs 28.2, it generates > a bogus "user-error: Cannot switch buffers in minibuffer window". Seems like read-buffer-to-switch (called by "C-x b") changes the selected-window: when it returns, the rest of the function runs with the minibuffer window being the selected-window, which is wrong in this case. I couldn't find the offending change, but I doubt that bisection would help us in this case, given how many water went under the bridge of using the minibuffer and saving/restoring the window configuration. The ugly kludge below seems to fix the problem. Stefan and Martin, any better ideas or hints? diff --git a/lisp/window.el b/lisp/window.el index a11b1a5..6777944 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8941,7 +8941,9 @@ switch-to-buffer "Cannot switch buffers in a dedicated window"))) ('pop nil) (_ (set-window-dedicated-p nil nil) 'force-same-window))))))) - (list (read-buffer-to-switch "Switch to buffer: ") nil force-same-window))) + (save-selected-window + (list + (read-buffer-to-switch "Switch to buffer: ") nil force-same-window)))) (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)) (set-window-start-and-point (not switch-to-buffer-obey-display-actions))) (cond