ресайз окон defun win-resize-top-or-bo Figure out if the current windo

 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
;; ресайз окон
(defun win-resize-top-or-bot ()
"Figure out if the current window is on top, bottom or in the
middle"
(let* ((win-edges (window-edges))
(this-window-y-min (nth 1 win-edges))
(this-window-y-max (nth 3 win-edges))
(fr-height (frame-height)))
(cond
((eq 0 this-window-y-min) "top")
((eq (- fr-height 1) this-window-y-max) "bot")
(t "mid"))))
(defun win-resize-left-or-right ()
"Figure out if the current window is to the left, right or in the
middle"
(let* ((win-edges (window-edges))
(this-window-x-min (nth 0 win-edges))
(this-window-x-max (nth 2 win-edges))
(fr-width (frame-width)))
(cond
((eq 0 this-window-x-min) "left")
((eq (+ fr-width 4) this-window-x-max) "right")
(t "mid"))))
(defun win-resize-enlarge-horiz ()
(interactive)
(cond
((equal "top" (win-resize-top-or-bot)) (enlarge-window -1))
((equal "bot" (win-resize-top-or-bot)) (enlarge-window 1))
((equal "mid" (win-resize-top-or-bot)) (enlarge-window -1))
(t (message "nil"))))
(defun win-resize-minimize-horiz ()
(interactive)
(cond
((equal "top" (win-resize-top-or-bot)) (enlarge-window 1))
((equal "bot" (win-resize-top-or-bot)) (enlarge-window -1))
((equal "mid" (win-resize-top-or-bot)) (enlarge-window 1))
(t (message "nil"))))
(defun win-resize-enlarge-vert ()
(interactive)
(cond
((equal "left" (win-resize-left-or-right)) (enlarge-window-horizontally -1))
((equal "right" (win-resize-left-or-right)) (enlarge-window-horizontally 1))
((equal "mid" (win-resize-left-or-right)) (enlarge-window-horizontally -1))))
(defun win-resize-minimize-vert ()
(interactive)
(cond
((equal "left" (win-resize-left-or-right)) (enlarge-window-horizontally 1))
((equal "right" (win-resize-left-or-right)) (enlarge-window-horizontally -1))
((equal "mid" (win-resize-left-or-right)) (enlarge-window-horizontally 1))))
(global-set-key [C-M-down] 'win-resize-mi2nimize-vert)
(global-set-key [C-M-up] 'win-resize-enlarge-vert)
(global-set-key [C-M-left] 'win-resize-minimize-horiz)
(global-set-key [C-M-right] 'win-resize-enlarge-horiz)
(global-set-key [C-M-up] 'win-resize-enlarge-horiz)
(global-set-key [C-M-down] 'win-resize-minimize-horiz)
(global-set-key [C-M-left] 'win-resize-enlarge-vert)
(global-set-key [C-M-right] 'win-resize-minimize-vert)