blob: 479db108e83ea26b52b3529e3315ab56684eb78b (
plain)
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
|
;; This config requires Emacs 24(+?)
;;;; Use XDG-ish locations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq xdg-cache-home (file-name-as-directory (or (getenv "XDG_CACHE_HOME") "~/.cache")))
(setq
package-user-dir (concat xdg-cache-home "emacs/elpa")
ido-save-directory-list-file (concat xdg-cache-home "emacs/ido.last.el")
el-get-dir (concat xdg-cache-home "emacs/el-get/")
eshell-directory-name (concat xdg-cache-home "emacs/eshell/")
wl-score-files-directory (concat xdg-cache-home "emacs/wl-score-files/")
elmo-msgdb-directory (concat xdg-cache-home "emacs/elmo-msgdb/")
elmo-cache-directory (concat xdg-cache-home "emacs/elmo-cache/")
auto-save-list-file-prefix (concat xdg-cache-home "emacs/auto-save-list/saves-")
tramp-persistency-file-name (concat xdg-cache-home "emacs/tramp-cache.el")
custom-file (concat user-emacs-directory "custom.el")
wl-init-file (concat user-emacs-directory "wl.el")
)
;;;; The basics that I can't use Emacs without ;;;;;;;;;;;;;;;;;;;;;;;
(show-paren-mode 1)
(column-number-mode 1)
(line-number-mode 1)
(ido-mode 1)
(unless (daemonp) (server-mode 1))
(when (require 'whitespace nil t)
(setq whitespace-style '(
tab-mark
space-mark
newline-mark
empty
))
(global-set-key "\C-cw" 'global-whitespace-mode))
(setq minibuffer-prompt-properties '(
read-only t
point-entered minibuffer-avoid-prompt
face minibuffer-prompt
))
(load custom-file 'noerror)
;;;; Early settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This isn't particularly important, but set it before doing a whole
;; lot (loading packages), so there isn't a weird change in text size.
(set-face-attribute 'default nil :height 80)
;;;; Bootstrap el-get ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This downloads and installs el-get (package management) if isn't
;; installed.
;; Derived from ELPA installation
;; http://tromey.com/elpa/install.html
(defun eval-url (url)
(let ((buffer (url-retrieve-synchronously url)))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer)))))
(add-to-list 'load-path (concat el-get-dir "el-get"))
(unless (require 'el-get nil t)
(let ((el-get-install-branch "master")) ;; live life on the edge
(eval-url "https://github.com/dimitri/el-get/raw/master/el-get-install.el")))
;;;; Install packages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This is kinda funny how it works.
;;
;; package.el/ELPA (The standard package manager in Emacs 24) has
;; terrible programatic management. It's great at installing packages,
;; but only interactively. So, I
;; 1) Disable package.el from getting loading all downloaded packages
;; 2) Use el-get to load a specified list of packages from elpa.
;;
;; This is also nice because I can do event-base programming for what
;; to do once a package is loaded, using :after.
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(setq package-enable-at-startup nil)
;; What packages el-get should get from ELPA (if it gets them at all)
(setq el-get-sources '(
;; Minor modes
(:name dtrt-indent :type elpa ;; Detect indent style for existing files
:after (dtrt-indent-mode 1))
(:name page-break-lines :type elpa ; Display form-feeds pretty
:after '(lambda ()
(define-global-minor-mode global-page-break-lines-mode
page-break-lines-mode page-break-lines-mode
:group 'page-break-lines)
(global-page-break-lines-mode 1)))
(:name smart-tabs-mode :type elpa ;; Indent with tabs, align with spaces
:after (progn
(smart-tabs-mode 1)
(apply 'smart-tabs-insinuate (mapcar 'car smart-tabs-insinuate-alist))))
;; Major modes
(:name coffee-mode :type elpa
:after (add-hook 'coffee-mode-hook
'(lambda ()
(set (make-local-variable 'tab-width) 2)
(set (make-local-variable 'indent-tabs-mode) nil)
)))
(:name graphviz-dot-mode :type elpa)
(:name markdown-mode :type elpa
:after (add-to-list 'auto-mode-alist '("\\.ronn\\'" . markdown-mode)))
(:name nginx-mode :type elpa
:after (put 'nginx-indent-level 'safe-local-variable 'integerp))
(:name scss-mode :type elpa)
))
;; What packages el-get should install, both from above, and it's
;; internal list of sources.
(el-get 'sync '(el-get
;; Minor modes
dtrt-indent
smart-tabs-mode
page-break-lines
;; Major modes
apel flim semi wanderlust
markdown-mode
nginx-mode
;;nxhtml ; nxhtml is invasive, only enable if actively using
php-mode-improved
))
;; Misc. crap
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(defadvice align-regexp (around lukeshu-align-with-spaces)
(let ((indent-tabs-mode nil)) ad-do-it))
(require 'go-mode-load nil t)
;; Make the mouse work in an xterm
(when (fboundp 'xterm-mouse-mode)
(xterm-mouse-mode 1)
(add-hook 'after-make-frame-functions
'(lambda (frame)
(if xterm-mouse-mode (xterm-mouse-mode 1))
)))
;; Use mailcrypt to encrypt/decrypt email
(when (require 'mailcrypt nil t)
(mc-setversion "gpg")
(add-hook 'wl-summary-mode-hook 'mc-install-read-mode)
(add-hook 'wl-mail-setup-hook 'mc-install-write-mode)
(defun mc-wl-verify-signature ()
(interactive)
(save-window-excursion
(wl-summary-jump-to-current-message)
(mc-verify)))
(defun mc-wl-decrypt-message ()
(interactive)
(save-window-excursion
(wl-summary-jump-to-current-message)
(let ((inhibit-read-only t))
(mc-decrypt))))
(eval-after-load "mailcrypt"
'(setq mc-modes-alist
(append
(quote
((wl-draft-mode (encrypt . mc-encrypt-message)
(sign . mc-sign-message))
(wl-summary-mode (decrypt . mc-wl-decrypt-message)
(verify . mc-wl-verify-signature))))
mc-modes-alist)))
)
;; Indent settings
(setq-default
indent-tabs-mode t
tab-width 8
c-basic-offset 8
sh-basic-offset 8
sh-indent-comment t
)
;; Backup settings
(setq
backup-by-copying t ;; don't clobber symlinks
backup-directory-alist '(("." . "~/.cache/emacs/saves")) ;; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t ;; use versioned backups
)
;; Web browser settings
(setq
browse-url-generic-program (executable-find "v-www-browser")
browse-url-browser-function 'browse-url-generic
)
;; Ediff settings
(setq
ediff-window-setup-function 'ediff-setup-windows-plain
ediff-split-window-function 'split-window-horizontally
)
;; Automatically load smerge mode for merge files
(defun try-smerge-mode ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode 1))))
(add-hook 'find-file-hook 'try-smerge-mode t)
;; All my weird mode-specific settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'lisp-mode-hook
'(lambda ()
(set (make-local-variable 'indent-tabs-mode) nil)
))
(add-hook 'emacs-lisp-mode-hook
'(lambda ()
(set (make-local-variable 'indent-tabs-mode) nil)
))
(add-hook 'term-mode-hook
'(lambda ()
(auto-fill-mode -1)
(setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
(set (make-local-variable 'mouse-yank-at-point) t)
(setq tab-width 8 )
(setq truncate-lines nil)
(set (make-local-variable 'autopair-dont-activate) t) ;; Don't let autopair break ansi-term
))
(add-hook 'ruby-mode-hook
'(lambda ()
(set (make-local-variable 'indent-tabs-mode) t)
(set (make-local-variable 'ruby-indent-level) 4)
(set (make-local-variable 'tab-width) 4)
))
(add-hook 'php-mode-hook
'(lambda ()
(c-set-offset 'cpp-macro 0)
))
(add-hook 'tex-mode-hook
'(lambda ()
(set (make-local-variable 'tab-always-indent) nil)
(set (make-local-variable 'indent-tabs-mode) t)
))
(add-hook 'sh-mode-hook
'(lambda ()
(sh-electric-here-document-mode 0)
))
(add-to-list 'auto-mode-alist '("PKGBUILD" . sh-mode))
(add-to-list 'auto-mode-alist '("SRCBUILD" . sh-mode))
|