Skip to content

Instantly share code, notes, and snippets.

@ajchemist
Created May 29, 2014 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajchemist/b61ef6a395df7b0b48c3 to your computer and use it in GitHub Desktop.
Save ajchemist/b61ef6a395df7b0b48c3 to your computer and use it in GitHub Desktop.
(defun winnum-select (&optional num)
"Selects the nth window."
(interactive (list (let (_)
(while (or (not (characterp _))
(<= _ 48) ; 0 not included
(and (> _ 57) (< _ 97))
(> _ 122))
(setq _ (read-event
#("Switch to Winnum: " 0 18
(face minibuffer-prompt)))))
(cond ((> _ 96) (setq _ (- _ 87)))
(t (setq _ (- _ 48))))
_)))
(let ((window (nth (1- num) (winnum-list))))
(if (and window (or (not (window-minibuffer-p window))
(minibuffer-window-active-p window)))
(select-window window)
(error "No such window."))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment