Function: windmove-do-window-select
windmove-do-window-select is a byte-compiled function defined in
windmove.el.gz.
Signature
(windmove-do-window-select DIR &optional ARG WINDOW CALLING-COMMAND)
Documentation
Move to the window at direction DIR as seen from WINDOW.
DIR, ARG, and WINDOW are handled as by windmove-find-other-window.
If no window is at direction DIR, an error is signaled.
If windmove-create-window is a function, call that function with
DIR, ARG and WINDOW. If it is non-nil, try to create a new window
in direction DIR instead.
When the same windmove command is invoked twice in succession,
the second invocation will override the no-other-window property.
CALLING-COMMAND is the command that called this function, used to detect
repeated commands.
Source Code
;; Defined in /usr/src/emacs/lisp/windmove.el.gz
;; Selects the window that's hopefully at the location returned by
;; `windmove-find-other-window', or screams if there's no window there.
(defun windmove-do-window-select (dir &optional arg window calling-command)
"Move to the window at direction DIR as seen from WINDOW.
DIR, ARG, and WINDOW are handled as by `windmove-find-other-window'.
If no window is at direction DIR, an error is signaled.
If `windmove-create-window' is a function, call that function with
DIR, ARG and WINDOW. If it is non-nil, try to create a new window
in direction DIR instead.
When the same windmove command is invoked twice in succession,
the second invocation will override the `no-other-window' property.
CALLING-COMMAND is the command that called this function, used to detect
repeated commands."
(let* ((repeated-command
(and calling-command
windmove-allow-repeated-command-override
(eq last-command
(intern (format "%s-override" calling-command)))))
(other-window (windmove-find-other-window dir arg window)))
(when (and (null other-window) repeated-command)
(setf other-window (window-in-direction dir window t arg windmove-wrap-around t)))
;; Create window if needed
(when (and windmove-create-window
(or (null other-window)
(and (window-minibuffer-p other-window)
(not (minibuffer-window-active-p other-window)))))
(setf other-window
(if (functionp windmove-create-window)
(funcall windmove-create-window dir arg window)
(split-window window nil dir))))
;; If we still don't have a window but could with allow-all-windows,
;; fail with a helpful message.
(when (and (null other-window)
calling-command
(not windmove-allow-all-windows)
(not repeated-command)
windmove-allow-repeated-command-override)
(let ((test-window (window-in-direction dir window t arg windmove-wrap-around t)))
(when test-window
;; Remember that we stopped at a boundary so we don't override
;; a no-other-window before telling the user about it during a
;; multi-command movement sequence.
(setf this-command
(intern (format "%s-override" calling-command)))
(user-error "No window %s (repeat to override)" dir))))
(cond ((null other-window)
(user-error "No window %s from selected window" dir))
((eq other-window 'no-select))
((and (window-minibuffer-p other-window)
(not (minibuffer-window-active-p other-window)))
(user-error "Minibuffer is inactive"))
(t
(select-window other-window)))))