-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot.emacs
393 lines (340 loc) · 13.5 KB
/
dot.emacs
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
;;;; -*- mode: emacs-lisp -*-
(require 'package)
(add-to-list 'package-archives
'("tromey" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(
starter-kit
starter-kit-eshell
starter-kit-bindings
auto-complete
ac-slime
ac-helm
zenburn-theme
dsvn
clojure-mode
nrepl
haskell-mode
ruby-compilation
shoulda
markdown-mode
yaml-mode
tuareg
marmalade
oddmuse
js2-mode
twittering-mode
jabber
yasnippet
ace-jump-mode
multiple-cursors
expand-region
wgrep
magit-svn
puppet-mode
vkill
google-this
google-maps
google-translate
nodejs-repl
coffee-mode
elnode
julia-mode
flycheck
))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(add-to-list 'load-path (concat user-emacs-directory "include/"))
(load-theme 'zenburn t)
;;;; Darwin fixes
(require 'dired)
(when (eq system-type 'darwin)
(setq ns-function-modifier 'hyper)
(menu-bar-mode 1)
(setenv "LANG" "en_US.UTF-8")
(setq dired-use-ls-dired nil)
(setq exec-path (append exec-path '("/usr/local/bin")))
(setenv "PATH" "/Users/mjcurry/bin:/opt/local/libexec/gnubin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"))
;;;; make unlimited (was cutting off function names, which breaks things
(require 'imenu)
(setq imenu-max-item-length t)
;;;; Shut off auto fill mode
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
;;;; Enable flycheck everywhere
(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)
;;;; ace-jump
(require 'ace-jump-mode)
(global-set-key (kbd "C-c SPC") 'ace-jump-mode)
;;;; multiple-cursor mode
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-c C->") 'mc/mark-more-like-this-extended)
;;;; expand-region
(require 'expand-region)
(global-set-key (kbd "s-=") 'er/expand-region)
(global-set-key (kbd "s--") 'er/contract-region)
;;;; ido & smex
(require 'smex)
(ido-mode 1)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
;;;; magit-status binding
(require 'magit)
(global-set-key (kbd "C-c g") 'magit-status)
(require 'magit-svn)
;;;; full screen magit-status
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)
;;;; jabber
(eval-after-load 'jabber
(progn
(setq jabber-account-list (quote (("mcurry@im.skarven.net" (:port . 5223) (:connection-type . ssl)))))
(setq jabber-autoaway-method nil)
(setq jabber-chat-foreign-prompt-format "[%t] %n>
")
(setq jabber-chat-local-prompt-format "[%t] %n>
")
(setq jabber-roster-show-title nil)))
;;;; toggle horizontal/vertical splitting
(defun toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(global-set-key [f9] 'toggle-window-split)
;;;; writable grep buffers via toggling off read-only (similar to
;;;; wdired mode for dired buffers)
(require 'wgrep)
(define-key grep-mode-map (kbd "C-x C-q") 'wgrep-change-to-wgrep-mode)
(setq wgrep-auto-save-buffer t)
;;;; Reset yasnippet trigger key
(require 'yasnippet)
(setq yas/trigger-key (kbd "C-c <kp-multiply>"))
(define-key yas/keymap (kbd "TAB") nil)
(yas-global-mode 1)
(add-to-list 'yas/root-directory
(car (file-expand-wildcards
"~/.emacs.d/elpa/yasnippet-*/snippets")))
(mkdir "~/.emacs.d/snippets" t)
(add-to-list 'yas/root-directory "~/.emacs.d/snippets")
(yas/reload-all)
;;;; auto-complete-mode
(require 'auto-complete-config)
(global-set-key (kbd "C-:") 'ac-complete-with-helm)
(define-key ac-complete-mode-map (kbd "C-:") 'ac-complete-with-helm)
(add-to-list 'ac-dictionary-directories
(expand-file-name "~/.ac-dict"))
;;;; ac-common-setup is called by ac-config-default
(defun ac-common-setup ()
(add-to-list 'ac-sources 'ac-source-yasnippet))
(add-to-list 'ac-modes 'html-mode)
(add-to-list 'ac-modes 'nxml-mode)
(ac-config-default)
(defun enable-auto-complete-mode ()
(auto-complete-mode 1))
(defun disable-auto-complete-mode ()
(auto-complete-mode 0))
;;;; Stop making backup files
(setq make-backup-files nil)
;;;; Make control tab switch buffer windows
(global-set-key [(control tab)] 'other-window)
(defun other-window-backwards (&optional count all-frames)
(interactive)
(other-window (if count (- count) -1) all-frames))
(global-set-key [(control shift iso-lefttab)] 'other-window-backwards)
;;;; Make meta g to goto-line
(global-set-key [(meta g)] 'goto-line)
;;;; set F5 key to revert-buffer
(defun reset-buffer ()
"Resets a file-buffer reflect the file on disk, resetting modes"
(interactive) (revert-buffer nil t nil))
(global-set-key [f5] 'reset-buffer)
;;;; set f8 to be recompile, shift-f8 to compile, scroll compile buffer
(defun compile-asking-directory (top-level)
(interactive "DProject toplevel directory: ")
(let ((default-directory top-level))
(call-interactively 'compile)))
(global-set-key [f8] 'recompile)
(global-set-key [S-f8] 'compile-asking-directory)
(global-set-key [C-S-f8] 'compile)
(setq compilation-scroll-output t)
;;;; allow color in compilation buffer
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
;;;; Make C-h C-s go to apropos (basically apropos-symbol)
(global-set-key [(control h) (control s)] 'apropos)
;;;; Advise the shell commands to name the buffer after the command itself
(defadvice async-shell-command (before buffer-named-with-command
(command &optional output-buffer error-buffer)
activate compile)
(setq output-buffer (or output-buffer (concat "*Async: " command "*")))
(let ((dir default-directory))
(switch-to-buffer output-buffer)
(setq default-directory dir)))
(defadvice shell-command (before buffer-named-with-command
(command &optional output-buffer error-buffer)
activate compile)
(setq output-buffer (or output-buffer (concat "*Shell: " command "*")))
(let ((dir default-directory))
(switch-to-buffer output-buffer)
(setq default-directory dir)))
;;;; Remap shortcuts to use async-shell-command by default
(global-set-key [(meta !)] 'async-shell-command)
(global-set-key [(control meta !)] 'shell-command)
;;;; dired mode added it's own key, ensure it is gone.
(require 'dired)
(define-key dired-mode-map [(meta !)] nil)
;;;; Buffer menu mode sort function
(defun buffer-list-sort (column)
(interactive "SColumn to sort by (one of name,size,mode,file,time [default=time]): ")
(case column
(name (Buffer-menu-sort 2))
(size (Buffer-menu-sort 3))
(mode (Buffer-menu-sort 4))
(file (Buffer-menu-sort 5))
(t (Buffer-menu-sort nil))))
(defun Buffer-mode-sort-key-hook ()
(define-key Buffer-menu-mode-map (kbd "S") 'buffer-list-sort))
(add-hook 'Buffer-menu-mode-hook 'Buffer-mode-sort-key-hook)
;;;; Allow terminal colorization
(ansi-color-for-comint-mode-on)
;;;; Highlight entire expression within parens
(show-paren-mode t)
(setq show-paren-style 'expression)
(set-face-background 'show-paren-match-face "#1f3f3f")
;;;; Don't spawn a new frame for the ediff commands, keep it all in one frame
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;;;; Have ediff buffers show in a side-by-side view
(setq ediff-split-window-function 'split-window-horizontally)
;;;; Set browser
(dolist (executable (list "google-chrome" "chromium-browser" "firefox"))
(let ((browser-path (executable-find executable)))
(when browser-path
(setq browse-url-generic-program browser-path
browse-url-browser-function 'browse-url-generic)
(return browser-path))))
;;;; edit-server for chromium browsers
(when (locate-library "edit-server")
(require 'edit-server)
(edit-server-start))
;;;; Add an alias to eshell to fork off processes
(defun eshell/fork (&rest args)
(lexical-let ((cmd ""))
(dolist (arg args)
(setf cmd (concat cmd " " arg)))
(setf cmd (subseq cmd 1))
(async-shell-command cmd)))
;;;; Some rcirc mode configuration
(setq rcirc-default-full-name "Matthew Curry")
;;;; Twittering mode
(setq twittering-use-master-password t)
;;;; shoulda
(require 'shoulda)
(define-key ruby-mode-map (kbd "C-c s") 'shoulda-run-should-at-point)
;;;; js2 indent 2 spaces
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.json\\'" . js2-mode))
(set-default 'js2-basic-offset 2)
(set-default 'js2-mirror-mode nil)
(set-default 'js2-mode-escape-quotes nil)
(define-key js2-mode-map (kbd "C-M-p")
(lambda ()
(interactive)
(js2-beginning-of-defun)))
(define-key js2-mode-map (kbd "C-M-n")
(lambda ()
(interactive)
(js2-end-of-defun)))
(define-key js2-mode-map (kbd "C-c m") 'js2-mark-defun)
;;;; Enable paredit-mode for all lisps, disable paredit's C-j
(require 'paredit)
(define-key paredit-mode-map (kbd "C-j") nil)
(define-key paredit-mode-map (kbd "C-M-n") 'paredit-forward)
(define-key paredit-mode-map (kbd "C-M-p") 'paredit-backward)
(define-key paredit-mode-map (kbd "C-M-f") 'paredit-forward-up)
(define-key paredit-mode-map (kbd "C-M-b") 'paredit-backward-down)
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)
(add-hook 'ielm-mode-hook 'enable-paredit-mode)
(add-hook 'lisp-mode-hook 'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook 'enable-paredit-mode)
(add-hook 'scheme-mode-hook 'enable-paredit-mode)
(add-hook 'inferior-scheme-mode-hook 'enable-paredit-mode)
;;;; Advice for ielm-mode
(defadvice ielm-eval-input (after ielm-paredit activate)
"Begin each IELM prompt with a ParEdit parenthesis pair."
(paredit-open-round))
;;;; scheme program, use chicken
(setq scheme-program-name "csi -:c")
;;;; chicken-scheme setup
(require 'chicken-scheme)
(add-hook 'scheme-mode-hook 'setup-chicken-scheme)
(define-key scheme-mode-map (kbd "C-?") 'chicken-show-help)
;;;; Load and setup slime
(let ((slime-helper (expand-file-name "~/quicklisp/slime-helper.el")))
(when (file-exists-p slime-helper)
(load slime-helper)
(setq slime-net-coding-system 'utf-8-unix)
(setq slime-lisp-implementations
'((sbcl ("/usr/local/bin/sbcl") :coding-system utf-8-unix)
(ecl ("/usr/local/bin/ecl"))))
;; slime-connect to stumpwm
(defun stumpwm-connect ()
"slime-connect to stumpwm"
(interactive)
(slime-connect "127.0.0.1" 5004))
;;;; Enable slime completion
(require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(add-to-list 'ac-modes 'slime-repl-mode)
(add-hook 'slime-mode-hook
(lambda () (define-key slime-mode-map [(tab)]
'slime-indent-and-complete-symbol)))
(add-hook 'slime-repl-mode-hook
(lambda () (define-key slime-repl-mode-map [(tab)]
'slime-indent-and-complete-symbol)))
;;;; Hook in paredit to slime
(add-hook 'slime-mode-hook 'enable-paredit-mode)
(add-hook 'slime-repl-mode-hook 'enable-paredit-mode)))