forked from majnemer/davesdots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emacsrc
261 lines (226 loc) · 9.62 KB
/
emacsrc
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
;; set up the load path to ~/emacsdir and all subdirs
(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
(let* ((my-lisp-dir "~/.emacsdir/")
(default-directory my-lisp-dir))
(setq load-path (cons my-lisp-dir load-path))
(normal-top-level-add-subdirs-to-load-path)))
;; Helper macro for safely requiring files with fallback
(defmacro desire (feature filename &optional success failure)
`(if (require ,feature ,filename t)
(eval ,success)
(progn (message (format "Failed to load %s" ,filename)) (eval ,failure))))
;; Standard load location.
(add-to-list 'load-path "~/elisp/")
;; Disable toolbars/menus/etc
(menu-bar-mode -1)
;; tool-bar-mode and scroll-bar-mode are only available for gui emacs
(if window-system
(progn
(tool-bar-mode -1)
(scroll-bar-mode -1)))
;; Start the emacs-server for quick startup when using emacsclient
;(server-start)
;; Some sane defaults for tabs and column width
(setq-default tab-width 4)
(setq-default fill-column 132)
;; Turn on column numbers
;(visual-line-mode 1)
(setq column-number-mode t)
;; backup files should be in ~/.saves
(setq backup-by-copying t
backup-directory-alist '(("." . "~/.saves"))
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;; similarly for tramp backups for su and sudo should be in ~/.saves
(setq backup-enable-predicate
(lambda (name)
(and (normal-backup-enable-predicate name)
(not
(let ((method (file-remote-p name 'method)))
(when (stringp method)
(member method '("su" "sudo"))))))))
;; Mac terminal key support
(if (string= (getenv "TERM_PROGRAM") "Apple_Terminal")
(progn (global-set-key (kbd "M-[ 5 d") 'backward-word)
(global-set-key (kbd "M-[ 5 c") 'forward-word)))
;; C Styling
(setq c-default-style "bsd"
c-basic-offset 4)
(add-hook 'c-mode-common-hook '(lambda ()
(c-toggle-auto-state 1)))
;; Turn on generic syntax highlighting
(desire 'generic-x "generic-x.el")
;; Turn on line numbering (hopefully with linum-mode)
;(desire 'linum "linum.el" '(global-linum-mode 1))
;; Load slime (the Superior Lisp Interaction Mode for Emacs).
;; It's typically in its own directory if it's not in the system site lisp.
;; This uses SBCL as the inferior lisp.
(add-to-list 'load-path "~/slime/")
(setq inferior-lisp-program "sbcl"
lisp-indent-function 'common-lisp-indent-function
slime-complete-symbol-function 'sime-fuzzy-complete-symbol
slime-log-events t
slime-use-autodoc-mode t
slime-autodoc-use-multiline-p t
slime-highlight-compiler-notes t)
;; The --eval fixes a problem on OS X where sbcl gets killed by the OS sometimes.
(desire 'slime-autoloads "slime-autoloads")
(desire 'slime "slime"
'(progn (slime-setup '(slime-fancy))
(setq slime-lisp-implementations '((sbcl ("sbcl" "--core" "/home/ndryden/slime/sbcl.core-for-slime" "--eval" "(sb-unix::ignore-interrupt sb-unix::sighup)"))))))
;; Load mic-paren, an advanced paren-matching mode.
;; Otherwise, try and load show-paren-mode.
(desire 'mic-paren "mic-paren"
'(progn (paren-activate) (setf paren-priority 'both))
'(progn (desire 'paren "paren.el"
'(progn
(set-face-background 'show-paren-match-face (face-background 'region))
(show-paren-mode 1)
(setq show-paren-delay 0)
(setq show-paren-style "mixed")))))
;; Load Par Edit, a minor mode for structured editing of sexps.
(desire 'paredit "paredit"
'(autoload 'enable-paredit-mode "paredit"
"Turn on pseduo-structural editing of Lisp code."))
;; Useful keybindings and swaps for Lisp. Requires slime and paredit.
;; Swaps [ with (, and ] with ), among other things.
(if (and (featurep 'slime) (featurep 'paredit))
(progn
(define-key slime-mode-map (kbd "[") 'paredit-open-round)
(define-key slime-mode-map (kbd "]") 'paredit-close-round)
(define-key slime-mode-map (kbd "M-[") 'paredit-wrap-round)
(define-key slime-mode-map (kbd "(") 'paredit-open-square)
(define-key slime-mode-map (kbd ")") 'paredit-close-square)
(define-key slime-mode-map (kbd "RET") 'paredit-newline)
(define-key slime-mode-map (kbd "<return>") 'paredit-newline)
(define-key slime-mode-map (kbd "C-t") 'transpose-sexps)
(define-key slime-mode-map (kbd "C-M-t") 'transpose-chars)
(define-key slime-mode-map (kbd "C-b") 'backward-sexp)
(define-key slime-mode-map (kbd "C-M-b") 'backward-char)
(define-key slime-mode-map (kbd "C-f") 'forward-sexp)
(define-key slime-mode-map (kbd "C-M-f") 'forward-char)))
;; Load tramp.
(desire 'tramp "tramp"
(setq tramp-default-method "ssh"))
;; Load AUCTeX, for LaTeX editing. (I believe it needs to be loaded like this.)
(if (and (load "auctex.el" nil t t) (load "preview-latex.el" nil t t))
(progn (setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
;; If on OS X, use `open' as the default is nonsense.
(if (string= (getenv "TERM_PROGRAM") "Apple_Terminal")
(progn (setq TeX-view-program-list '(("Preview" "open %o")))
(setq TeX-view-program-selection '((output-pdf "Preview")))))))
;; Set up the color theme
(if (and (fboundp 'load-theme) (boundp 'custom-theme-load-path))
; We can use emacs24 color themes
(progn
(push "~/.emacsdir/themes/" custom-theme-load-path)
(load-theme 'wombat-twilight t))
; We can't use modern themes, try to use color-theme package
(progn
(message "Emacs24 themes unavailable, falling back to color-theme.el")
(desire 'color-theme "color-theme.el"
'(progn (color-theme-initialize) (color-theme-comidia))
'(if (not (null window-system))
(progn
(setq initial-frame-alsit '((background-color . "black")
(foreground-color . "ghostwhite")))
(setq default-frame-alist '((background-color . "black")
(foreground-color . "ghostwhite"))))))))
;; Turn on whitespace highlights
(desire 'whitespace "whitespace.el"
'(progn
(setq whitespace-style '(face trailing empty space-before-tab))
(global-whitespace-mode)
(global-set-key "\C-cw" 'whitespace-cleanup)))
;; Tabs for indentation with spaces for alignment
(desire 'smarttabs "smarttabs.el"
'(progn
(add-hook 'c-mode-hook 'smart-tabs-mode-enable)
(smart-tabs-advice c-indent-line c-basic-offset)
(smart-tabs-advice c-indent-region c-basic-offset)))
;; load org-mode
(desire 'org-install "org-install.el"
'(progn
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(define-key global-map "\C-cc" 'org-capture)
(setq org-capture-templates
'(("t" "Todo" entry (file+headline "~/org/newgtd.org" "Tasks")
"* TODO %^{Brief description} %^g\n%?\nAdded %U")
("j" "Journal" entry (file+datetree "~/org/journal.org")
"* %?\nEntered on %U\n %i\n")))
(setq org-log-done t)
(setq org-use-fast-todo-selection t)
(setq org-agenda-include-diary t)
(setq org-default-notes-file (list "~/org/journal.org"))
(setq org-refile-targets '(("newgtd.org" :maxlevel . 1)
("someday.org" :level . 2)))
(setq org-agenda-files
; Add agendas to this list
(list "~/org/"))))
;; Haskell-Mode
(desire 'haskell-mode "haskell-mode.el"
'(progn
(add-to-list 'auto-mode-alist '("\\.hs$" . haskell-mode))
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)))
;; rust-mode
(desire 'rust-mode "rust-mode.el")
;; gas-mode replacement for asm-mode
(desire 'gas-mode "gas-mode.el"
'(add-to-list 'auto-mode-alist '("\\.[sS]$" . gas-mode)))
;; php-mode
(desire 'php-mode "php-mode.el"
'(progn
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))))
;; ruby-mode indentation
(add-hook 'ruby-mode-hook '(lambda ()
(setq tab-width 2)
(setq indent-tab-mode nil)))
;;; Sketchier things that are too specific or need to be cleaned up
(message "Loading sketchier sections of .emacs")
;; android-mode and related
(desire 'android "android.el"
'(progn
(desire 'android-mode "android-mode.el"
'(progn
(setq android-mode-sdk-dir "/usr/local/Cellar/android-sdk/r9/")
(add-hook 'gud-mode-hook
(lambda()
(add-to-list 'gud-jdb-classpath "/usr/local/Cellar/android-sdk/r9/android-10/android.jar")))))))
;; tuareg-mode (better ocaml mode)
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?$" . tuareg-mode))
(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code." t)
(autoload 'camldebug "camldebug" "Run the Caml debugger" t)
;; Smarter python tabs/spaces
(add-hook 'python-mode-hook (lambda ()
(setq tab-width default-tab-width)
(python-guess-indent)
(if indent-tabs-mode
(setq python-indent default-tab-width))))
;; js2-mode (javascript mode)
(add-to-list 'auto-mode-alist '("\\.js(on)?$" . js2-mode))
(autoload 'js2-mode "js2-mode" "Major mode for editing Javascript code." t)
;; processing-mode (A java-mode derivative for the
;; processing java language extension)
(autoload 'processing-mode "processing-mode" "Processing mode" t)
(add-to-list 'auto-mode-alist '("\\.pde$" . processing-mode))
(setq processing-location "/Applications/Processing.app/Contents/MacOS/JavaApplicationStub")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)