diff options
| author | Juri Linkov | 2020-06-22 02:17:02 +0300 |
|---|---|---|
| committer | Juri Linkov | 2020-06-22 02:17:02 +0300 |
| commit | ba8370bc38ace70149f0af9a88fcdb35e33fe31e (patch) | |
| tree | a778ca91057593484aef95be5ceba76a53363682 | |
| parent | a1686c00d0e4550228673e9f2b95b7c1c0662be8 (diff) | |
| download | emacs-ba8370bc38ace70149f0af9a88fcdb35e33fe31e.tar.gz emacs-ba8370bc38ace70149f0af9a88fcdb35e33fe31e.zip | |
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'.
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/frame.el | 17 | ||||
| -rw-r--r-- | lisp/window.el | 38 |
3 files changed, 63 insertions, 0 deletions
| @@ -115,6 +115,14 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil. | |||
| 115 | 115 | ||
| 116 | * Changes in Specialized Modes and Packages in Emacs 28.1 | 116 | * Changes in Specialized Modes and Packages in Emacs 28.1 |
| 117 | 117 | ||
| 118 | ** Windows | ||
| 119 | |||
| 120 | *** The key prefix 'C-x 4 4' displays next command buffer in a new window. | ||
| 121 | |||
| 122 | ** Frames | ||
| 123 | |||
| 124 | *** The key prefix 'C-x 5 5' displays next command buffer in a new frame. | ||
| 125 | |||
| 118 | ** Tab Bars | 126 | ** Tab Bars |
| 119 | 127 | ||
| 120 | *** The key prefix 'C-x t t' displays next command buffer in a new tab. | 128 | *** 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 6c2f774709e..77080b76e4f 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -1070,6 +1070,22 @@ that variable should be nil." | |||
| 1070 | (setq arg (1+ arg))) | 1070 | (setq arg (1+ arg))) |
| 1071 | (select-frame-set-input-focus frame))) | 1071 | (select-frame-set-input-focus frame))) |
| 1072 | 1072 | ||
| 1073 | (defun other-frame-prefix () | ||
| 1074 | "Display the buffer of the next command in a new frame. | ||
| 1075 | The next buffer is the buffer displayed by the next command invoked | ||
| 1076 | immediately after this command (ignoring reading from the minibuffer). | ||
| 1077 | Creates a new frame before displaying the buffer. | ||
| 1078 | When `switch-to-buffer-obey-display-actions' is non-nil, | ||
| 1079 | `switch-to-buffer' commands are also supported." | ||
| 1080 | (interactive) | ||
| 1081 | (display-buffer-override-next-command | ||
| 1082 | (lambda (buffer alist) | ||
| 1083 | (cons (display-buffer-pop-up-frame | ||
| 1084 | buffer (append '((inhibit-same-window . t)) | ||
| 1085 | alist)) | ||
| 1086 | 'frame))) | ||
| 1087 | (message "Display next command buffer in a new frame...")) | ||
| 1088 | |||
| 1073 | (defun iconify-or-deiconify-frame () | 1089 | (defun iconify-or-deiconify-frame () |
| 1074 | "Iconify the selected frame, or deiconify if it's currently an icon." | 1090 | "Iconify the selected frame, or deiconify if it's currently an icon." |
| 1075 | (interactive) | 1091 | (interactive) |
| @@ -2697,6 +2713,7 @@ See also `toggle-frame-maximized'." | |||
| 2697 | (define-key ctl-x-5-map "1" 'delete-other-frames) | 2713 | (define-key ctl-x-5-map "1" 'delete-other-frames) |
| 2698 | (define-key ctl-x-5-map "0" 'delete-frame) | 2714 | (define-key ctl-x-5-map "0" 'delete-frame) |
| 2699 | (define-key ctl-x-5-map "o" 'other-frame) | 2715 | (define-key ctl-x-5-map "o" 'other-frame) |
| 2716 | (define-key ctl-x-5-map "5" 'other-frame-prefix) | ||
| 2700 | (define-key global-map [f11] 'toggle-frame-fullscreen) | 2717 | (define-key global-map [f11] 'toggle-frame-fullscreen) |
| 2701 | (define-key global-map [(meta f10)] 'toggle-frame-maximized) | 2718 | (define-key global-map [(meta f10)] 'toggle-frame-maximized) |
| 2702 | (define-key esc-map [f10] 'toggle-frame-maximized) | 2719 | (define-key esc-map [f10] 'toggle-frame-maximized) |
diff --git a/lisp/window.el b/lisp/window.el index 998568e7b82..f6f30ad6f49 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4005,6 +4005,43 @@ always effectively nil." | |||
| 4005 | ;; Always return nil. | 4005 | ;; Always return nil. |
| 4006 | nil)))) | 4006 | nil)))) |
| 4007 | 4007 | ||
| 4008 | (defun other-window-prefix () | ||
| 4009 | "Display the buffer of the next command in a new window. | ||
| 4010 | The next buffer is the buffer displayed by the next command invoked | ||
| 4011 | immediately after this command (ignoring reading from the minibuffer). | ||
| 4012 | Creates a new window before displaying the buffer. | ||
| 4013 | When `switch-to-buffer-obey-display-actions' is non-nil, | ||
| 4014 | `switch-to-buffer' commands are also supported." | ||
| 4015 | (interactive) | ||
| 4016 | (display-buffer-override-next-command | ||
| 4017 | (lambda (buffer alist) | ||
| 4018 | (let ((alist (append '((inhibit-same-window . t)) alist)) | ||
| 4019 | window type) | ||
| 4020 | (if (setq window (display-buffer-pop-up-window buffer alist)) | ||
| 4021 | (setq type 'window) | ||
| 4022 | (setq window (display-buffer-use-some-window buffer alist) | ||
| 4023 | type 'reuse)) | ||
| 4024 | (cons window type)))) | ||
| 4025 | (message "Display next command buffer in a new window...")) | ||
| 4026 | |||
| 4027 | (defun same-window-prefix () | ||
| 4028 | "Display the buffer of the next command in the same window. | ||
| 4029 | The next buffer is the buffer displayed by the next command invoked | ||
| 4030 | immediately after this command (ignoring reading from the minibuffer). | ||
| 4031 | Even when the default rule should display the buffer in a new window, | ||
| 4032 | force its display in the already selected window. | ||
| 4033 | When `switch-to-buffer-obey-display-actions' is non-nil, | ||
| 4034 | `switch-to-buffer' commands are also supported." | ||
| 4035 | (interactive) | ||
| 4036 | (display-buffer-override-next-command | ||
| 4037 | (lambda (buffer alist) | ||
| 4038 | (setq alist (append '((inhibit-same-window . nil)) alist)) | ||
| 4039 | (cons (or | ||
| 4040 | (display-buffer-same-window buffer alist) | ||
| 4041 | (display-buffer-use-some-window buffer alist)) | ||
| 4042 | 'reuse))) | ||
| 4043 | (message "Display next command buffer in the same window...")) | ||
| 4044 | |||
| 4008 | ;; This should probably return non-nil when the selected window is part | 4045 | ;; This should probably return non-nil when the selected window is part |
| 4009 | ;; of an atomic window whose root is the frame's root window. | 4046 | ;; of an atomic window whose root is the frame's root window. |
| 4010 | (defun one-window-p (&optional nomini all-frames) | 4047 | (defun one-window-p (&optional nomini all-frames) |
| @@ -10124,5 +10161,6 @@ displaying that processes's buffer." | |||
| 10124 | (define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer) | 10161 | (define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer) |
| 10125 | (define-key ctl-x-map "+" 'balance-windows) | 10162 | (define-key ctl-x-map "+" 'balance-windows) |
| 10126 | (define-key ctl-x-4-map "0" 'kill-buffer-and-window) | 10163 | (define-key ctl-x-4-map "0" 'kill-buffer-and-window) |
| 10164 | (define-key ctl-x-4-map "4" 'other-window-prefix) | ||
| 10127 | 10165 | ||
| 10128 | ;;; window.el ends here | 10166 | ;;; window.el ends here |