How can I move focus from currently focused frame to a neighboring frame-- e.g. right next frame-- via a keyboard shortcut? I'd like to cycle through frames in "z" direction. If I had frames a to h like below on my desktop

  a   b  c
d  e  f  

g       h 

I'd like to move in the order of a, b, c, d, e, f, g, h, then go back to a and repeat.

  • This sounds tricky, the position of frames is typically the responsibility of the window manager.
    – icarus
    Dec 27, 2016 at 2:31
  • You could select them by letter or by number -- see the following example: stackoverflow.com/a/26922594/2112489
    – lawlist
    Dec 27, 2016 at 2:42
  • 1
    On another thought, the top and left coordinates of each frame parameter can be used to create a custom answer. TOP: (cdr (assq 'top (frame-parameters (selected-frame)))) and LEFT: (cdr (assq 'left (frame-parameters (selected-frame)))) -- cycle through the frame-list with something like mapc or mapcar. And, there is a means of obtaining the bounds -- frame-geometry might be helpful with respect to the outer-size.
    – lawlist
    Dec 27, 2016 at 3:31

4 Answers 4


There is an inherent order of the visible frames, but it does not coincide with any particular user-wished order. To cycle through frames in that inherent order you can use command other-frame (C-x 5 o).

To move through frames in an arbitrary order that you choose, you would need to create a list or alist of them in that order, and cycle through it.

If you use Icicles then you can at least choose a frame by its name, using completion, with command icicle-select-frame (bound to C-x 5 o in Icicle mode).

And you can sort the completion candidates in various ways, and then cycle through candidates in that sort order. You can also define your own sort orders, so if you have a set layout of frames then you can use a custom sort order than cycles through them in the order you want.


This isn't what you're actually asking for, but framemove lets you switch focus to the next frame in a specified direction from the current frame, exactly like windmove lets you select another window by direction.

It also works beautifully as an extension of windmove, so that you use the same keybindings for both (moving between frames when there is no window in the given direction).


I wrote this and put it at:


It adds select-next-frame and select-prev-frame commands bound to C-x 5 n and C-x 5 p.

  • I've read though your code but I'm still learning elisp. Would you please add some specific details about how and why your code will help resolve the question? Thanks!
    – Melioratus
    Oct 25, 2017 at 23:04
  • 1
    The select-next-frame command moves focus from currently focused frame to a neighboring frame-- e.g. right next frame-- via the keyboard shortcut C-x 5 n. If you have frames a to h like shown above in the original post and you would like to move in the order of a, b, c, d, e, f, g, h, then go back to a and repeat, you'd use the select-next-frame command defined in frame-movement.el. Oct 26, 2017 at 0:43

ace-window provides quick access to any window. By default all windows in all frames are available, so you can use it to jump to any frame. It requires one extra keypress than what you asked for - it doesn't cycle through frames in a fixed order, you have to pick the frame you're moving to.

Basic use is M-x ace-window K, where K is a single letter corresponding to one of the available windows. When you call ace-window, each window is temporarily labeled with a letter, so you can see which letter gets you to the window you want.

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.