I would like to be able to switch to an open window by typing the name of the buffer which is displayed in it. It would be something like C-x b which opens the selected buffer only if it is not opened in another windows and in that case the focus switch to that window.
For a slightly different approach, you can install the https://github.com/abo-abo/ace-window package (available from melpa) and bind
ace-window to some key sequence. When you invoke it, it gives each window a letter or number, which you can type to select. If you turn on
ace-window-display-mode this letter is also added to the mode line so you can see it in advance.
The answer to Defining the window pointed by "other-window" has a screencast showing it in action.
The package has extra features, for example if invoked with one universal argument it swaps the current window with the target window.
The https://github.com/abo-abo/ace-window/wiki has an extended example, with scrolling other windows,
winner-mode to save and restore window configurations and so on.
C-x o trips among windows or frames, as follows (
C-h k C-x o):
C-x oruns the command
icicle-other-window-or-framewhich is an interactive compiled Lisp function in
Select a window or frame, by name or by order.
This command combines Emacs commands
other-frame, together with Icicles commands
Use the prefix argument to choose the behavior, as follows:
With no prefix arg or a non-zero numeric prefix arg: If the selected frame has multiple windows, then this is
other-window. Otherwise, it is
With a zero prefix arg (e.g.
C-0): If the selected frame has multiple windows, then this is
icicle-select-windowwith windows in the frame as candidates. Otherwise (single-window frame), this is
C-u: If the selected frame has multiple windows, then this is
icicle-select-windowwith windows from all visible frames as candidates. Otherwise, this is
C-u C-u: Same as
icicle-select-windowwith a negative prefix arg: Select a window from any frame, including iconified and invisible frames.
C-u C-u C-u: This is
icicle-choose-window-for-buffer-display, with windows from all frames (i.e., iconified and invisible) frames as candidates.
If you use library
oneonone.elwith a standalone minibuffer frame, and if option
1on1-remap-other-frame-command-flagis non-nil, then frame selection can include the standalone minibuffer frame.
By default, Icicle mode remaps all key sequences that are normally bound to
icicle-other-window-or-frame. If you do not want this remapping, then customize option
(defun open-window-by-buffer (buffer) (interactive "bBuffer: ") (select-window (get-buffer-window buffer) nil))
ido-mode for selecting things like open buffers, so here's a solution using that:
(defun open-window-by-buffer () (interactive) (let ((buffer (ido-completing-read "Buffer: " (mapcar 'buffer-name (buffer-list))))) (select-window (get-buffer-window buffer) nil)))