-
Notifications
You must be signed in to change notification settings - Fork 0
/
justin.el
executable file
·326 lines (267 loc) · 10.7 KB
/
justin.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
(setq user-full-name "Justin Richter")
(setq user-login-name "justin")
(setq user-mail-address "[email protected]")
;; Load packages not installed
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(clojure-mode
clojure-test-mode
nrepl
ac-nrepl
color-theme-sanityinc-tomorrow
color-theme-sanityinc-solarized
fill-column-indicator
auto-complete
undo-tree
diminish
js2-mode
js2-refactor
lua-mode
gnus
bbdb
flymake-python-pyflakes
flymake-ruby
flymake-lua
flymake-haml
flymake-json
flymake-css
flymake-sass
flymake-jslint
robe
))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
;; Set Google Chrome as default browser
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "google-chrome")
;; Set Google Chrome as default
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "google-chrome")
;; Make compilation window not steal a buffer
(setq special-display-buffer-names
'("*compilation*"))
(setq special-display-function
(lambda (buffer &optional args)
(split-window)
(switch-to-buffer buffer)
(get-buffer-window buffer 0)))
;; setup multi-term
(require 'multi-term)
(setq multi-term-program "/bin/zsh" )
;; flymake python :note pyflakes must be installed
(require 'flymake-python-pyflakes)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
;; js2-mode
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; load some js2-mode defaults from magnars
(eval-after-load 'js2-mode '(require 'setup-js2-mode))
(eval-after-load 'html-mode '(require 'setup-html-mode))
;; sh-mode stuff
(add-to-list 'auto-mode-alist '("\\.zsh-theme\\'" . sh-mode))
;; When splitting a buffer move point to new buffer
(defadvice split-window (after move-point-to-new-window activate)
"Moves the point to the newly created window after splitting."
(other-window 1))
;; After yank, indent region
(defadvice yank (after indent-region activate)
(if (member major-mode '(emacs-lisp-mode scheme-mode lisp-mode sh-mode js-mode js2-mode
c-mode c++-mode objc-mode ruby-mode slim-mode lua-mode clojure-mode
LaTeX-mode TeX-mode html-mode scss-mode css-mode))
(indent-region (region-beginning) (region-end) nil)))
;; Keybinding for commenting region
;; (global-set-key (kbd "C-;") 'comment-or-uncomment-region)
;; This is already enabled with M-; by default
;; terminal stuff
(global-set-key (kbd "C-x t") '(lambda ()(interactive)(ansi-term "/bin/zsh")))
;; Keybinding for ido find-file-at-point
(global-set-key (kbd "C-x a") 'find-file-at-point)
;; Some usefull keybindings
(global-set-key (kbd "C-w") 'backward-kill-word)
(global-set-key (kbd "C-x C-k") 'kill-region)
(global-set-key (kbd "C-c C-k") 'kill-region)
;; auto-complete mode
(require 'auto-complete-config)
;; ace-jump-mode
(global-set-key (kbd "C-c ;") 'ace-jump-mode)
(global-set-key (kbd "C-c :") 'ace-jump-word-mode)
(global-set-key (kbd "M-j")
(lambda ()
(interactive)
(join-line -1)))
;;----------------------------------------------------------------------------
;; Ruby - robe
;;----------------------------------------------------------------------------
(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'robe-mode-hook
(lambda ()
(add-to-list 'ac-sources 'ac-source-robe)
(setq completion-at-point-functions '(auto-complete))))
;; rhtml mode https://github.com/eschulte/rhtml.git
(add-to-list 'load-path "~/.emacs.d/personal/rhtml")
(require 'rhtml-mode)
;; ruby-mode tools
(add-to-list 'load-path "~/.emacs.d/personal/ruby-tools")
(require 'ruby-tools)
;; flymake ruby
(require 'flymake-ruby)
(add-hook 'ruby-mode-hook 'flymake-ruby-load)
;; slim-mode
(add-to-list 'load-path "~/.emacs.d/personal/")
(require 'slim-mode)
;; lua-mode
;; (add-to-list 'load-path "~/.emacs.d/personal/lua-mode")
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
;; flymake lua
(require 'flymake-lua)
(add-hook 'ruby-mode-hook 'flymake-lua-load)
;; rvm.el should allow us to automatically load the correct ruby by
;; looking at the associated .rvmrc
(require 'rvm)
(add-hook 'ruby-mode-hook
(lambda () (rvm-activate-corresponding-ruby)))
;; Tramp Stuff
(setq tramp-default-port 2211)
;; ;; SBCL + SLIME
;; (load (expand-file-name "~/quicklisp/slime-helper.el"))
;; (setq inferior-lisp-program "/usr/bin/sbcl")
;; ;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
;; (add-to-list 'load-path "/home/justin/quicklisp/dists/quicklisp/software/slime-20111105-cvs")
;; (require 'slime-autoloads)
;; (slime-setup '(slime-fancy slime-fuzzy))
;; (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
;; W3M
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/w3m/")
;; (require 'w3m-load)
;; Helm Mode
(helm-mode 1)
;; Disable Projectile Mode as it is sloooow on the cr48
;; (projectile-global-mode -1)
;; Clean up buffers before save
(add-hook 'before-save-hook 'whitespace-cleanup)
;; Make SCSS mode not compile at file save
(setq scss-compile-at-save nil)
;;I think prelude uses this now ;; Add expand region
;; (add-to-list 'load-path "~/.emacs.d/personal/er")
;; (require 'expand-region)
;; (global-set-key (kbd "C-@") 'er/expand-region)
;;Make yasnippet have the correct keybinding when editing C files
(require 'yasnippet)
(setq yas/snippet-dirs '("~/.emacs.d/personal/snippets"))
(yas-global-mode 1)
( global-set-key [f7] 'yas/insert-snippet)
;;Add yari Yet Another RI...
(add-to-list 'load-path "~/.emacs.d/personal/yari")
(require 'yari)
(defun ri-bind-key ()
(local-set-key [f6] 'yari))
(add-hook 'ruby-mode-hook 'ri-bind-key)
;; TRAMP custom stuff
(add-to-list 'tramp-default-method-alist '("home" "" "scp"))
(add-to-list 'tramp-default-method-alist '("5.jetfive.com" "" "scp"))
;; Auto complete mode
(require 'auto-complete)
(add-to-list 'ac-modes 'ruby-mode 'javascript-mode)
(setq ac-sources '(ac-source-semantic ac-source-yasnippet))
(global-auto-complete-mode)
;; Show line at 90 char
(require 'fill-column-indicator)
(setq-default fill-column 90)
(setq-default fci-rule-width 1)
(setq-default fci-rule-color "#686868")
(add-hook 'ruby-mode-hook 'fci-mode)
(add-hook 'js-mode-hook 'fci-mode)
(add-hook 'js2-mode-hook 'fci-mode)
(add-hook 'clojure-mode-hook 'fci-mode)
(add-hook 'markdown-mode-hook 'fci-mode)
;; Represent undo-history as an actual tree (visualize with C-x u)
(setq undo-tree-mode-lighter "")
(require 'undo-tree)
(global-undo-tree-mode)
;; Sentences do not need double spaces to end. Period.
(set-default 'sentence-end-double-space nil)
;; Add parts of each file's directory to the buffer name if not unique
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; When popping the mark, continue popping until the cursor actually moves
;; Also, if the last command was a copy - skip past all the expand-region cruft.
(defadvice pop-to-mark-command (around ensure-new-position activate)
(let ((p (point)))
(when (eq last-command 'save-region-or-current-line)
ad-do-it
ad-do-it
ad-do-it)
(dotimes (i 10)
(when (= p (point)) ad-do-it))))
;; REMINDERS
;;
;; 'M-x cua-mode' enables rectangular text selection/editing DONT
;; FORGET IT
;;
;; M-/ hippie-expand
;; it will look for completions in the current buffer, other open
;; buffers, and the kill ring
;;
;; M-x follow-mode open a long file, then two buffers, enabel follow
;; mode to stretch the file across two or more buffers, C-x + to
;; balance the windows, very cool
;;
;; C-h m show all active minor and major mode key bindings
;; C-c C-e sgml-close-tag
;; C-c C-w html-mode wrap-tag which is a custom definition
;; Multiple Cursors
(add-to-list 'load-path "~/.emacs.d/personal/multiple-cursors")
(require 'multiple-cursors)
(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 >") 'mc/mark-sgml-tag-pair)
;; From active region to multiple cursors:
;; (global-set-key (kbd "C-M-c C-S-c") 'mc/edit-lines)
;; (global-set-key (kbd "C-M-c C-e") 'mc/edit-ends-of-lines)
;; (global-set-key (kbd "C-M-c C-a") 'mc/edit-beginnings-of-lines)
;; kill flyspell-mode
(defun fix-prelude-prog-mode-defaults ()
(turn-off-flyspell))
(add-hook 'prelude-prog-mode-hook 'fix-prelude-prog-mode-defaults t)
;; Diminish modeline clutter
(require 'diminish)
(diminish 'helm-mode)
(diminish 'projectile-mode)
(diminish 'prelude-mode)
(diminish 'yas-minor-mode)
(add-hook 'ruby-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'js-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'js2-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'html-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'css-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'scss-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'sh-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'lisp-mode-hook (lambda () (diminish 'guru-mode)))
(add-hook 'ruby-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'js-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'js2-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'html-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'css-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'scss-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'sh-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
(add-hook 'lisp-mode-hook (lambda () (diminish 'volatile-highlights-mode)))
;; Turn on winner mode
(winner-mode t)
;; Ask for confirmation before quitting Emacs
(add-hook 'kill-emacs-query-functions
(lambda () (y-or-n-p "Do you really want to exit Emacs? "))
'append)
(require 'clojure-stuff)
(require 'my-custom-definitions)
(require 'custom-gnus)
(require 'my-layout-and-theme)
;; disable those annoying tooltips
(tooltip-mode -1)