Select the previous window with ace-window06 Mar 2015
It's strange that I haven't implemented this feature before, as it's quite a common usage pattern:
- You select a window with
- You do some stuff there.
- You want to return the previous window.
In the step 3, you have to go though the whole
only to select a window which can be pre-determined. Not any more, if
(defun aw-flip-window () "Switch to the window you were previously in." (interactive) (aw-switch-to-window (aw--pop-window)))
So now, you could have a grid of 10 windows, select one of them with
ace-window, and switch indefinitely between it and the previous
ace-flip-window, while ignoring the other 8.
Remember that if you have some window that you never want to switch to
ace-window, you can add it to
(defcustom aw-ignored-buffers '("*Calc Trail*" "*LV*") "List of buffers to ignore when selecting window." :type '(repeat string))
It's not a big deal, but it's convenient at least for this scenario:
- I start with one active window.
calc; now I have three windows.
- I can toggle back and forth between
calcand the main window with
ace-windowwithout having to type
*Calc Trail*is ignored, so that makes only two total windows.
Selecting last window during the
This is a really cool feature, in my opinion: for all three actions -
aw-delete-window, you can
select the previous window as a target with the same key n.
This is, of course, customizable:
(defcustom aw-flip-keys '("n") "Keys which should select the last window." :set (lambda (sym val) (set sym val) (setq aw--flip-keys (mapcar (lambda (x) (aref (kbd x) 0)) val))))
So you could have a whole list of bindings that select the previous
window during the
aw-keys dispatch. This is cool because there's no
visual feedback necessary, so this binding can be easily added to the
muscle memory. The bindings don't necessarily need to be single keys,
anything with one chord, e.g. C-f, is acceptable.
Here's how I've set it up for myself:
(global-set-key "ν" 'ace-window) (csetq aw-flip-keys '("n" "ν"))
This means that:
- I can select the previous window with νν - a double call to
- I can swap with the previous window with ψνν, ψ calls
- I can delete the previous window with ψψνν.
Thanks to @luciferasm for the idea, I hope you'll enjoy the new feature.