emacs-diffs
[Top][All Lists]
Advanced

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

master 2c662e6: Add new command `clone-frame'


From: Lars Ingebrigtsen
Subject: master 2c662e6: Add new command `clone-frame'
Date: Wed, 1 Sep 2021 05:42:57 -0400 (EDT)

branch: master
commit 2c662e6d66165db8ead2f4d19a61af521807b8ba
Author: Drew Adams <drew.adams@oracle.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add new command `clone-frame'
    
    * doc/emacs/frames.texi (Creating Frames): Document it.
    
    * lisp/frame.el (clone-frame): New command and keystroke (bug#34715).
---
 doc/emacs/frames.texi |  9 ++++++++-
 etc/NEWS              |  5 +++++
 lisp/frame.el         | 18 ++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 22f22ef..a32181e 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 66006db..0e1edd6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/frame.el b/lisp/frame.el
index 28601b8..f36a34d 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -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)



reply via email to

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