[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil a5ab49a490: Swap window sizes when exchanging windows
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil a5ab49a490: Swap window sizes when exchanging windows |
Date: |
Mon, 9 Jan 2023 11:59:10 -0500 (EST) |
branch: elpa/evil
commit a5ab49a49068b419f92de39ec046aa49aa80d3f1
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Axel Forsman <axelsfor@gmail.com>
Swap window sizes when exchanging windows
Use the function window-swap-states added in GNU Emacs 26.1 when
available. Also leave the correct window selected, i.e. not the window
that was originally selected.
Closes #338
---
evil-commands.el | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index 50288dee50..d6558b9490 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -4599,22 +4599,18 @@ If ARG is empty, maximize the current window height."
(select-window (car (window-list))))))
(evil-define-command evil-window-exchange (count)
- "Without COUNT: exchange current window with next one.
-With COUNT: Exchange current window with COUNTth window."
+ "Exchange the current window with the next, or the COUNT-th, one."
:repeat nil
(interactive "<c>")
- (let ((this-buffer (window-buffer))
- other-buffer other-window)
- (if (not count)
- (setq other-buffer (window-buffer (next-window))
- other-window (next-window))
- (save-window-excursion
- (evil-window-next count)
- (setq other-buffer (window-buffer)
- other-window (selected-window))))
- (switch-to-buffer other-buffer nil t)
- (select-window other-window)
- (switch-to-buffer this-buffer nil t)))
+ (let ((original-window (selected-window)))
+ (evil-window-next count)
+ (if (fboundp 'window-swap-states)
+ (window-swap-states nil original-window t)
+ (let* ((other-window (selected-window))
+ (original-state (window-state-get original-window))
+ (other-state (window-state-get other-window)))
+ (window-state-put other-state original-window t)
+ (window-state-put original-state other-window t)))))
(evil-define-command evil-window-move-very-top ()
"Close the current window, split the upper-left one horizontally
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil a5ab49a490: Swap window sizes when exchanging windows,
ELPA Syncer <=