Add new command `clone-frame'

* doc/emacs/frames.texi (Creating Frames): Document it.

* lisp/frame.el (clone-frame): New command and keystroke (bug#34715).
This commit is contained in:
Drew Adams 2021-09-01 11:42:48 +02:00 committed by Lars Ingebrigtsen
parent a4e3e0f89e
commit 2c662e6d66
3 changed files with 31 additions and 1 deletions

View file

@ -452,7 +452,14 @@ buffer to select:
@item C-x 5 2
@kindex C-x 5 2
@findex make-frame-command
Create a new frame (@code{make-frame-command}).
Create a new frame using the default frame parameters
(@code{make-frame-command}).
@item C-x 5 c
@kindex C-x 5 c
@findex clone-frame
Create a new frame using the parameters of the current frame
(@code{clone-frame}).
@item C-x 5 b @var{bufname} @key{RET}
Select buffer @var{bufname} in another frame. This runs

View file

@ -343,6 +343,11 @@ commands. The new keystrokes are 'C-x x g' ('revert-buffer-quick'),
** Commands 'set-frame-width' and 'set-frame-height' can now get their
input using the minibuffer.
+++
** New command 'clone-frame' (bound to 'C-x 5 c').
This is like 'C-x 5 2', but uses the frame parameters of the current
frame instead of 'default-frame-alist'.
---
** New help window when Emacs prompts before opening a large file.
Commands like 'find-file' or 'visit-tags-table' ask to visit a file

View file

@ -787,6 +787,23 @@ When called from Lisp, returns the new frame."
(make-frame)
(select-frame (make-frame))))
(defun clone-frame (&optional frame use-default-parameters)
"Make a new frame with the same parameters as FRAME.
With a prefix arg (USE-DEFAULT-PARAMETERS), use
`default-frame-alist' instead.
FRAME defaults to the selected frame. The frame is created on the
same terminal as FRAME. If the terminal is a text-only terminal then
also select the new frame."
(interactive "i\nP")
(if use-default-parameters
(make-frame-command)
(let* ((default-frame-alist (frame-parameters frame))
(new-frame (make-frame)))
(unless (display-graphic-p)
(select-frame new-frame))
new-frame)))
(defvar before-make-frame-hook nil
"Functions to run before `make-frame' creates a new frame.")
@ -2807,6 +2824,7 @@ See also `toggle-frame-maximized'."
(define-key ctl-x-5-map "0" #'delete-frame)
(define-key ctl-x-5-map "o" #'other-frame)
(define-key ctl-x-5-map "5" #'other-frame-prefix)
(define-key ctl-x-5-map "c" #'clone-frame)
(define-key global-map [f11] #'toggle-frame-fullscreen)
(define-key global-map [(meta f10)] #'toggle-frame-maximized)
(define-key esc-map [f10] #'toggle-frame-maximized)