Function: display-buffer-in-child-frame

display-buffer-in-child-frame is a byte-compiled function defined in window.el.gz.

Signature

(display-buffer-in-child-frame BUFFER ALIST)

Documentation

Display BUFFER in a child frame.

By default, this either reuses a child frame of the selected frame or makes a new child frame of the selected frame. If successful, return the window used; otherwise return nil.

ALIST is an association list of action symbols and values. See Info node (elisp) Buffer Display Action Alists for details of such alists.

If ALIST has a non-nil child-frame-parameters entry, the corresponding value is an alist of frame parameters to give the new frame. A parent-frame parameter specifying the selected frame is provided by default. If the child frame shall be or become the child of any other frame, a corresponding entry must be added to ALIST.

This is an action function for buffer display, see Info node (elisp) Buffer Display Action Functions. It should be called only by display-buffer or a function directly or indirectly called by the latter.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun display-buffer-in-child-frame (buffer alist)
  "Display BUFFER in a child frame.
By default, this either reuses a child frame of the selected
frame or makes a new child frame of the selected frame.  If
successful, return the window used; otherwise return nil.

ALIST is an association list of action symbols and values.  See
Info node `(elisp) Buffer Display Action Alists' for details of
such alists.

If ALIST has a non-nil `child-frame-parameters' entry, the
corresponding value is an alist of frame parameters to give the
new frame.  A `parent-frame' parameter specifying the selected
frame is provided by default.  If the child frame shall be or
become the child of any other frame, a corresponding entry must
be added to ALIST.

This is an action function for buffer display, see Info
node `(elisp) Buffer Display Action Functions'.  It should be
called only by `display-buffer' or a function directly or
indirectly called by the latter."
  (let* ((parameters
          (append
           (cdr (assq 'child-frame-parameters alist))
           `((parent-frame . ,(selected-frame)))))
	 (parent (or (assq 'parent-frame parameters)
                     (selected-frame)))
         (share (assq 'share-child-frame parameters))
         share1 frame window type)
    (with-current-buffer buffer
      (when (frame-live-p parent)
        (catch 'frame
          (dolist (frame1 (frame-list))
            (when (eq (frame-parent frame1) parent)
              (setq share1 (assq 'share-child-frame
                                 (frame-parameters frame1)))
              (when (eq share share1)
                (setq frame frame1)
                (throw 'frame t))))))

      (if frame
          (progn
            (setq window (frame-selected-window frame))
            (setq type 'reuse))
        (setq frame (make-frame parameters))
        (setq window (frame-selected-window frame))
        (setq type 'frame)))

    (prog1 (window--display-buffer buffer window type alist)
      (unless (cdr (assq 'inhibit-switch-frame alist))
	(window--maybe-raise-frame frame)))))