Yet another approach -- Similar to the behavior of the answer that uses library Do Re Mi (doremi.el
), but using library Icicles instead.
Multi-command icicle-select-window
lets you move among windows by cycling using the up/down arrow keys, but by default you need to hold Control
pressed while doing that. (And you need to hit RET
to end the command to choose the last window selected.)
The reason is this: You can also select windows by name, using completion. Each window is given the name of its buffer (windows showing the same buffer are uniquified with a numerical suffix). And besides completing a name you can cycle among the names (completion candidates) using the arrow keys (without Control
). So: arrow keys to cycle among names; Control
+ arrow keys to cycle among them and select the windows at the same time.
So you can bind, say, C-x o
in icicle-mode-map
to command icicle-select-window
, then use C-x o C-<down> C-<down> C-<down>...
to successively select windows.
I said "by default" for the use of Control
because you can use M-g
in the minibuffer to flip its use, so that instead of needing to use Control
+ arrow key to act on a completion candidate you can use just the arrow key, and instead of using just the arrow key to cycle among window names you use Control
+ arrow key.
In that case, you would use just C-x o <down> <down> <down>...
(the same as for Do Re Mi).
You can roll this alternative behavior into its own command this way:
(defun my-icy-select-window ()
"Same as `icicle-select-window' but act without holding `Control'."
(interactive)
(let ((orig icicle-use-C-for-actions-flag))
(when orig (icicle-toggle-C-for-actions)) ; Same as `M-g`
(icicle-select-window)
(when orig (icicle-toggle-C-for-actions)))) ; Same as `M-g`
To bind C-x o
(or any other key) to, say, my-icy-select-window
you customize user option icicle-top-level-key-bindings
to add an entry for it. (Do not try to use define-key
with icicle-mode-map
.)
(kbd "C-x <right>")
, not(kbd "<C-x-right>")
. You can useC-h k
to see how Emacs denotes a key sequence.