Function: other-window-for-scrolling

other-window-for-scrolling is a function defined in window.c.

Signature

(other-window-for-scrolling)

Documentation

Return "the other" window for "other window scroll" commands.

If in the minibuffer, and minibuffer-scroll-window is non-nil, it specifies the window to use. Otherwise, if other-window-scroll-buffer is a buffer, a window showing that buffer is the window to use, popping it up if necessary. Otherwise, if other-window-scroll-default is a function, call it, and the window it returns is the window to use. Finally, the function looks for a neighboring window on the selected frame, followed by windows on all the visible frames on the current terminal.

Probably introduced at or before Emacs version 19.26.

Source Code

// Defined in /usr/src/emacs/src/window.c
{
  Lisp_Object window;

  if (MINI_WINDOW_P (XWINDOW (selected_window))
      && !NILP (Vminibuf_scroll_window))
    window = Vminibuf_scroll_window;
  /* If buffer is specified and live, scroll that buffer.  */
  else if (BUFFERP (Vother_window_scroll_buffer)
	   && BUFFER_LIVE_P (XBUFFER (Vother_window_scroll_buffer)))
    {
      window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil);
      if (NILP (window))
	window = display_buffer (Vother_window_scroll_buffer, Qt, Qnil);
    }
  else if (FUNCTIONP (Vother_window_scroll_default))
    /* Nothing specified; try to get a window from the function.  */
    window = call0 (Vother_window_scroll_default);
  else
    {
      /* Otherwise, look for a neighboring window on the same frame.  */
      window = Fnext_window (selected_window, Qlambda, Qnil);

      if (EQ (window, selected_window))
	/* That didn't get us anywhere; look for a window on another
           visible frame on the current terminal.  */
        window = Fnext_window (window, Qlambda, Qvisible);
    }

  CHECK_LIVE_WINDOW (window);

  if (EQ (window, selected_window))
    error ("There is no other window");

  return window;
}