Function: same-window-p

same-window-p is a byte-compiled function defined in window.el.gz.

Signature

(same-window-p BUFFER-NAME)

Documentation

Return non-nil if buffer BUFFER-NAME would be shown in the "same" window.

This function returns non-nil if display-buffer or pop-to-buffer would show a buffer named BUFFER-NAME in the selected rather than (as usual) some other window. See same-window-buffer-names and same-window-regexps.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun same-window-p (buffer-name)
  "Return non-nil if buffer BUFFER-NAME would be shown in the \"same\" window.
This function returns non-nil if `display-buffer' or
`pop-to-buffer' would show a buffer named BUFFER-NAME in the
selected rather than (as usual) some other window.  See
`same-window-buffer-names' and `same-window-regexps'."
  (cond
   ((not (stringp buffer-name)))
   ;; The elements of `same-window-buffer-names' can be buffer
   ;; names or cons cells whose cars are buffer names.
   ((member buffer-name same-window-buffer-names))
   ((assoc buffer-name same-window-buffer-names))
   ((catch 'found
      (dolist (regexp same-window-regexps)
	;; The elements of `same-window-regexps' can be regexps
	;; or cons cells whose cars are regexps.
	(when (or (and (stringp regexp)
		       (string-match-p regexp buffer-name))
		  (and (consp regexp) (stringp (car regexp))
		       (string-match-p (car regexp) buffer-name)))
	  (throw 'found t)))))))