-
Notifications
You must be signed in to change notification settings - Fork 5
/
shampoo-layout.el
97 lines (81 loc) · 2.82 KB
/
shampoo-layout.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
;;; shampoo-layout.el --- Shampoo layout builder
;;
;; Copyright (C) 2010 - 2012 Dmitry Matveev <[email protected]>
;;
;; This software is released under terms of the MIT license,
;; please refer to the LICENSE file for details.
(eval-when-compile (require 'cl))
(require 'shampoo-modes)
(require 'shampoo-state)
(require 'shampoo-dict)
(defun shampoo-generic-splitter (args split-fcn)
(lexical-let ((row-funcs args)
(splitter split-fcn))
(lambda (wnd)
(let ((head (first row-funcs))
(tail (rest row-funcs)))
(dolist (f (reverse tail))
(funcall f (funcall splitter wnd)))
(funcall head wnd)))))
(defun shampoo-rows (&rest args)
(shampoo-generic-splitter args 'split-window))
(defun shampoo-cols (&rest args)
(shampoo-generic-splitter args (lambda (w) (split-window w nil t))))
(defun shampoo-build-layout (layout-desc)
(delete-other-windows)
(funcall layout-desc (selected-window))
(balance-windows))
(defun* shampoo-make-window-setup
(&key buffer-name mode-to-use set-binding)
(lexical-let ((buffer buffer-name)
(mode mode-to-use)
(binding set-binding))
(lambda (wnd)
(let ((buff (get-buffer-create buffer)))
(set-window-buffer wnd buff)
(with-current-buffer buff
(funcall mode))
(with-~shampoo~
(shampoo-dict-put
:key binding
:value wnd
:into (shampoo-current-main-windows ~shampoo~)))))))
(defun shampoo-layout-desc ()
(shampoo-rows
(shampoo-cols (shampoo-setup-namespaces-window)
(shampoo-setup-classes-window)
(shampoo-setup-categories-window)
(shampoo-setup-methods-window))
(shampoo-setup-source-window)))
(defun shampoo-setup-namespaces-window ()
(shampoo-make-window-setup
:buffer-name "*shampoo-namespaces*"
:mode-to-use 'shampoo-namespaces-list-mode
:set-binding :namespaces))
(defun shampoo-setup-classes-window ()
(shampoo-make-window-setup
:buffer-name "*shampoo-classes*"
:mode-to-use 'shampoo-classes-list-mode
:set-binding :classes))
(defun shampoo-setup-categories-window ()
(shampoo-make-window-setup
:buffer-name "*shampoo-categories*"
:mode-to-use 'shampoo-cats-list-mode
:set-binding :categories))
(defun shampoo-setup-methods-window ()
(shampoo-make-window-setup
:buffer-name "*shampoo-methods*"
:mode-to-use 'shampoo-methods-list-mode
:set-binding :methods))
(defun shampoo-setup-source-window ()
(shampoo-make-window-setup
:buffer-name "*shampoo-code*"
:mode-to-use 'shampoo-code-mode
:set-binding :source))
(defun shampoo-create-layout ()
(shampoo-build-layout (shampoo-layout-desc)))
(defun shampoo-restore-layout ()
(interactive)
(shampoo-create-layout))
(provide 'shampoo-layout)
;;; shampoo-layout.el ends here.