From 9aec100f72237ee0be23c5b1774e323dc9d04d37 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Fri, 19 Jun 2015 15:31:41 +0200 Subject: [PATCH] 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)