/
mac-win-select.el
64 lines (51 loc) · 2.32 KB
/
mac-win-select.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;; my function for selecting windows ala 'avy-window'
(defun mac-win-select ()
"Next version of this function that attempts to use better
keybindings and add more contingencies for issues that have come
up outside of my standard window setup."
(interactive)
(let ((choice))
;; start here for ease of use
(select-window (car (window-at-side-list nil 'left)))
(setq choice
(format "%s" (key-description
(read-key-sequence
(concat
(propertize "Which window: " 'face '(italic default))
(propertize "f:" 'face '(bold default)) " top left "
(propertize "j:" 'face '(bold default)) " top right "
(propertize "o:" 'face '(bold default)) " other "
(propertize "m:" 'face '(bold default)) " minibuffer\n "
(propertize "d:" 'face '(bold default)) " middle left "
(propertize "k:" 'face '(bold default)) " middle right\n "
(propertize "s:" 'face '(bold default)) " bottom right "
(propertize "l:" 'face '(bold default)) " bottom left")))))
(cond
((string= choice "f")
(select-window (car (window-at-side-list nil 'left))))
((string= choice "j")
(select-window (car (window-at-side-list nil 'right))))
((string= choice "d")
(select-window (car (cdr (window-at-side-list nil 'left)))))
((string= choice "k")
(select-window (car (cdr (window-at-side-list nil 'right)))))
((string= choice "s")
(select-window (car (nthcdr 2 (window-at-side-list nil 'left)))))
((string= choice "l")
(select-window (car (nthcdr 2 (window-at-side-list nil 'right)))))
;; minibuffer window
((string= choice "m")
(select-window (minibuffer-window)))
;; something else
((string= choice "o")
(while
(string= choice "o")
(progn
(other-window 1)
(setq choice (read-key-sequence "key: ")))))
;; default to top left window under most circumstances
(t
(select-window (car (window-at-side-list nil 'left)))))
(message "")
))
(global-set-key (kbd "C-'") 'mac-win-select)