GNU bug report logs -
#63967
28.2; switch-to-buffer in normal window fails if minibuffer window is active
Previous Next
Reported by: Al Petrofsky <al <at> petrofsky.org>
Date: Fri, 9 Jun 2023 04:10:02 UTC
Severity: normal
Found in version 28.2
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: Al Petrofsky <al <at> petrofsky.org>
> 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
This bug report was last modified 1 year and 340 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.