Poyekhali!20 Dec 2014
My name is Oleh and I've been using Emacs for about 3 years now. I think that it's an awesome editor, and I've accumulated some know-how to make it even better (at least for me and people who think like me). Sharing is caring, so here we go.
On this weekend I've made a major update to my package ace-window that allows it to be used as a library. Luckily the change went smoothly, as there are no complaints in the github issues so far. In case you don't know what the package does in the first place, a short blurb follows.
ace-window's "what and why"
I'm sure you're aware of the
other-window command. While it's great for
two windows, it quickly loses its value when there are more windows:
you need to call it many times, and since it's not easily predictable,
you have to check each time if you're in the window that you wanted.
Another approach is to use
windmove-up etc. These
are fast and predictable. Their disadvantage is that they need 4 key
bindings. The default ones are shift+arrows, which are hard to reach.
This package aims to take the speed and predictability of
and pack it into a single key binding, similar to
achieve this, I'm using the excellent
Here's how the package looks in action: ace-window.gif
Since switching windows is a frequently used operation, I recommend
ace-window to something short, like M-p.
By default, three actions are available:
- M-p - select window
- C-u M-p - swap the current window with the selected window
- C-u C-u M-p - delete the selected window
finally, the library part
So now, what if you want to select a window to maximize with
After the change that I've mentioned, the code to do this is dirt simple:
(defun ace-maximize-window () "Ace maximize window." (interactive) (setq aw--current-op (lambda (aj) (let ((wnd (aj-position-window aj))) (select-window wnd) (delete-other-windows)))) (aw--doit " Ace - Maximize Window")) (global-set-key (kbd "C-M-o") 'ace-maximize-window)