emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-28 f7e6c19: Clone the frame window configuration in 'clone-frame'


From: Juri Linkov
Subject: emacs-28 f7e6c19: Clone the frame window configuration in 'clone-frame'
Date: Wed, 6 Oct 2021 12:38:31 -0400 (EDT)

branch: emacs-28
commit f7e6c199bf5b915e000bad964f3be2323d07647e
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    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
---
 doc/emacs/frames.texi |  4 ++--
 etc/NEWS              |  4 ++--
 lisp/frame.el         | 31 ++++++++++++++++---------------
 lisp/tab-bar.el       |  6 +++---
 4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 06e2642..8cf7568 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 8808413..8b327fa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
diff --git a/lisp/frame.el b/lisp/frame.el
index e97b990..2c73737 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -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.")
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 68afb53..b08b744 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -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)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]