Subject: Re: bug#45848: 27.1; Buffers menu opens wrong buffer

From: martin rudalics <[email-masked]>
Date: Thu, 14 Jan 2021 08:40:59 +0100

> In recent versions of GTK Emacs with multiple frames open, selecting the
 > top buffer from the Buffers menu often opens the wrong buffer.  Upon
 > returning to the Buffers menu, the top item has changed to the one that
 > actually opened.  Selecting the desired file from the menu again opens the
 > correct file as expected.
 >
 > The Buffers menu on each frame appears to be the same but in reality the
 > order is different.  When one frame is in focus but you click on the
 > Buffers menu of an unfocused frame it will show the Buffers for the
 > focused menu.  If you close the menu and reclick, the focus will have
 > changed and it will show the correct Buffers menu.
 >
 > I belive the problem is that the Buffers menu opens before the frame focus
 > changes causing the wrong Buffers list to display for the frame.

I always disable the Buffers menu here so I can't tell whether there was
a noticeable change recently.  The function responsible for providing
that menu ('menu-bar-update-buffers') uses the global buffer list - not
the one specific for that menu bar's frame.  This means that
conceptually the menu will show the same list regardless from where you
invoke it unless that invoking step itself changes the global buffer
list beforehand.  Now selecting a frame is one way to change it, popping
up a menu from the menu bar should not change it.

So the first issue we'd have to resolve is what the "correct Buffers
menu" is.  The second issue, and that is one that should never happen,
is that apparently Emacs switches to another buffer than the one whose
name you clicked on.  Maybe someone else has an idea how such a thing
could occur in practice.

martin