There are at least a couple of packages dedicated to moving buffers around within a frame (buffer-move and transpose-frame are the ones I'm aware of), but I don't seem to be able to find anything to swap buffers between two frames. Does anyone have a nice way of doing this?

I primarily use emacs on OSX but would think there should be a good generic solution to this.

  • Not an answer to your question, but you may wish to consider targeting the correct frame when the buffer is created. It is also possible to associate the buffer with the desired frame and add/remove any buffers from the associated buffer list for a particular frame. The reason I mention that is because it sounds like you may be trying to remedy a problem created by the desired buffer being displayed in the undesired frame. And, of course, buffers can be simultaneously displayed in multiple frames if so desired.
    – lawlist
    Commented Jan 31, 2018 at 19:42
  • @lawlist Yes, that's a good suggestion. The primary use case (for me) for such functionality, though, is when I have two buffers open in to frames and for whatever reason want to switch the proximity of one to some other window for a particular task. This is usually a temporary/dynamic situation.
    – Turn
    Commented Jan 31, 2018 at 19:48
  • Depending on what you really need, you might consider swapping the frame locations instead.
    – Drew
    Commented Jan 31, 2018 at 21:49

2 Answers 2


Check out ace-window.

From the GitHub link, after invoking ace-window, you can press m, and then the key corresponding to the window you want to swap the current window with (across or within frames). Under the hood, this is just swapping buffers between the two windows.


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).

  1. Switch from B1 to any other buffer B3 in frame 1.
  2. Focus frame 2 and switch from B2 to the most recently used buffer, which is B1.
  3. 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.

  1. Move the focus from frame 1 to frame 2 (without focusing any other Emacs frame in between).
  2. 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.
  3. 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.

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.