-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.el
146 lines (129 loc) · 5.07 KB
/
window.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
;;; window.el --- window movement and setup -*- lexical-binding: t; -*-
(load-config "autoloads/window.el")
;;;###autoload
(defun jds/ace-window-save-excursion ()
"Ace-window but return to window selected when calling function."
(interactive)
(let ((window (selected-window)))
(call-interactively #'ace-window)
(select-window window)))
(use-package ace-window
:straight t
:init
(setq aw-background nil)
(setq aw-keys '(?a ?d ?g ?h ?k ?l ?y ?r ?q ?w ?b ?c ?j ?n))
:config
;; get more consistent bindings with my setup everywhere else
;; customize movement action
(setq aw-dispatch-always t
aw-minibuffer-flag nil)
(setq aw-dispatch-alist
'((?x aw-delete-window "Delete Window")
(?m aw-swap-window "Swap Windows")
(?p aw-move-window "Move Window")
(?P aw-delete-and-move-window "Move Window and Delete")
(?v aw-move-window-split-right "Move Window to right")
(?V aw-delete-and-move-window-split-right "Move Window to right and Delete")
(?s aw-move-window-split-below "Move Window below")
(?S aw-delete-and-move-window-split-below "Move Window below and Delete")
(?f aw-move-window-split-fair "Move Window fair split")
(?F aw-delete-and-move-window-split-fair "Move Window fair split")
;; (?c aw-copy-window "Copy Window")
;; (?j aw-switch-buffer-in-window "Select Buffer")
;; (?n aw-flip-window "Jump to previous window")
(?u aw-switch-buffer-other-window "Switch Buffer Other Window")
(?e aw-execute-command-other-window "Execute Command Other Window")
;; (?= aw-split-window-fair "Split Fair Window")
;; (?s aw-split-window-vert "Split Vert Window")
;; (?v aw-split-window-horz "Split Horz Window")
(?o delete-other-windows "Delete Other Windows")
;; (?T aw-transpose-frame "Transpose Frame")
;; ?i ?r ?t are used by hyperbole.el
(?? aw-show-dispatch-help)))
(setq aw-scope 'visible)
(ace-window-display-mode t) ; display labels in mode line -- works for x windows
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 2.5 :foreground "red"))))))
;; (use-package ace-window-posframe
;; :straight (ace-window-posframe :type git :host github :repo "abo-abo/ace-window")
;; :config (ace-window-posframe-mode 1))
;;;###autoload
(defun aw-move-window-split-fair (window)
"Like the default aw-move-window but splits based on target window dimension.
Controlled by `aw-fair-aspect-ratio'."
(let ((buffer (current-buffer))
(w (window-body-width window))
(h (window-body-height window)))
(aw-switch-to-window window)
(if (< (* h aw-fair-aspect-ratio) w)
(aw-split-window-horz window)
(aw-split-window-vert window))
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-delete-and-move-window-split-fair (window)
"Like the default aw-move-window but splits based on target window dimension.
Controlled by `aw-fair-aspect-ratio'."
(let ((buffer (current-buffer))
(w (window-body-width window))
(h (window-body-height window)))
(delete-window)
(aw-switch-to-window window)
(if (< (* h aw-fair-aspect-ratio) w)
(aw-split-window-horz window)
(aw-split-window-vert window))
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-delete-and-move-window (window)
"Move the current buffer to WINDOW, deleting current window.
Switch the current window to the previous buffer."
(let ((buffer (current-buffer)))
(delete-window)
(aw-switch-to-window window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-move-window-split-right (window)
"Like the default aw-move-window but splits and puts on right."
(let ((buffer (current-buffer)))
(switch-to-buffer (other-buffer))
(aw-switch-to-window window)
(split-window-right)
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-move-window-split-below (window)
"Like the default aw-move-window but splits and puts on below."
(let ((buffer (current-buffer)))
(switch-to-buffer (other-buffer))
(aw-switch-to-window window)
(split-window-below)
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-delete-and-move-window-split-right (window)
"Like the default aw-move-window but splits and puts on right."
(let ((buffer (current-buffer)))
(delete-window)
(aw-switch-to-window window)
(split-window-right)
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;;;###autoload
(defun aw-delete-and-move-window-split-below (window)
"Like the default aw-move-window but splits and puts on below."
(let ((buffer (current-buffer)))
(delete-window)
(aw-switch-to-window window)
(split-window-below)
(call-interactively #'other-window)
(switch-to-buffer buffer)))
;; from here https://github.com/abo-abo/ace-window/issues/125
;;;###autoload
(defun aw-previous-window ()
"Toggle between the last two selected windows."
(interactive)
(let ((win (get-mru-window t t t)))
(unless win (error "Last window not found."))
(aw-switch-to-window win)))