Moses
Moses

Reputation: 327

Emacs switch to the next window regardless of frame

I'd like for the C-x o command (next window) to include windows in other frames as well as windows in the current frame.

Does anyone know how to pull this off? Is there another command that I should be using? Is there some snippet of elisp magic that can do this with ease?

Upvotes: 6

Views: 1317

Answers (8)

Vines world
Vines world

Reputation: 1

Nowadays, there is a different command you can use which does exactly what you want:

(global-set-key (kbd "C-x o") 'next-window-any-frame)

Upvotes: 0

Drew
Drew

Reputation: 30701

You say "Is there a way to cycle through windows regardless of what frame they're in? That's really what I'm looking for?"

Yes, there is, with Icicles.

What you request is what command icicle-select-window does when you use a prefix arg. If you want that behavior always, you can define your own command that does it without a prefix arg:

 (defun my-select-window ()
   "Select window by name.  Windows of all visible frames are candidates."
   (interactive)
   (let ((current-prefix-arg  1)) (icicle-select-window)))

You are prompted for the window name. But if you just want to cycle, without narrowing the candidates by typing part of the name, then just use C-down to get the window you want.

(A window name is the name of its displayed buffer, but suffixed as needed by [NUMBER], to make the name unique. For example, if you have two windows showing buffer *Help*, one of the windows will be called *Help*[2] for use with this command.)

Upvotes: 0

jdd
jdd

Reputation: 4336

From C-h f next-window:

(next-window &optional WINDOW MINIBUF ALL-FRAMES) ...

ALL-FRAMES nil or omitted means consider all windows on WINDOW's frame, plus the minibuffer window if specified by the MINIBUF argument. If the minibuffer counts, consider all windows on all frames that share that minibuffer too. The following non-nil values of ALL-FRAMES have special meanings:

  • t means consider all windows on all existing frames.

  • `visible' means consider all windows on all visible frames.

  • 0 (the number zero) means consider all windows on all visible and iconified frames.

  • A frame means consider all windows on that frame only.

Anything else means consider all windows on WINDOW's frame and no others.

Somewhat ironically, other-window supports this as well, as it uses next-window. Unfortunately, I don't know of a way to pass non-numeric arguments interactively, but a simple function should do the trick:

(defun my-other-window (count)
  (interactive "p")
  (other-window count t))

Upvotes: 1

TacticalCoder
TacticalCoder

Reputation: 6325

I use the version 2.0 of ace-jump-mode. It takes about two minutes to understand how it works and since version 2.0 it allows to "jump" to another frame. You can jump to any character from any buffer/frame/window that you can actually see on a screen in three or four keypresses. It's very hard to beat.

It's a gigantic time saver anyway so I'd recommend checking it out because it's really convenient.

http://www.emacswiki.org/emacs/AceJump

And the "Emacs Rocks! Episode 10: Jumping around" two minutes screencast showing it in action:

http://www.youtube.com/watch?v=UZkpmegySnc

Upvotes: 1

alinsoar
alinsoar

Reputation: 15783

You must press C-x 5 o C-h to see all functions about working with frames.

Some of these function is other-frame.

Upvotes: 1

slitvinov
slitvinov

Reputation: 5768

This can be a first approximation.
http://www.gnu.org/software/emacs/manual/html_node/elisp/Cyclic-Window-Ordering.html
http://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html

other-window has a parameter to control how it deals with frames.

(global-set-key (kbd "C-x o")  (lambda ()
                 (interactive)
                 (other-window 1 t)
         (let ((nframe (window-frame (selected-window))))
           (select-frame-set-input-focus nframe)
           (make-frame-visible nframe))))

Upvotes: 1

Keith Flower
Keith Flower

Reputation: 4152

Not sure if this is what you mean, but if you want to just cycle through buffers in the buffer list, regardless of frame:

Ctrl x

Ctrl x

These are bound to (next-buffer) and (previous-buffer), respectively.

Upvotes: 1

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

C-x o is other-window. To go to an other frame use C-x 5 o which is other-frame.

Upvotes: 4

Related Questions