I've seen the https://www.emacswiki.org/emacs/buffer-move.el script, but I'm trying to something a bit different. Suppose I have a frame with a buffer from file A.h in it and A.cpp in another frame somewhere else. If I currently have A.h selected and try to open A.cpp from it (using either C-x C-f or projectile open), I would want the frames containing A.h and A.cpp to simply swap buffers with each other. Is there a library or something that already does this? I'm trying to do it myself based on buffer-move.el, but I can't find any of the hooks I need or the ability to search for a frame containing a buffer with a specific name.

  • Several years ago I spent quite a bit of time playing with frames and buffers and eventually settled upon a modified version of Alp Aker's frame-bufs that associate buffers with frames. There is an option to associate or disassociate, or at least there is in my modified version. I have never played with the swapper-oo idea -- instead, I just associate or disassociate whatever buffers I need. I also have a display-buffer-alist function that associates certain file types with specified frames. I've taken it one step further and tied it in with a modified version of tabbar ... associating.
    – lawlist
    Jun 12, 2019 at 5:13
  • @lawlist @Drew While these ideas are interesting, I think that my use case is slightly different. I usually have a static frame layout and like to reference frames on the right while editing whatever is in the middle frame. Hence wanting to swap a right frame out for the middle. The problem with move-buffer is that I need to select the frame with arrow keys (or movement keys if I redo the keybindings), which isn't as fast for me as just opening a file or switching the buffer.
    – iHowell
    Jun 13, 2019 at 14:52
  • Here is a link to a related thread where the accepted answer states that the library ace-window can swap buffers in windows within the same frame or in different frames -- "How to swap buffers between two frames?": emacs.stackexchange.com/questions/38505/…
    – lawlist
    Jun 13, 2019 at 16:02

1 Answer 1


Do you really need the buffers to swap frames? Or would it be enough to just select (move the focus to) the frame of the buffer you want to use?

For that, just C-x 4 b if pop-up-frames is non-nil, or C-x 5 b if it is nil.

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.