Function: other-frame

other-frame is an interactive and byte-compiled function defined in frame.el.gz.

Signature

(other-frame ARG)

Documentation

Select the ARGth different visible frame on current display, and raise it.

All frames are arranged in a cyclic order. This command selects the frame ARG steps away in that order. A negative ARG moves in the opposite order.

To make this command work properly, you must tell Emacs how the system (or the window manager) generally handles focus-switching between windows. If moving the mouse onto a window selects it (gives it focus), set focus-follows-mouse to t. Otherwise, that variable should be nil.

Probably introduced at or before Emacs version 19.20.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/frame.el.gz
(defun other-frame (arg)
  "Select the ARGth different visible frame on current display, and raise it.
All frames are arranged in a cyclic order.
This command selects the frame ARG steps away in that order.
A negative ARG moves in the opposite order.

To make this command work properly, you must tell Emacs how the
system (or the window manager) generally handles focus-switching
between windows.  If moving the mouse onto a window selects
it (gives it focus), set `focus-follows-mouse' to t.  Otherwise,
that variable should be nil."
  (interactive "p")
  (let ((sframe (selected-frame))
        (frame (selected-frame)))
    (while (> arg 0)
      (setq frame (next-frame frame))
      (while (and (not (eq frame sframe))
                  (not (eq (frame-visible-p frame) t)))
	(setq frame (next-frame frame)))
      (setq arg (1- arg)))
    (while (< arg 0)
      (setq frame (previous-frame frame))
      (while (and (not (eq frame sframe))
                  (not (eq (frame-visible-p frame) t)))
	(setq frame (previous-frame frame)))
      (setq arg (1+ arg)))
    (select-frame-set-input-focus frame)))