I needed something to speed up my work when I have few windows, I was looking at switch-window.el, but it kind of silly that the content of the window disappear. So I’ve written this simple 2 functions which act similar to my other sollution Faster buffer bookmarking in Emacs. But you mark window to which you want to jump.
It set Keyboard C-c C-0 for mark and C-C C-<1-9> to jump.
(setq window-alist '()) (defun mark-window (number) "Give current window a number to select it later using `switch-to-number-window'" (interactive "nNumber Your Window: ") (let ((pair (assoc number window-alist)) (window (get-buffer-window))) (if pair (setf (cdr pair) window) (add-to-list 'window-alist (cons number window))))) (defun switch-to-number-window (number) "Jump to the window marked with a `mark-window' function" (interactive "nNumber Your Window: ") (let ((pair (assoc number window-alist))) (if pair (select-window (cdr pair)) (message "Invalid Number")))) ;; create 9 keyboard shortcuts using closure (forced using lexical-let) (dolist (i (map #'1+ (range 9))) (global-set-key (read-kbd-macro (concat "C-c C-" (number-to-string i))) (lexical-let ((i i)) (lambda () (interactive) (switch-to-number-window i))))) (global-set-key (kbd "C-c C-0") 'mark-window)
It use range helper function (same as in python)
(defun range (n &optional list) "function return list of numbers from 1 to n" (if (eq n 0) list (let ((n (- n 1))) (range n (cons n list)))))
EDIT: I just found windmove commands which are much better.