diff --git a/README.md b/README.md index 59afd57..cd51b04 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,16 @@ always be `1`. - You can delete the selected window by calling `ace-window` with a double prefix argument, i.e. C-u C-u. +- You may replace the target window with the current one while closing current one by calling `ace-window` with a negative prefix argument, i.e. C-- + ## Change the action midway You can also start by calling `ace-window` and then decide to switch the action to `delete` or `swap` etc. By default the bindings are: - x - delete window -- m - swap (move) window +- m - swap window +- M - move window +- r - replace window - v - split window vertically - b - split window horizontally - n - select the previous window diff --git a/ace-window.el b/ace-window.el index e5bbd33..e5173cc 100644 --- a/ace-window.el +++ b/ace-window.el @@ -257,6 +257,7 @@ LEAF is (PT . WND)." '((?x aw-delete-window " Ace - Delete Window") (?m aw-swap-window " Ace - Swap Window") (?M aw-move-window " Ace - Move Window") + (?r aw-replace-window " Ace - Replace Window") (?n aw-flip-window) (?v aw-split-window-vert " Ace - Split Vert Window") (?b aw-split-window-horz " Ace - Split Horz Window") @@ -352,6 +353,13 @@ Amend MODE-LINE to the mode line for the duration of the selection." (aw-select " Ace - Swap Window" #'aw-swap-window)) +;;;###autoload +(defun ace-replace-window () + "Ace replace window." + (interactive) + (aw-select " Ace - Replace Window" + #'aw-replace-window)) + ;;;###autoload (defun ace-maximize-window () "Ace maximize window." @@ -372,9 +380,14 @@ buffer moves to current window (and current buffer moves to selected window). Prefixed with two \\[universal-argument]'s, deletes the selected -window." +window. + +Prefixed with a negative \\[universal-argument], replaces +selected window's buffer with current window's buffer, while +closing current window." (interactive "p") (cl-case arg + (-1 (ace-replace-window)) (0 (setq aw-ignore-on (not aw-ignore-on)) @@ -489,6 +502,14 @@ Switch the current window to the previous buffer." (aw-switch-to-window window) (switch-to-buffer buffer))) +(defun aw-replace-window (window) + "Move the current buffer to WINDOW. +Delete current window." + (let ((buffer (current-buffer))) + (delete-window) + (aw-switch-to-window window) + (switch-to-buffer buffer))) + (defun aw-split-window-vert (window) "Split WINDOW vertically." (select-window window)