GNU Emacs Lisp Reference Manual
When you use the command C-x o (other-window) to select the next window, it moves through all the windows on the screen in a specific cyclic order. For any given configuration of windows, this order never varies. It is called the cyclic ordering of windows.
This ordering generally goes from top to bottom, and from left to right. But it may go down first or go right first, depending on the order in which the windows were split.
If the first split was vertical (into windows one above each other), and then the subwindows were split horizontally, then the ordering is left to right in the top of the frame, and then left to right in the next lower part of the frame, and so on. If the first split was horizontal, the ordering is top to bottom in the left part, and so on. In general, within each set of siblings at any level in the window tree, the order is left to right, or top to bottom.
The value of the argument minibuf determines whether the minibuffer is included in the window order. Normally, when minibuf is nil, the minibuffer is included if it is currently active; this is the behavior of C-x o. (The minibuffer window is active while the minibuffer is in use. See Minibuffers.)
If minibuf is t, then the cyclic ordering includes the minibuffer window even if it is not active.
If minibuf is neither t nor nil, then the minibuffer window is not included even if it is active.
The argument all-frames specifies which frames to consider. Here are the possible values and their meanings:
niltvisibleThis example assumes there are two windows, both displaying the buffer `windows.texi':
(selected-window)
=> #
(next-window (selected-window))
=> #
(next-window (next-window (selected-window)))
=> #
next-window.nil. In an interactive call, count is the numeric prefix argument.
proc once for each window with the window as its sole argument. The optional arguments minibuf and all-frames specify the set of windows to include in the scan. See next-window, above, for details.