If I have only one emacs frame, and I open files A, B, C, and then press C-x b and switch to A, then press again and switch to B, from then on every time I press C-x b ENTER, I will alternate between A and B buffers. But if I have two emacs frames, where the second frame has B open, and then I repeat the procedure in the first frame, instead of alternating A and B as expected it will alternate A and C. The fact that B is open in the other frame prevents C-x b ENTER from toggling back and forth from B.

It's as if emacs assumes I can't possibly mean to open the same file twice in two different frames, but I use winpoint.el specifically to make sure buffer positions are remembered per window instead of per buffer, because it's handy to have multiple views into large files.

Is there a way to make sure C-x b ENTER always toggle back and forth between the last visited buffer and current? I'm using ivy currently but IIRC this behavior happens even without it.

  • 1
    One workaround is to create two windows in the original frame, displaying buffers A and B and just switch windows instead.
    – NickD
    Commented Mar 29 at 15:01

1 Answer 1


I looked at the documentation and code for the function switch-to-buffer (bound to C-x b), which calls read-buffer-to-switch which calls other-buffer which is written in C... It seems rather complex (at least too complex for me!). It seems that the buffer "B" is indeed in the first elements of the (buffer-list) of the current frame's buffer but switch-to-buffer will skip it.

Anyway there is a workaround.

I'm using the (old) module "cycle-buffer": https://www.emacswiki.org/emacs/cycle-buffer.el

When I type C-TAB, "cycle-buffer" will cycle in the buffer list and propose at first the buffer "B" even if it's open in another frame.

So, with "cycle-buffer", C-TAB will always toggle back and forth between the last visited buffer and current one, which is not exactly the same as, but quite close to what you asked for.

There is a lot of modules to cycle through buffers (icycle cycbuf...), so you may find another one which meets your needs better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.