Is there any command like other-frame which behaves like windows's Alt-TAB? And how to create this command?

To clarify this behavior, I wrote python code which virtually emulate this behavior. Each elements of frame_lst are frames. The first element of the frame_lst is the currently selected frame. With Alt being pressed, pressing TAB N times move the index which shows which frame will be selected, and after releasing TAB and Alt the frame of index'th element of frame_lst is selected and focused, then change the order of the elements of frame_lst to make recently selected frame become first element of the frame_lst.

  • Emulation Program (virtual_alt_tab.py)

    def init_environment():
        global frame_lst, index
        index = 0
        frame_lst = ['f1', 'f2', 'f3', 'f4']
    def on_alt_tab_pressed():
        global frame_lst, index
        index += 1
        index = index%len(frame_lst)
    def on_alt_tab_released():
            global frame_lst, index
            frame_lst.insert(0, frame_lst.pop(index))
            index = 0
    def hit_alt_tab_n_times(n):
        global frame_lst
        print('==== Before hitting Alt-TAB ====')
        for _ in range(n):
        print('==== After hitting alt-TAB consecutively %d times ===='%n)
    # test 1
    print('\n================ test 1 ================')
    # test 2
    print('\n================ test 2 ================')
    # test 3
    print('\n================ test 3 ================')
  • Output

    ================ test 1 ================
    ==== Before hitting Alt-TAB ====
    ['f1', 'f2', 'f3', 'f4']
    ==== After hitting alt-TAB consecutively 1 times ====
    ['f2', 'f1', 'f3', 'f4']
    ================ test 2 ================
    ==== Before hitting Alt-TAB ====
    ['f1', 'f2', 'f3', 'f4']
    ==== After hitting alt-TAB consecutively 2 times ====
    ['f3', 'f1', 'f2', 'f4']
    ================ test 3 ================
    ==== Before hitting Alt-TAB ====
    ['f1', 'f2', 'f3', 'f4']
    ==== After hitting alt-TAB consecutively 3 times ====
    ['f4', 'f1', 'f2', 'f3']

I found related article.


According to this article Emacs can't detect the release event of the Alt key. So I need another mechanics which complement this. I think pressing C-g will complement this, but I don't know how to detect C-g after Alt-TAB pressed repeatedly.

  • Please specify the behavior you're looking for, instead of just saying "like window's ALT-TAB". Some of those who might be able to help might not know just what that behavior is or which part(s) of it you're looking for.
    – Drew
    Commented Apr 4, 2019 at 16:51
  • Maybe use (frame-list) to get the list of existing frames, and exclude (selected-frame) from that, then increment a pointer into that list (as a ring). Use ring-convert-sequence-to-ring to convert a list to a ring, then ring-next etc.
    – Drew
    Commented Apr 4, 2019 at 16:58
  • @Drew: I added the program which virtually emulate the behavior. But Converting this program to lisp and implement C-g detection(see bottom of my question) is long way for me. I almost gave up. Commented Apr 5, 2019 at 11:01
  • Sorry, I meant only to please describe MS Windows's ALT-TAB behavior in this context, for people unfamiliar with it. I didn't mean that you needed to show code (e.g. Python) for it.
    – Drew
    Commented Apr 5, 2019 at 14:57
  • @Drew: It is just writing code is more faster and precise than writing in English in my case. I just write this code in my iPhone while eating my launch. So No need for sorry :) Commented Apr 5, 2019 at 15:14

1 Answer 1


The function other-frame, bound to C-x 5 o by default, moves you to the next frame, and calling it repeatedly will cycle you through all available frames. As I recall, that's what Alt-tab does?

ace-window might also be useful for you. See this answer: https://emacs.stackexchange.com/a/46587/262

  • Yes, Alt-TAB cycles frames. I'm currently using Mac and has familiar function(Command-TAB). To clarify the behavior I added the program which virtually emulate it. But I almost gave up. Commented Apr 5, 2019 at 11:13

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.