[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ba8370b: New commands other-window-prefix (C-x 4 4) and other-fra
From: |
Juri Linkov |
Subject: |
master ba8370b: New commands other-window-prefix (C-x 4 4) and other-frame-prefix (C-x 5 5) |
Date: |
Sun, 21 Jun 2020 19:17:09 -0400 (EDT) |
branch: master
commit ba8370bc38ace70149f0af9a88fcdb35e33fe31e
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
New commands other-window-prefix (C-x 4 4) and other-frame-prefix (C-x 5 5)
* lisp/window.el (other-window-prefix, same-window-prefix): New commands.
(ctl-x-4-map): Bind 'C-x 4 4' to 'other-window-prefix'. (Bug#41691)
* lisp/frame.el (other-frame-prefix): New command.
(ctl-x-5-map): Bind 'C-x 5 5' to 'other-frame-prefix'.
---
etc/NEWS | 8 ++++++++
lisp/frame.el | 17 +++++++++++++++++
lisp/window.el | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 5a46e71..6bfecd6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -115,6 +115,14 @@ setting the variable 'auto-save-visited-mode'
buffer-locally to nil.
* Changes in Specialized Modes and Packages in Emacs 28.1
+** Windows
+
+*** The key prefix 'C-x 4 4' displays next command buffer in a new window.
+
+** Frames
+
+*** The key prefix 'C-x 5 5' displays next command buffer in a new frame.
+
** Tab Bars
*** The key prefix 'C-x t t' displays next command buffer in a new tab.
diff --git a/lisp/frame.el b/lisp/frame.el
index 6c2f774..77080b7 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1070,6 +1070,22 @@ that variable should be nil."
(setq arg (1+ arg)))
(select-frame-set-input-focus frame)))
+(defun other-frame-prefix ()
+ "Display the buffer of the next command in a new frame.
+The next buffer is the buffer displayed by the next command invoked
+immediately after this command (ignoring reading from the minibuffer).
+Creates a new frame before displaying the buffer.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
+ (interactive)
+ (display-buffer-override-next-command
+ (lambda (buffer alist)
+ (cons (display-buffer-pop-up-frame
+ buffer (append '((inhibit-same-window . t))
+ alist))
+ 'frame)))
+ (message "Display next command buffer in a new frame..."))
+
(defun iconify-or-deiconify-frame ()
"Iconify the selected frame, or deiconify if it's currently an icon."
(interactive)
@@ -2697,6 +2713,7 @@ See also `toggle-frame-maximized'."
(define-key ctl-x-5-map "1" 'delete-other-frames)
(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 global-map [f11] 'toggle-frame-fullscreen)
(define-key global-map [(meta f10)] 'toggle-frame-maximized)
(define-key esc-map [f10] 'toggle-frame-maximized)
diff --git a/lisp/window.el b/lisp/window.el
index 998568e..f6f30ad 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4005,6 +4005,43 @@ always effectively nil."
;; Always return nil.
nil))))
+(defun other-window-prefix ()
+ "Display the buffer of the next command in a new window.
+The next buffer is the buffer displayed by the next command invoked
+immediately after this command (ignoring reading from the minibuffer).
+Creates a new window before displaying the buffer.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
+ (interactive)
+ (display-buffer-override-next-command
+ (lambda (buffer alist)
+ (let ((alist (append '((inhibit-same-window . t)) alist))
+ window type)
+ (if (setq window (display-buffer-pop-up-window buffer alist))
+ (setq type 'window)
+ (setq window (display-buffer-use-some-window buffer alist)
+ type 'reuse))
+ (cons window type))))
+ (message "Display next command buffer in a new window..."))
+
+(defun same-window-prefix ()
+ "Display the buffer of the next command in the same window.
+The next buffer is the buffer displayed by the next command invoked
+immediately after this command (ignoring reading from the minibuffer).
+Even when the default rule should display the buffer in a new window,
+force its display in the already selected window.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
+ (interactive)
+ (display-buffer-override-next-command
+ (lambda (buffer alist)
+ (setq alist (append '((inhibit-same-window . nil)) alist))
+ (cons (or
+ (display-buffer-same-window buffer alist)
+ (display-buffer-use-some-window buffer alist))
+ 'reuse)))
+ (message "Display next command buffer in the same window..."))
+
;; This should probably return non-nil when the selected window is part
;; of an atomic window whose root is the frame's root window.
(defun one-window-p (&optional nomini all-frames)
@@ -10124,5 +10161,6 @@ displaying that processes's buffer."
(define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer)
(define-key ctl-x-map "+" 'balance-windows)
(define-key ctl-x-4-map "0" 'kill-buffer-and-window)
+(define-key ctl-x-4-map "4" 'other-window-prefix)
;;; window.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ba8370b: New commands other-window-prefix (C-x 4 4) and other-frame-prefix (C-x 5 5),
Juri Linkov <=