-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
executable file
·218 lines (165 loc) · 5.55 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Install all the required packages
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(starter-kit starter-kit-bindings starter-kit-eshell
starter-kit-js starter-kit-lisp
yaml-mode sass-mode
rainbow-delimiters rainbow-mode
fill-column-indicator multi-term coffee-mode
rinari handlebars-mode markdown-mode guru-mode
js2-mode))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(add-to-list 'load-path "~/.emacs.d/vendor")
(add-to-list 'load-path "~/.emacs.d/vendor/nxhtml")
(add-to-list 'load-path "~/.emacs.d/vendor/yaml")
(add-to-list 'load-path "~/.emacs.d/themes")
(setq custom-file "~/.emacs.d/custom.el")
(if (file-readable-p custom-file)
(load custom-file))
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(server-start)
(load-theme 'zenburn)
;; TODO: Maybe turn off hl-line-mode?
(when (eq system-type 'darwin)
(require 'pbcopy)
(turn-on-pbcopy)
(setq ls-lisp-use-insert-directory-program nil)
(require 'ls-lisp))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Modes and Hooks
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Minor modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq abbrev-file-name "~/.emacs.d/abbrev_defs")
(setq save-abbrevs t)
(quietly-read-abbrev-file)
(setq default-abbrev-mode t)
(winner-mode t)
(column-number-mode)
(linum-mode)
(guru-global-mode)
(setq enable-recursive-minibuffers t)
(global-rainbow-delimiters-mode)
;;;;;;;;;;;;;;;;;;;;
;; Get the mouse working!
;;;;;;;;;;;;;;;;;;;;
(require 'mouse)
(xterm-mouse-mode)
(defun track-mouse (e))
;;;;;;;;;;;;;;;;;;;;
;; Hooks
;;;;;;;;;;;;;;;;;;;;
(add-hook 'before-save-hook 'whitespace-cleanup)
(set-default 'tab-width 4)
(set-default 'indent-tabs-mode nil)
(setq longlines-auto-wrap t)
;;;;;;;;;;;;;;;;;;;;
;; Coffeescript
;;;;;;;;;;;;;;;;;;;;
(defun coffee-custom ()
(make-local-variable 'tab-width)
(set 'tab-width 2))
(add-hook 'coffee-mode-hook 'coffee-custom)
;;;;;;;;;;;;;;;;;;;;
;; CSS / SASS
;;;;;;;;;;;;;;;;;;;;
(defun css-options ()
"My CSS options"
(setq css-indent-offset 2))
(add-hook 'css-mode-hook 'css-options)
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'sass-mode-hook 'rainbow-mode)
(add-to-list 'auto-mode-alist '("\\.scss$" . sass-mode))
;;;;;;;;;;;;;;;;;;;;
;; Dired
;;;;;;;;;;;;;;;;;;;;
(put 'dired-find-alternate-file 'disabled nil)
(add-hook 'dired-mode-hook 'ensure-buffer-name-ends-in-slash)
(defun ensure-buffer-name-ends-in-slash ()
"change buffer name to end with slash"
(let ((name (buffer-name)))
(if (not (string-match "/$" name))
(rename-buffer (concat name "/") t))))
;;;;;;;;;;;;;;;;;;;;
;; HAML
;;;;;;;;;;;;;;;;;;;;
(add-hook 'haml-mode-hook 'rainbow-delimiters-mode)
;;;;;;;;;;;;;;;;;;;;
;; Handlebars
;;;;;;;;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.hbs$" . handlebars-mode))
;;;;;;;;;;;;;;;;;;;;
;; iBuffer
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;
;; JS2
;;;;;;;;;;;;;;;;;;;;
(setq js2-basic-offset 2)
;;;;;;;;;;;;;;;;;;;;
;; Magit
;;;;;;;;;;;;;;;;;;;;
(setq magit-default-tracking-name-function 'magit-default-tracking-name-branch-only)
(global-set-key (kbd "C-c m b") 'magit-blame-mode)
(global-set-key (kbd "C-c m f l") 'magit-file-log)
;;;;;;;;;;;;;;;;;;;;
;; Multi-term
;;;;;;;;;;;;;;;;;;;;
(require 'multi-term)
(global-set-key (kbd "C-c t") 'multi-term-next)
(global-set-key (kbd "C-c C-t") 'multi-term)
(defun map-term-line ()
(local-set-key (kbd "C-c C-j") 'term-line-mode))
(add-hook 'term-mode-hook 'map-term-line)
;;;;;;;;;;;;;;;;;;;;
;; Ruby
;;;;;;;;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\thor$" . ruby-mode))
(defun ruby-generate-tags()
(interactive)
(let ((root (ffip-project-root)))
(let ((my-tags-file (concat root "TAGS")))
(message "Regenerating TAGS file: %s" my-tags-file)
(if (file-exists-p my-tags-file)
(delete-file my-tags-file))
(shell-command
(format
"find %s -iname '*.rb' -not -regex \".*vendor.*\"| grep -v db | xargs /usr/local/bin/ctags.old -e -a %s"
root my-tags-file))
(if (get-file-buffer my-tags-file)
(kill-buffer (get-file-buffer my-tags-file)))
(visit-tags-table my-tags-file))))
;;;;;;;;;;;;;;;;;;;;
;; Shell
;;;;;;;;;;;;;;;;;;;;
(add-to-list 'auto-mode-alist '("\\.zsh$" . shell-script-mode))
;;;;;;;;;;;;;;;;;;;;
;; YAML
;;;;;;;;;;;;;;;;;;;;
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "\C-xg") 'magit-status)
(global-set-key (kbd "\C-xm") 'smex)
(global-set-key (kbd "\C-x\C-m") 'smex)
(global-set-key (kbd "\C-x\C-b") 'ibuffer)
(global-set-key (kbd "\C-xf") 'find-file-in-project)
;; Needed for iTerm, since Shift-Up sends <select>
(global-set-key (kbd "<select>") 'windmove-up)
(put 'ido-exit-minibuffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)