Clone the frame window configuration in 'clone-frame'

* doc/emacs/frames.texi (Creating Frames): Mention the cloned
window configuration for clone-frame.

* lisp/frame.el (clone-frame): Change second arg to 'no-windows'
and clone window configuration when it's nil.

* lisp/tab-bar.el (tab-bar-mouse-context-menu)
(tab-bar-detach-tab): Replace "Detach" with "Move" in help/doc strings.

https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg00408.html
This commit is contained in:
Juri Linkov 2021-10-06 19:38:09 +03:00
parent 5f626488d8
commit f7e6c199bf
4 changed files with 23 additions and 22 deletions

View file

@ -458,8 +458,8 @@ Create a new frame using the default frame parameters
@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}).
Create a new frame using the window configuration and frame 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

@ -352,8 +352,8 @@ of the next command to be displayed in a new frame.
+++
*** 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'.
This is like 'C-x 5 2', but uses the window configuration and frame
parameters of the current frame instead of 'default-frame-alist'.
---
*** Default values of 'frame-title-format' and 'icon-title-format' have changed.

View file

@ -786,25 +786,26 @@ 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.
(defun clone-frame (&optional frame no-windows)
"Make a new frame with the same parameters and windows as FRAME.
With a prefix arg NO-WINDOWS, don't clone the window configuration.
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 (seq-filter
(lambda (elem)
(not (eq (car elem) 'name)))
(frame-parameters frame)))
(new-frame (make-frame)))
(unless (display-graphic-p)
(select-frame new-frame))
new-frame)))
(interactive (list (selected-frame) current-prefix-arg))
(let* ((frame (or frame (selected-frame)))
(windows (unless no-windows
(window-state-get (frame-root-window frame))))
(default-frame-alist
(seq-remove (lambda (elem) (eq (car elem) 'name))
(frame-parameters frame)))
(new-frame (make-frame)))
(when windows
(window-state-put windows (frame-root-window new-frame) 'safe))
(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.")

View file

@ -316,7 +316,7 @@ that closes only when clicked on the close button."
`(menu-item "Detach" (lambda () (interactive)
(tab-bar-detach-tab
,tab-number))
:help "Detach the tab to new frame"))
:help "Move the tab to new frame"))
(define-key-after menu [close]
`(menu-item "Close" (lambda () (interactive)
(tab-bar-close-tab ,tab-number))
@ -1208,8 +1208,8 @@ Interactively, ARG selects the ARGth different frame to move to."
(force-mode-line-update t))))
(defun tab-bar-detach-tab (&optional from-number)
"Detach tab number FROM-NUMBER to a new frame.
Interactively or without argument, detach current tab."
"Move tab number FROM-NUMBER to a new frame.
Interactively or without argument, move the current tab."
(interactive (list (1+ (tab-bar--current-tab-index))))
(let* ((tabs (funcall tab-bar-tabs-function))
(tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs)))))