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 @item C-x 5 c
@kindex C-x 5 c @kindex C-x 5 c
@findex clone-frame @findex clone-frame
Create a new frame using the parameters of the current frame Create a new frame using the window configuration and frame parameters
(@code{clone-frame}). of the current frame (@code{clone-frame}).
@item C-x 5 b @var{bufname} @key{RET} @item C-x 5 b @var{bufname} @key{RET}
Select buffer @var{bufname} in another frame. This runs 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'). *** 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 This is like 'C-x 5 2', but uses the window configuration and frame
frame instead of 'default-frame-alist'. parameters of the current frame instead of 'default-frame-alist'.
--- ---
*** Default values of 'frame-title-format' and 'icon-title-format' have changed. *** 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) (make-frame)
(select-frame (make-frame)))) (select-frame (make-frame))))
(defun clone-frame (&optional frame use-default-parameters) (defun clone-frame (&optional frame no-windows)
"Make a new frame with the same parameters as FRAME. "Make a new frame with the same parameters and windows as FRAME.
With a prefix arg (USE-DEFAULT-PARAMETERS), use With a prefix arg NO-WINDOWS, don't clone the window configuration.
`default-frame-alist' instead.
FRAME defaults to the selected frame. The frame is created on the 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 same terminal as FRAME. If the terminal is a text-only terminal then
also select the new frame." also select the new frame."
(interactive "i\nP") (interactive (list (selected-frame) current-prefix-arg))
(if use-default-parameters (let* ((frame (or frame (selected-frame)))
(make-frame-command) (windows (unless no-windows
(let* ((default-frame-alist (seq-filter (window-state-get (frame-root-window frame))))
(lambda (elem) (default-frame-alist
(not (eq (car elem) 'name))) (seq-remove (lambda (elem) (eq (car elem) 'name))
(frame-parameters frame))) (frame-parameters frame)))
(new-frame (make-frame))) (new-frame (make-frame)))
(unless (display-graphic-p) (when windows
(select-frame new-frame)) (window-state-put windows (frame-root-window new-frame) 'safe))
new-frame))) (unless (display-graphic-p)
(select-frame new-frame))
new-frame))
(defvar before-make-frame-hook nil (defvar before-make-frame-hook nil
"Functions to run before `make-frame' creates a new frame.") "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) `(menu-item "Detach" (lambda () (interactive)
(tab-bar-detach-tab (tab-bar-detach-tab
,tab-number)) ,tab-number))
:help "Detach the tab to new frame")) :help "Move the tab to new frame"))
(define-key-after menu [close] (define-key-after menu [close]
`(menu-item "Close" (lambda () (interactive) `(menu-item "Close" (lambda () (interactive)
(tab-bar-close-tab ,tab-number)) (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)))) (force-mode-line-update t))))
(defun tab-bar-detach-tab (&optional from-number) (defun tab-bar-detach-tab (&optional from-number)
"Detach tab number FROM-NUMBER to a new frame. "Move tab number FROM-NUMBER to a new frame.
Interactively or without argument, detach current tab." Interactively or without argument, move the current tab."
(interactive (list (1+ (tab-bar--current-tab-index)))) (interactive (list (1+ (tab-bar--current-tab-index))))
(let* ((tabs (funcall tab-bar-tabs-function)) (let* ((tabs (funcall tab-bar-tabs-function))
(tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs))))) (tab-index (1- (or from-number (1+ (tab-bar--current-tab-index tabs)))))