-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.el
326 lines (267 loc) · 9.48 KB
/
init.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
(live-load-config-file "bindings.el")
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(load "~/.live-packs/josephwilk-pack/electric.el")
(color-theme-electric)
(defun move-region (start end n)
"Move the current region up or down by N lines."
(interactive "r\np")
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(let ((start (point)))
(insert line-text)
(setq deactivate-mark nil)
(set-mark start))))
(defun move-region-up (start end n)
"Move the current line up by N lines."
(interactive "r\np")
(move-region start end (if (null n) -1 (- n))))
(defun move-region-down (start end n)
"Move the current line down by N lines."
(interactive "r\np")
(move-region start end (if (null n) 1 n)))
;;F is left side B is right side. Obey logical positioning
(global-set-key (kbd "C-f") 'backward-char)
(global-set-key (kbd "C-b") 'forward-char)
(global-set-key (kbd "M-f") 'backward-word)
(global-set-key (kbd "M-b") 'forward-word)
(global-set-key (kbd "C-c C-s") 'zone)
(global-set-key (kbd "C-x p") 'previous-buffer)
(global-set-key (kbd "C-x n") 'next-buffer)
(when (fboundp 'winner-mode) (winner-mode 0))
(require 'yasnippet)
(setq yas-snippet-dirs (append yas-snippet-dirs
'("~/.live-packs/josephwilk-pack/snippets")))
(yas-reload-all)
;;(load "~/.live-packs/josephwilk-pack/animations/algo.el")
(load "~/.live-packs/josephwilk-pack/animations/end-of-buffer.el")
;;(load "~/.live-packs/josephwilk-pack/animations/the-stars.el")
;;(load "~/.live-packs/josephwilk-pack/animations/waves.el")
;;(load "~/.live-packs/josephwilk-pack/animations/upcase.el")
(defun clojure-set-up-key-bindings ()
(define-key cider-mode-map (kbd "M-RET") 'cider-eval-defun-at-point)
(define-key cider-mode-map (kbd "C-M-RET") 'cider-eval-region))
(add-hook 'cider-mode-hook 'clojure-set-up-key-bindings)
(defun zone-pgm-md5 ()
"MD5 the buffer, then recursively checksum each hash."
(let ((prev-md5 (buffer-substring-no-properties ;; Initialize.
(point-min) (point-max))))
;; Whitespace-fill the window.
(zone-fill-out-screen (window-width) (window-height))
(random t)
(goto-char (point-min))
(while (not (input-pending-p))
(when (eobp)
(goto-char (point-min)))
(while (not (eobp))
(delete-region (point) (line-end-position))
(let ((next-md5 (md5 prev-md5)))
(insert next-md5)
(setq prev-md5 next-md5))
(forward-line 1)
(zone-park/sit-for (point-min) 0.1)))))
(defun music-layout () "Music split"
(interactive)
(progn
(split-window-horizontally)
(win-switch-right)
(minimize-window)
(win-switch-left)))
(defun test-layout () "Code split"
(interactive)
(progn
(split-window-horizontally)
(win-switch-right)
(win-switch-left)))
(defun all-off () "All drums on"
(interactive)
(progn
(save-excursion
(replace-string " #k=_" " k=_" nil (point-min) (point-max))
(replace-string " #s=_" " s=_" nil (point-min) (point-max))
(replace-string " #p=_" " p=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun all-on () "All drums off"
(interactive)
(progn
(save-excursion
(replace-string " k=_" " #k=_" nil (point-min) (point-max))
(replace-string " s=_" " #s=_" nil (point-min) (point-max))
(replace-string " p=_" " #p=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun drum-off () "Drums off"
(interactive)
(progn
(save-excursion
(replace-string " #k=_" " k=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun drum-on () "Drums on"
(interactive)
(progn
(save-excursion
(replace-string " k=_" " #k=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun drum-toggle () "Drums off/on"
(interactive)
(progn
(if (eql drum-mode 'drum-on)
(setf drum-mode 'drum-off)
(setf drum-mode 'drum-on))
(funcall drum-mode)))
(defun snare-off () "Snare off"
(interactive)
(progn
(save-excursion
(replace-string " #s=_" " s=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun snare-on () "Snare on"
(interactive)
(progn
(save-excursion
(replace-string " s=_" " #s=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun snare-toggle () "Snare off/on"
(interactive)
(progn
(if (eql snare-mode 'snare-on)
(setf snare-mode 'snare-off)
(setf snare-mode 'snare-on))
(funcall snare-mode)))
(defun perc-off () "Percussion off"
(interactive)
(progn
(save-excursion
(replace-string " #p=_" " p=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun perc-on () "Percussion on"
(interactive)
(progn
(save-excursion
(replace-string " p=_" " #p=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun perc2-off () "Percussion2 off"
(interactive)
(progn
(save-excursion
(replace-string " #pp=_" " pp=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun perc2-on () "Percussion on"
(interactive)
(progn
(save-excursion
(replace-string " pp=_" " #pp=_" nil (point-min) (point-max))
(sonic-pi-send-buffer))))
(defun perc-toggle () "Perc off/on"
(interactive)
(progn
(if (eql perc-mode 'perc-on)
(setf perc-mode 'perc-off)
(setf perc-mode 'perc-on))
(funcall perc-mode)))
(defun perc2-toggle () "Perc2 off/on"
(interactive)
(progn
(if (eql perc2-mode 'perc2-on)
(setf perc2-mode 'perc2-off)
(setf perc2-mode 'perc2-on))
(funcall perc2-mode)))
(defvar perc2-mode 'perc2-off)
(defvar perc-mode 'perc-off)
(defvar drum-mode 'drum-off)
(defvar snare-mode 'snare-off)
(global-set-key (kbd "<f9>") 'perc2-off)
(global-set-key (kbd "<f10>") 'perc-off)
(global-set-key (kbd "<f11>") 'snare-off)
(global-set-key (kbd "<f12>") 'drum-off)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(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))))
;;Sane Navigation
(global-set-key (kbd "M-u") 'backward-word)
(global-set-key (kbd "M-o") 'forward-word)
(global-set-key (kbd "M-j") 'backward-char)
(global-set-key (kbd "M-l") 'forward-char)
(global-set-key (kbd "M-i") 'previous-line)
(global-set-key (kbd "M-k") 'next-line)
(global-hl-line-mode -1)
(add-to-list 'load-path "/Users/josephwilk/Workspace/josephwilk/emacs/sonic-pi.el/")
(require 'sonic-pi-mode)
(require 'sonic-pi)
(setq sonic-pi-path "/Users/josephwilk/Workspace/josephwilk/c++/sonic-pi/app/")
(add-to-list 'ac-modes 'sonic-pi-mode)
;;(add-to-list 'load-path "~/Workspace/repl-eletric/tidal/")
;;(require 'haskell-mode)
;;(require 'tidal)
;;(setq tidal-interpreter "/usr/local/bin/ghci")
;;cider
(setq cider-repl-display-help-banner nil)
(setq cider-repl-display-in-current-window t)
(setq cider-auto-select-error-buffer nil)
;;Sane reg-builder
(require 're-builder)
(setq reb-re-syntax 'string)
(require 'unicode-fonts)
(unicode-fonts-setup)
(setq-default show-trailing-whitespace nil)
(setq-default mode-require-final-newline nil)
(require 'emojify)
(setq emojify-set-emoji-styles 'unicode)
(setq emojify-display-style 'unicode)
(define-key function-key-map "\e[1;9A" [M-up])
(define-key function-key-map "\e[1;9B" [M-down])
(define-key function-key-map "\e[1;9C" [M-right])
(define-key function-key-map "\e[1;9D" [M-left])
(define-key function-key-map "\e[1;10A" [M-shift-up])
(define-key function-key-map "\e[1;10B" [M-shift-down])
;;(global-set-key [M-up] 'move-region-up)
;;(global-set-key [M-down] 'move-region-down)
(load "~/.live-packs/josephwilk-pack/lib/live-numbers.el")