forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
230 lines (189 loc) · 7.54 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
;;; init.el --- Where all the magic begins
;;
;; Part of the Emacs Starter Kit
;;
;; This is the first thing to get loaded.
;;
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; Mac specific options!
(setq mac-option-modifier 'hyper) ; sets the Option key as Hyper
(setq mac-option-modifier 'super) ; sets the Option key as Super
(setq mac-command-modifier 'meta) ; sets the Command key as Meta
;; Start emacs server
(call-interactively 'server-start)
;; Visual line mode
(global-visual-line-mode t)
;; Turn off mouse interface early in startup to avoid momentary display
;; You really don't need these; trust me.
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
;; path etc.
(setq dotfiles-dir (file-name-directory
(or (buffer-file-name) load-file-name)))
;; Load up ELPA, the package manager
(add-to-list 'load-path dotfiles-dir)
(add-to-list 'load-path (concat dotfiles-dir "midje-mode"))
(add-to-list 'load-path (concat dotfiles-dir "elpa-to-submit"))
(add-to-list 'load-path (concat dotfiles-dir "autocomplete"))
;; Autocomplete!
(require 'auto-complete-config)
(require 'ac-slime)
(require 'hippie-expand-slime)
(add-hook 'slime-mode-hook 'set-up-slime-hippie-expand)
(add-hook 'slime-repl-mode-hook 'set-up-slime-hippie-expand)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(add-to-list 'ac-dictionary-directories (concat dotfiles-dir "autocomplete/ac-dict"))
(ac-config-default)
;; TODO
(setq autoload-file (concat dotfiles-dir "loaddefs.el"))
(setq package-user-dir (concat dotfiles-dir "elpa"))
(setq custom-file (concat dotfiles-dir "custom.el"))
(require 'package)
(dolist (source '(("marmalade" . "http://marmalade-repo.org/packages/")
("elpa" . "http://tromey.com/elpa/")))
(add-to-list 'package-archives source t))
(package-initialize)
(require 'starter-kit-elpa)
;; These should be loaded on startup rather than autoloaded on demand
;; since they are likely to be used in every session
(require 'cl)
(require 'saveplace)
(require 'ffap)
(require 'uniquify)
(require 'ansi-color)
(require 'recentf)
;; backport some functionality to Emacs 22 if needed
(require 'dominating-file)
;; Load up starter kit customizations
(require 'starter-kit-defuns)
(require 'starter-kit-bindings)
(require 'starter-kit-misc)
(require 'starter-kit-registers)
(require 'starter-kit-eshell)
(require 'starter-kit-lisp)
(require 'starter-kit-perl)
(require 'starter-kit-ruby)
(require 'starter-kit-js)
(regen-autoloads)
(load custom-file 'noerror)
;; Enable window numbering mode
(require 'window-numbering)
(window-numbering-mode 1)
;; Thrift mode
(require 'thrift-mode)
;; Turn off auto fill for markdown.
(add-hook 'markdown-mode-hook '(lambda () (auto-fill-mode 0)))
(add-hook 'text-mode-hook '(lambda () (auto-fill-mode 0)))
(add-hook 'org-mode-hook '(lambda () (auto-fill-mode 0)))
(setq org-use-sub-superscripts nil)
;; Jekyll mode.
(require 'jekyll)
(global-set-key (kbd "C-c b n") 'jekyll-draft-post)
(global-set-key (kbd "C-c b P") 'jekyll-publish-post)
(global-set-key (kbd "C-c b p") (lambda ()
(interactive)
(find-file "~/sritchie.github.com/org/_posts/")))
(global-set-key (kbd "C-c b d") (lambda ()
(interactive)
(find-file "~/sritchie.github.com/org/_drafts/")))
;; Org mode publishing for jekyll. C-x sam gets it done!
(global-set-key (kbd "C-c x") 'org-publish)
;; Midje!
(require 'midje-mode)
(require 'clojure-jump-to-file)
(add-hook 'clojure-mode-hook 'midje-mode)
;; Org mode.
(load "orgmode.el")
(require 'org-babel-defuns)
(require 'ob-clojure)
(require 'buffer-move)
;; Theme
;; (color-theme-zenburn)
(zenburn)
;; Haskell mode stuff.
(require 'hs-lint)
(require 'haskell-ac)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(defun flymake-haskell-init ()
"When flymake triggers, generates a tempfile containing the
contents of the current buffer, runs `hslint` on it, and
deletes file. Put this file path (and run `chmod a+x hslint`)
to enable hslint: https://gist.github.com/1241073"
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "hslint" (list local-file))))
(defun flymake-haskell-enable ()
(when (and buffer-file-name
(file-writable-p
(file-name-directory buffer-file-name))
(file-writable-p buffer-file-name))
(local-set-key (kbd "C-c d") 'flymake-display-err-menu-for-current-line)
(flymake-mode t)))
(defun my-haskell-mode-hook ()
(local-set-key "\C-cl" 'hs-lint)
(setq ac-sources
(append '(ac-source-yasnippet
ac-source-abbrev
ac-source-words-in-buffer
my/ac-source-haskell)
ac-sources))
(dolist (x '(haskell literate-haskell))
(when window-system
(font-lock-add-keywords
(intern (concat (symbol-name x) "-mode"))
'(("(\\|)" . 'esk-paren-face))))
(add-hook
(intern (concat (symbol-name x)
"-mode-hook"))
'turn-on-paredit)))
(custom-set-faces
'(flymake-errline ((((class color)) (:underline "red"))))
'(flymake-warnline ((((class color)) (:underline "yellow")))))
(add-to-list 'completion-ignored-extensions ".hi")
(eval-after-load 'haskell-mode
'(progn
(require 'flymake)
(push '("\\.l?hs\\'" flymake-haskell-init) flymake-allowed-file-name-masks)
(add-hook 'haskell-mode-hook 'flymake-haskell-enable)
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)))
;; You can keep system- or user-specific customizations here
(require 'org-docbook-manning)
;; Develop and keep personal snippets under ~/emacs.d/mysnippets
(setq yas/root-directory "~/.emacs.d/snippets")
(yas/load-directory yas/root-directory)
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field)))
(add-hook 'org-mode-hook
(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field)))
;; Set path
(set-exec-path-from-shell-PATH)
;; Magit Customization Options (fixes 2, 3, 4 key bugs)
(setq magit-diff-options '("-w"))
(setq system-specific-config (concat dotfiles-dir system-name ".el")
user-specific-config (concat dotfiles-dir user-login-name ".el")
user-specific-dir (concat dotfiles-dir user-login-name))
(add-to-list 'load-path user-specific-dir)
(if (file-exists-p system-specific-config) (load system-specific-config))
(if (file-exists-p user-specific-config) (load user-specific-config))
(if (file-exists-p user-specific-dir)
(mapc #'load (directory-files user-specific-dir nil ".*el$")))
;;; init.el ends here