From 20b919cfb1b5861a91a57b5f0c27e6c6fc03aff5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 18 Apr 2025 18:25:16 +0800 Subject: [PATCH] Bind new window layout commands under C-x w * lisp/window.el (rotate-windows-repeat-map) (window-layout-rotate-repeat-map, window-layout-flip-repeat-map): New keymaps. (window-prefix-map): Bind new window layout commands. * etc/NEWS: Rewrite entry for the new commands. --- etc/NEWS | 12 +++++++----- lisp/window.el | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 0918553c733..d57c118d9e7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -225,11 +225,13 @@ albeit as a variable, not a user option. ** Windows +++ -*** New functions to modify window layout. -Several functions to modify the window layout have been added: -'window-layout-rotate-clockwise', 'window-layout-rotate-anticlockwise', -'window-layout-flip-topdown', 'window-layout-flip-leftright', -'window-layout-transpose', 'rotate-windows', and 'rotate-windows-back'. +*** New commands to modify window layouts. +'C-x w t' and 'C-x w r /' rotate the window layout. +'C-x w o /' rotate the windows within the current layout. +'C-x w f ///' flip window layouts. + +By default these commands operate on the selected frame's root window. +With a prefix argument, they operate on the selected window's parent. +++ *** Windmove commands now move to skipped windows if invoked twice in a row. diff --git a/lisp/window.el b/lisp/window.el index cdd6b932502..e0e626e9500 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -11381,6 +11381,29 @@ Used in `repeat-mode'." ;; Additional keys: "v" #'shrink-window) +(defvar-keymap rotate-windows-repeat-map + :doc "Keymap to repeat window-rotating commands. +Used in `repeat-mode'." + :repeat t + "" #'rotate-windows-back + "" #'rotate-windows) + +(defvar-keymap window-layout-rotate-repeat-map + :doc "Keymap to repeat window layout-rotating commands. +Used in `repeat-mode'." + :repeat t + "" #'window-layout-rotate-anticlockwise + "" #'window-layout-rotate-clockwise) + +(defvar-keymap window-layout-flip-repeat-map + :doc "Keymap to repeat window-flipping commands. +Used in `repeat-mode'." + :repeat t + "" #'window-layout-flip-leftright + "" #'window-layout-flip-leftright + "" #'window-layout-flip-topdown + "" #'window-layout-flip-topdown) + (defvar-keymap window-prefix-map :doc "Keymap for subcommands of \\`C-x w'." "2" #'split-root-window-below @@ -11391,7 +11414,17 @@ Used in `repeat-mode'." "^ t" #'tab-window-detach "-" #'fit-window-to-buffer "0" #'delete-windows-on - "q" #'quit-window) + "q" #'quit-window + + "o " #'rotate-windows-back + "o " #'rotate-windows + "t" #'window-layout-transpose + "r " #'window-layout-rotate-anticlockwise + "r " #'window-layout-rotate-clockwise + "f " #'window-layout-flip-leftright + "f " #'window-layout-flip-leftright + "f " #'window-layout-flip-topdown + "f " #'window-layout-flip-topdown) (define-key ctl-x-map "w" window-prefix-map) (provide 'window)