branch: elpa/crux
commit 95f50405860d988f25cceb412f3439949876af5f
Author: Trust me I am a doctor <pill...@riseup.net>
Commit: Bozhidar Batsov <bozhi...@batsov.dev>

    Update crux-transpose-window with other-window
    
    Hello,
    
    The current crux-transpose-window uses next-window and previous-window.
    I suggest to rather uses other-window.
    
    The difference between those it that other-window will check for the
    no-other-window window parameter.
    
    This parameter is by default, not set to any window. It is at the user
    or external packages discretion to set it, with display-buffer-alist or
    whatever. So essentially, for a default configuration, this commit
    changes nothing.
    
    When the user or a package customizes the window display to set it to
    some windows, these window will be skipped by functions such as
    other-window, windmove, display-buffer-in-direction.
    
    Essentially one may want to narrow the candidates of commands checking
    this parameters to gain in predicability and avoid reusing disposables
    window, popups or I don't know how to call them but I think you get the
    idea.
    
    I will ramble a little and say this parameter is quite confusing since
    you may expect the commands of the ctl-x-4-map to uses it, but no. These
    commands generally relies on pop-to-buffer and never check the
    no-other-window parameter.
    
    So, maybe too specific for crux ?
---
 crux.el | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/crux.el b/crux.el
index e70b6be..d7654cf 100644
--- a/crux.el
+++ b/crux.el
@@ -638,14 +638,11 @@ Prefix ARG determines if the current windows buffer is 
swapped
 with the next or previous window, and the number of
 transpositions to execute in sequence."
   (interactive "p")
-  (let ((selector (if (>= arg 0) 'next-window 'previous-window)))
-    (while (/= arg 0)
-      (let ((this-win (window-buffer))
-            (next-win (window-buffer (funcall selector))))
-        (set-window-buffer (selected-window) next-win)
-        (set-window-buffer (funcall selector) this-win)
-        (select-window (funcall selector)))
-      (setq arg (if (cl-plusp arg) (1- arg) (1+ arg))))))
+  (let ((this-win (selected-window))
+        (this-buffer (window-buffer)))
+    (other-window arg)
+    (set-window-buffer this-win (current-buffer))
+    (set-window-buffer (selected-window) this-buffer)))
 
 (defalias 'crux-swap-windows 'crux-transpose-windows)
 

Reply via email to