What I do is to use a mechanism for switching buffers with a global most-recently-used list (not the per-window list of next-buffer
/previous-buffer
).
- Switch from B1 to any other buffer B3 in frame 1.
- Focus frame 2 and switch from B2 to the most recently used buffer, which is B1.
- Focus frame 1 and switch from B3 to the most recently used buffer, which is B2.
This works with windows as well as frames.
I use a custom buffer switching mechanism with its own global MRU list, but I'm sure there are packages for that. You may be able to do it with iswitchb/ido, but by default, if you ask to switch to a buffer that's visible in a frame, they switch to the frame in question, which wouldn't do you any good.
With built-in features, there's a MRU list in ibuffer
. It isn't bound to a key by default; it's one of my primary ways to switch buffers and I have it on F9. With Ibuffer, you don't even need the third buffer.
- Move the focus from frame 1 to frame 2 (without focusing any other Emacs frame in between).
M-x ibuffer RET
(or keyboard shortcut), navigate to the second buffer line (M-< 4 SPC
, or just SPC
or down
if this is the first time you use Ibuffer) and switch to it with RET
.
- Move the focus back to frame 1,
M-x ibuffer RET
(or keyboard shortcut), and RET
(the cursor is still on the second buffer, and that's the one you just left in the other frame).
This works for windows as well, you just have to navigate between windows without focusing an intermediate window.