Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ always be `1`.

- You can delete the selected window by calling `ace-window` with a double prefix argument, i.e. <kbd>C-u C-u</kbd>.

- 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. <kbd>C--</kbd>

## 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:

- <kbd>x</kbd> - delete window
- <kbd>m</kbd> - swap (move) window
- <kbd>m</kbd> - swap window
- <kbd>M</kbd> - move window
- <kbd>r</kbd> - replace window
- <kbd>v</kbd> - split window vertically
- <kbd>b</kbd> - split window horizontally
- <kbd>n</kbd> - select the previous window
Expand Down
23 changes: 22 additions & 1 deletion ace-window.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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."
Expand All @@ -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))
Expand Down Expand Up @@ -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)
Expand Down