-
- err = no_switch_window (selected_window);
- if (err)
- /* If can't display in current window, let pop-to-buffer
- try some other window. */
- return call3 (intern ("pop-to-buffer"), buffer, Qnil, norecord);
-
- return switch_to_buffer_1 (buffer, norecord);
-}
-
-DEFUN ("pop-to-buffer", Fpop_to_buffer, Spop_to_buffer, 1, 3, 0,
- doc: /* Select buffer BUFFER in some window, preferably a different one.
-BUFFER may be a buffer, a string \(a buffer name), or nil.
-If BUFFER is a string which is not the name of an existing buffer,
-then this function creates a buffer with that name.
-If BUFFER is nil, then it chooses some other buffer.
-If `pop-up-windows' is non-nil, windows can be split to do this.
-If optional second arg OTHER-WINDOW is non-nil, insist on finding another
-window even if BUFFER is already visible in the selected window,
-and ignore `same-window-regexps' and `same-window-buffer-names'.
-This function returns the buffer it switched to.
-This uses the function `display-buffer' as a subroutine; see the documentation
-of `display-buffer' for additional customization information.
-
-Optional third arg NORECORD non-nil means
-do not put this buffer at the front of the list of recently selected ones. */)
- (buffer, other_window, norecord)
- Lisp_Object buffer, other_window, norecord;
-{
- register Lisp_Object buf;
- if (NILP (buffer))
- buf = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil);
+ else if (EQ (minibuf_window, selected_window)
+ /* If `dedicated' is neither nil nor t, it means it's
+ dedicatedness can be overridden by an explicit request
+ such as a call to switch-to-buffer. */
+ || EQ (Fwindow_dedicated_p (selected_window), Qt))
+ /* We can't use the selected window so let `pop-to-buffer' try some
+ other window. */
+ return call3 (intern ("pop-to-buffer"), buffer_or_name, Qnil, norecord);