display-buffer-function is a variable defined in `window.el'.
Its value is

  • This variable is obsolete since 24.3;
    use `display-buffer-alist' instead.
  • This variable may be risky if used as a file-local variable.

If non-nil, function to call to handle `display-buffer'.
It will receive two args, the buffer and a flag which if non-nil
means that the currently selected window is not acceptable. It
should choose or create a window, display the specified buffer in
it, and return the window.

The specified function should call `display-buffer-record-window'
with corresponding arguments to set up the quit-restore parameter
of the window used.

You can customize this variable.