Function: make-frame
make-frame is an interactive and byte-compiled function defined in
frame.el.gz.
Signature
(make-frame &optional PARAMETERS)
Documentation
Return a newly created frame displaying the current buffer.
Optional argument PARAMETERS is an alist of frame parameters for the new frame. Each element of PARAMETERS should have the form (NAME . VALUE), for example:
(name . STRING) The frame should be named STRING.
(width . NUMBER) The frame should be NUMBER characters in width.
(height . NUMBER) The frame should be NUMBER text lines high.
(minibuffer . t) The frame should have a minibuffer.
(minibuffer . nil) The frame should have no minibuffer.
(minibuffer . only) The frame should contain only a minibuffer.
(minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
(window-system . nil) The frame should be displayed on a terminal device.
(window-system . x) The frame should be displayed in an X window.
(display . ":0") The frame should appear on display :0.
(terminal . TERMINAL) The frame should use the terminal object TERMINAL.
In addition, any parameter specified in default-frame-alist,
but not present in PARAMETERS, is applied.
Before creating the frame (via frame-creation-function), this
function runs the hook before-make-frame-hook. After creating
the frame, it runs the hook after-make-frame-functions with one
argument, the newly created frame.
If a display parameter is supplied and a window-system is not, guess the window-system from the display.
On graphical displays, this function does not itself make the new frame the selected frame. However, the window system may select the new frame according to its own rules.
By default do not display the current buffer in the new frame if the
buffer is hidden, that is, if the buffer's name starts with a space.
Display another buffer, one that could be returned by other-buffer,
instead. However, if expose-hidden-buffer is non-nil, display the
current buffer even if it is hidden.
Probably introduced at or before Emacs version 19.20.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/frame.el.gz
(defun make-frame (&optional parameters)
"Return a newly created frame displaying the current buffer.
Optional argument PARAMETERS is an alist of frame parameters for
the new frame. Each element of PARAMETERS should have the
form (NAME . VALUE), for example:
(name . STRING) The frame should be named STRING.
(width . NUMBER) The frame should be NUMBER characters in width.
(height . NUMBER) The frame should be NUMBER text lines high.
(minibuffer . t) The frame should have a minibuffer.
(minibuffer . nil) The frame should have no minibuffer.
(minibuffer . only) The frame should contain only a minibuffer.
(minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
(window-system . nil) The frame should be displayed on a terminal device.
(window-system . x) The frame should be displayed in an X window.
(display . \":0\") The frame should appear on display :0.
(terminal . TERMINAL) The frame should use the terminal object TERMINAL.
In addition, any parameter specified in `default-frame-alist',
but not present in PARAMETERS, is applied.
Before creating the frame (via `frame-creation-function'), this
function runs the hook `before-make-frame-hook'. After creating
the frame, it runs the hook `after-make-frame-functions' with one
argument, the newly created frame.
If a display parameter is supplied and a window-system is not,
guess the window-system from the display.
On graphical displays, this function does not itself make the new
frame the selected frame. However, the window system may select
the new frame according to its own rules.
By default do not display the current buffer in the new frame if the
buffer is hidden, that is, if the buffer's name starts with a space.
Display another buffer, one that could be returned by `other-buffer',
instead. However, if `expose-hidden-buffer' is non-nil, display the
current buffer even if it is hidden."
(interactive)
(let* ((display (cdr (assq 'display parameters)))
(w (cond
;; When running in a batch session, don't create a GUI
;; frame. (Batch sessions don't set a SIGIO handler on
;; relevant platforms, so attempting this would terminate
;; Emacs.)
(noninteractive nil)
((assq 'terminal parameters)
(let ((type (terminal-live-p
(cdr (assq 'terminal parameters)))))
(cond
((eq t type) nil)
((null type) (error "Terminal %s does not exist"
(cdr (assq 'terminal parameters))))
(t type))))
((assq 'window-system parameters)
(cdr (assq 'window-system parameters)))
(display
(or (window-system-for-display display)
(error "Don't know how to interpret display %S"
display)))
(t window-system)))
(params parameters)
frame child-frame)
(unless (get w 'window-system-initialized)
(let ((window-system w)) ;Hack attack!
(window-system-initialization display))
(setq x-display-name display)
(put w 'window-system-initialized t))
;; Add parameters from `window-system-default-frame-alist'.
(dolist (p (cdr (assq w window-system-default-frame-alist)))
(unless (assq (car p) params)
(push p params)))
;; Add parameters from `default-frame-alist'.
(dolist (p default-frame-alist)
(unless (assq (car p) params)
(push p params)))
;; Add parameters from `frame-inherited-parameters' unless they are
;; overridden by explicit parameters.
(dolist (param frame-inherited-parameters)
(unless (assq param parameters)
(let ((val (frame-parameter nil param)))
(when val (push (cons param val) params)))))
(when (eq (cdr (or (assq 'minibuffer params) '(minibuffer . t)))
'child-frame)
;; If the 'minibuffer' parameter equals 'child-frame' make a
;; frame without minibuffer first using the root window of
;; 'default-minibuffer-frame' as its minibuffer window
(setq child-frame t)
(setq params (cons '(minibuffer)
(delq (assq 'minibuffer params) params))))
;; Now make the frame.
(run-hooks 'before-make-frame-hook)
(setq frame (let ((window-system w)) ; Hack attack!
(frame-creation-function params)))
(when child-frame
;; When we want to equip the new frame with a minibuffer-only
;; child frame, make that frame and reparent it immediately.
(setq child-frame
(make-frame
(append
`((display . ,display) (minibuffer . only)
(parent-frame . ,frame))
minibuffer-frame-alist)))
(when (frame-live-p child-frame)
;; Have the 'minibuffer' parameter of our new frame refer to
;; its child frame's root window.
(set-frame-parameter
frame 'minibuffer (frame-root-window child-frame))))
(normal-erase-is-backspace-setup-frame frame)
(when (window-system frame)
;; On a window-system frame apply buffer-local values for the
;; fringes, scroll bars and margins of root and minibuffer window
;; of the new frame. The 'frame-creation-function' above could
;; not do that since the frame did not exist yet at the time the
;; buffers for these windows were set (Bug#79606).
(let* ((root (frame-root-window frame))
(buffer (window-buffer root)))
(with-current-buffer buffer
(set-window-fringes
root left-fringe-width right-fringe-width fringes-outside-margins)
(set-window-scroll-bars
root scroll-bar-width vertical-scroll-bar
scroll-bar-height horizontal-scroll-bar)
(set-window-margins
root left-margin-width right-margin-width)))
(let* ((mini (minibuffer-window frame))
(buffer (window-buffer mini)))
(when (eq (window-frame mini) frame)
(with-current-buffer buffer
(set-window-fringes
mini left-fringe-width right-fringe-width fringes-outside-margins)
(set-window-scroll-bars
mini scroll-bar-width vertical-scroll-bar
scroll-bar-height horizontal-scroll-bar)
(set-window-margins
mini left-margin-width right-margin-width)))))
;; We can run `window-configuration-change-hook' for this frame now.
(frame-after-make-frame frame t)
(run-hook-with-args 'after-make-frame-functions frame)
frame))