switchy-window

Homepage: https://sr.ht/~tsdh/switchy-window

Author: Tassilo Horn

Updated:

Summary

A most-recently-used window switcher

Commentary

switchy-window.el is a most-recently-used window switcher.  It suits my
personal Emacs layout and workflow where I usually have at most two editing
windows but up to three side-windows which I have to select only seldomly.

The idea of switchy-window is simple: when you invoke `switchy-window' in
quick succession, it will switch to one window after the other in
most-recently-used order.  Once you stop switching for long enough time
(`switchy-window-delay', 1.5 seconds by default), the selected window gets
locked in, i.e., its LRU timestamp is updated and this switching sequence is
ended.  Thusly, you can toggle between two windows simply by invoking
`switchy-window', waiting at least `switchy-window-delay', and then invoking
`switchy-window' again to switch back to the original window.

Activate `switchy-window-minor-mode' which tracks window changes and bind
`switchy-window' to a key of your liking in `switchy-window-minor-mode-map'
(or globally, see the variable's docstring for examples).

Hint: Since the order of window switching is not as obvious as it is with
`other-window', adding a bit visual feedback to window selection changes can
be helpful.  That can be done easily with the stock Emacs pulse.el, e.g.:

(defun my-pulse-line-on-window-selection-change (frame)
  (when (eq frame (selected-frame))
    (pulse-momentary-highlight-one-line)))

(add-hook 'window-selection-change-functions
          #'my-pulse-line-on-window-selection-change)

Dependencies