I often have got multiple emacs frame in various desktop, but only two of them are visible. I often need to jump between those two frames, but since other frames are opened I can't use C-x 5 o, because it cycle among all of them.

For this purpose I wrote a code, which allows to jumps between two frames. If in frame1, then pressing C-c C-, the current line will be highlighted. Then, if in frame2, pressing C-c C-., the current line will be highlighted and the cursor will jump the other frame (removing the highlighting of that line).

A working example is portrayed in the gif.enter image description here

The code is the following. Can you help me to extend the behaviour I got also between windows and positions in the same file, not only frame? Thank you. Moreover I am not expert with lisp and I am sure that the amount of code can be shortened.

        (defun my-jumping-bookmark-jump(bookmark-name)
          (setq pop-up-frames t)
          (bookmark-jump-other-window bookmark-name)
          (setq pop-up-frames nil))

        (defun my-jumping-bookmark-set() (interactive)
               (defvar my-jumping-bookmark-alternator)
               (setq my-jumping-bookmark-alternator 0)
               (bookmark-delete "my-jumping-bookmark0")
               (bookmark-delete "my-jumping-bookmark1")
               (bookmark-set "my-jumping-bookmark0")
               (message "set"))

        (defun my-jumping-bookmark-switch() (interactive)
               (if (= (mod my-jumping-bookmark-alternator 2) 0)
                   (progn (bookmark-set "my-jumping-bookmark1")
;this does not jump between frames or windows, only between positions in the same buffer
                          ;; (bookmark-jump "my-jumping-bookmark0")
;this does not jump between windows or positions in the same buffer, only between frames
                          (my-jumping-bookmark-jump "my-jumping-bookmark0")
;I used this in the beginning, instead of bm-remove-all-current-buffer, so to remove the highlighting only in the current line, but there is a bug in bm so if you go to the last position in a buffer, the current line is not influenced by bm-toggle    
                          ;; (bm-toggle) 
                          (bookmark-delete "my-jumping-bookmark0")
                          (setq my-jumping-bookmark-alternator 1)
                          (message "switched to 1"))
                 (progn (bookmark-set "my-jumping-bookmark0")
                        ;; (bookmark-jump "my-jumping-bookmark1")
                        (my-jumping-bookmark-jump "my-jumping-bookmark1")
                        ;; (bm-toggle)
                        (bookmark-delete "my-jumping-bookmark1")
                        (setq my-jumping-bookmark-alternator 0)
                        (message "switched to 0"))))

        (global-set-key (kbd "C-c C-,") 'my-jumping-bookmark-set)
        (global-set-key (kbd "C-c C-.") 'my-jumping-bookmark-switch)

Finally, I want to thank the user who suggested me to use pop-up-frames, in this question.

  • This is the core of your question, and it's not clear (to me): "Can you help me to extend the behaviour I got also between windows and positions in the same file, not only frame?" Please consider specifying what behavior you are looking for exactly.
    – Drew
    Jan 30, 2018 at 14:42
  • @Drew basically I want to build a function which allows me to go back and forth between two visible buffers. First you call my-jumping-bookmark-set, then, when you call my-jumping-bookmark-switch, the focus moves to the previous buffer an so on. If the two buffers are in different frame and visible, my code words fine. But not if they belong to the same frame (in two visible windows). Neither it works if I call the two functions I defined from two locations of the same file.
    – Nisba
    Feb 2, 2018 at 2:12
  • So it sounds like you just want a command that switches back and forth between two windows. Is that it?
    – Drew
    Feb 2, 2018 at 15:11
  • @Drew basically
    – Nisba
    Feb 2, 2018 at 15:34

1 Answer 1


If I understand your question, I think ace-window does what you want. When you call the function ace-window, all of the visible windows (even on different frames) get a temporary label (letters or numbers). You press the key for the window you want to jump to. Here's an example from the project repository:

enter image description here

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.