Function: windmove-display-in-direction
windmove-display-in-direction is a byte-compiled function defined in
windmove.el.gz.
Signature
(windmove-display-in-direction DIR &optional ARG)
Documentation
Display the next buffer in the window at direction DIR.
The next buffer is the buffer displayed by the next command invoked immediately after this command (ignoring reading from the minibuffer). Create a new window if there is no window in that direction.
By default, select the new window with a displayed buffer.
If windmove-display-no-select is ignore, then allow the next command
to decide what window it selects. With other non-nil values of
windmove-display-no-select, this function reselects
a previously selected old window.
If prefix ARG is C-u (universal-argument), reselect a previously selected old window.
If windmove-display-no-select is non-nil, the meaning of
the prefix argument is reversed and it selects the new window.
When switch-to-buffer-obey-display-actions is non-nil,
switch-to-buffer commands are also supported.
Source Code
;; Defined in /usr/src/emacs/lisp/windmove.el.gz
(defun windmove-display-in-direction (dir &optional arg)
"Display the next buffer in the window at direction DIR.
The next buffer is the buffer displayed by the next command invoked
immediately after this command (ignoring reading from the minibuffer).
Create a new window if there is no window in that direction.
By default, select the new window with a displayed buffer.
If `windmove-display-no-select' is `ignore', then allow the next command
to decide what window it selects. With other non-nil values of
`windmove-display-no-select', this function reselects
a previously selected old window.
If prefix ARG is \\[universal-argument], reselect a previously selected old window.
If `windmove-display-no-select' is non-nil, the meaning of
the prefix argument is reversed and it selects the new window.
When `switch-to-buffer-obey-display-actions' is non-nil,
`switch-to-buffer' commands are also supported."
(let ((no-select (xor (consp arg) windmove-display-no-select)))
(display-buffer-override-next-command
(lambda (_buffer alist)
(let* ((type 'reuse)
(window (cond
((eq dir 'new-tab)
(let ((tab-bar-new-tab-choice t))
(tab-bar-new-tab))
(setq type 'tab)
(selected-window))
((eq dir 'new-frame)
(let* ((params (cdr (assq 'pop-up-frame-parameters alist)))
(pop-up-frame-alist (append params pop-up-frame-alist))
(frame (make-frame-on-current-monitor
pop-up-frame-alist)))
(unless (cdr (assq 'inhibit-switch-frame alist))
(window--maybe-raise-frame frame))
(setq type 'frame)
(frame-selected-window frame)))
((eq dir 'same-window)
(selected-window))
(t (window-in-direction
dir nil windmove-allow-all-windows
(and arg (prefix-numeric-value arg))
windmove-wrap-around 'nomini)))))
(unless window
(setq window (split-window nil nil dir) type 'window))
(cons window type)))
(lambda (old-window new-window)
(when (and (not (eq windmove-display-no-select 'ignore))
(window-live-p (if no-select old-window new-window)))
(select-window (if no-select old-window new-window))))
(format "[display-%s]" dir))))