emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ace-window 9aec100 01/92: Allow to pop current buffer a


From: Stefan Monnier
Subject: [elpa] externals/ace-window 9aec100 01/92: Allow to pop current buffer and move it with "M" during dispatch
Date: Wed, 17 Mar 2021 18:39:10 -0400 (EDT)

branch: externals/ace-window
commit 9aec100f72237ee0be23c5b1774e323dc9d04d37
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    Allow to pop current buffer and move it with "M" during dispatch
    
    ace-window.el (aw-move-window): New defun.
    
    During dispatch, while in window-1, press "M" and select window-2.
    The buffer currently in window-1 will move to window-2.
    The most recently selected buffer will move to window-1.
    
    Fixes #56
    
    Use case: suppose you have many windows and you call
    `describe-function'. It pops up *Help* replacing a necessary buffer.
    The you can e.g. "M-p M a" to move the *Help* buffer to replace a less
    necessary buffer in window "a", while restoring the necessary buffer
    that *Help* previously replaced.
---
 ace-window.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ace-window.el b/ace-window.el
index a1c12ed..f528c4b 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -250,6 +250,7 @@ LEAF is (PT . WND)."
 (defvar aw-dispatch-alist
   '((?x aw-delete-window " Ace - Delete Window")
     (?m aw-swap-window " Ace - Swap Window")
+    (?M aw-move-window " Ace - Move Window")
     (?n aw-flip-window)
     (?v aw-split-window-vert " Ace - Split Vert Window")
     (?b aw-split-window-horz " Ace - Split Horz Window")
@@ -472,6 +473,14 @@ Windows are numbered top down, left to right."
             (swap-windows window this-window)
           (swap-windows this-window window))))))
 
+(defun aw-move-window (window)
+  "Move the current buffer to WINDOW.
+Switch the current window to the previous buffer."
+  (let ((buffer (current-buffer)))
+    (switch-to-buffer (other-buffer))
+    (aw-switch-to-window window)
+    (switch-to-buffer buffer)))
+
 (defun aw-split-window-vert (window)
   "Split WINDOW vertically."
   (select-window window)



reply via email to

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