emacs-devel
[Top][All Lists]
Advanced

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

Re: Functions transpose/rotate/flip windows


From: Pranshu Sharma
Subject: Re: Functions transpose/rotate/flip windows
Date: Sun, 12 Jan 2025 04:40:12 +1000
User-agent: Gnus/5.13 (Gnus v5.13)

I attached new diff with following changes (ON TOP of Eshel's diff):
- change keywords from files
- added the defcustom: rotate-windows-change-selected
I made the default value t, I think that is more pracitcal.  Even though
swap-window-states goes with the window, it must, because if it didn't
you wouldn't be able to move window around, only swap with neihbor.
- removed some now irrelevent comments


diff --git a/lisp/window-x.el b/lisp/window-x.el
index 42a09a3f063..97b0ecb4ed9 100644
--- a/lisp/window-x.el
+++ b/lisp/window-x.el
@@ -1,11 +1,11 @@
-;;; window-x.el --- Extra window organization commands  -*- lexical-binding: 
t; -*-
+;;; window-x.el --- Extra window related commands  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2025 Free Software Foundation, Inc.
 
 ;; Author: Pranshu Sharma <pranshu@bauherren.ovh>
 ;;         Martin Rudalics <rudalics@gmx.at>
 ;; Maintainer: emacs-devel@gnu.org
-;; Keywords: files
+;; Keywords: window, convenience
 ;; Package: emacs
 
 ;; This file is part of GNU Emacs.
@@ -29,6 +29,14 @@
 
 ;;; Code:
 
+(defcustom rotate-windows-change-selected t
+  "If nil the selected window will not change with `rotate-windows'.
+
+The selected window before and after the function call will stay
+unchanged if nil.  `rotate-windows-back' is also affected."
+  :type 'boolean
+  :group 'windows)
+
 (defun window-tree-normal-sizes (window &optional next)
   "Return normal sizes of all windows rooted at WINDOW.
 
@@ -70,7 +78,7 @@ HEIGHT and WIDTH are the normal height and width of the 
window.
 
 ;;;###autoload
 (defun rotate-window-layout-counterclockwise (&optional window)
-  "Rotate windows under WINDOW counterclockwise by 90 degrees.
+  "Rotate window layout of WINDOW counterclockwise by 90 degrees.
 
 If WINDOW is nil, it defaults to the root window of the selected frame.
 
@@ -81,7 +89,7 @@ selected window."
 
 ;;;###autoload
 (defun rotate-window-layout-clockwise (&optional window)
-  "Rotate windows under WINDOW clockwise by 90 degrees.
+  "Rotate window layout under WINDOW clockwise by 90 degrees.
 
 If WINDOW is nil, it defaults to the root window of the selected frame.
 
@@ -175,14 +183,13 @@ selected window."
     (when (or (seq-some #'window-atom-root winls)
              (seq-some #'window-fixed-size-p winls))
       (user-error "Cannot rotate windows due to fixed size or atom windows"))
-    ;; All child windows need to be recursively deleted.
     (delete-other-windows-internal first-window window)
-    ;; (delete-dups atom-windows)
     (window--transpose-1 new-win-tree first-window '(below . right) t nil)
     (set-frame-selected-window frame selected-window)
-    (other-window other-window-arg)
-    (while (not (memq (selected-window) winls))
-      (other-window other-window-arg))))
+    (when rotate-windows-change-selected
+      (other-window other-window-arg)
+      (while (not (memq (selected-window) winls))
+        (other-window other-window-arg)))))
 
 (defun window--transpose (window conf no-resize)
   "Rearrange windows under WINDOW recursively.
-- 
Pranshu Sharma <https://p.bauherren.ovh>

reply via email to

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