/
dotemacs1
366 lines (280 loc) · 10.6 KB
/
dotemacs1
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
;; (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))
(require 'package)
(require 'json)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
;;Initialize package mode along with all the installed packages
(package-initialize)
(defun jwh-require-package (name)
(unless (package-installed-p name)
(package-install name)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; projectile
;; ------------------------
;; C-c p s - switch to a project
;; C-c p f - list files in a project
;; C-c p k - kill all buffers for a project
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(jwh-require-package 'projectile)
(require 'projectile)
(projectile-global-mode)
(setq projectile-completion-system 'ido)
;;;;;;;;;;;;;;;;;;;;;;;;
;; auto-complete
;;;;;;;;;;;;;;;;;;;;;;;;
(jwh-require-package 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;; show menu very quickly - may need to turn back off
(setq ac-show-menu-immediately-on-auto-complete t)
;; (setq jwh-init-dir (expand-file-name "init.d"))
(jwh-require-package 'monokai-theme)
(load-theme 'monokai t)
;; load all lisp files in ./init.d
;; (if (file-exists-p jwh-init-dir)
;; (dolist (file (directory-files jwh-init-dir t "\\.el$"))
;; (load-file)))
(setq visible-bell t)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(blink-cursor-mode 0)
(display-time-mode 1)
(setq standard-indent 4)
(setq-default indent-tabs-mode nil)
(setq scroll-step 1)
(setq transient-mark-mode t) ; visually show region
(setq global-font-lock-mode 1) ; everything should use fonts
;(jwh-require-package 'ipython)
(jwh-require-package 'elpy)
(jwh-require-package 'flymake-cursor)
(jwh-require-package 'magit)
;;(elpy-enable)
;;(elpy-clean-modeline)
;; Fixing a key binding bug in elpy
;(define-key yas-minor-mode-map (kbd "C-c k") 'yas-expand)
; Fixing another key binding bug in iedit mode
(define-key global-map (kbd "C-c o") 'iedit-mode)
(defun python--add-debug-highlight ()
"Adds a highlighter for use by `python--ipdb-breakpoint-string'"
(highlight-lines-matching-regexp "## DEBUG ##\\s-*$" 'hi-red-b))
(add-hook 'python-mode-hook 'python--add-debug-highlight)
(defvar python--ipdb-breakpoint-string "import ipdb; ipdb.set_trace() ## DEBUG ##"
"Python breakpoint string used by `python-insert-breakpoint'")
;; (defun python-insert-breakpoint ()
;; "Inserts a python breakpoint using `pdb'"
;; (interactive)
;; (back-to-indentation)
;; ;; this preserves the correct indentation in case the line above
;; ;; point is a nested block
;; (split-line)
;; (insert python--ipdb-breakpoint-string))
;(define-key python-mode-map (kbd "<f6>") 'python-insert-breakpoint)
(highlight-indentation-mode -1)
;(require 'bbdb)
(line-number-mode t)
(column-number-mode t)
(setq-default fill-column 79)
(show-paren-mode t)
(jwh-require-package 'autopair)
(require 'autopair)
(jwh-require-package 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;;(jwh-require-package 'undo-tree)
;;(require 'undo-tree)
;;(global-undo-tree-mode)
;(jwh-require-package 'back-button)
;(require 'back-button)
;(back-button-mode 1)
(jwh-require-package 'fill-column-indicator)
(require 'fill-column-indicator)
(define-globalized-minor-mode
global-fci-mode fci-mode (lambda () (fci-mode 1)))
(global-fci-mode t)
(jwh-require-package 'popwin)
(require 'popwin)
(popwin-mode 1)
(highlight-indentation-mode -1)
;; resize window
(global-set-key (kbd "M-<up>") 'enlarge-window)
(global-set-key (kbd "M-<down>") 'shrink-window)
;; sample function
;; interactive makes it a command that can be run
;(defun display-buffer-name ()
; (interactive)
; (message (buffer-file-name)))
;(global-set-key (kbd "<f7>") 'display-buffer-name)
;; same thing inline
(global-set-key (kbd "<f8>") (lambda () (interactive) (message (buffer-file-name))))
(jwh-require-package 'markdown-mode)
(require 'markdown-mode)
;; only in markdown mode, f9 will spell check
(define-key markdown-mode-map (kbd "<f9>") 'ispell-buffer)
(add-hook 'markdown-mode-hook 'flyspell-mode)
(define-key elpy-mode-map (kbd "<f5>") 'flymake-display-err-menu-for-current-line)
;; C-h f - get function help
;; C-h v - get variable help
;; watch visited files for changes and reload if needed
(setq
global-auto-revert-mode 1
require-final-newline t
inhibit-startup-screen t
initial-scratch-message ";;_
;; __ _,******
;; ,-----, _ _,**
;; | Mu! | _ ____,****
;; ;-----; _
;; \\ ^__^
;; \\ (^^)\\_______
;; ^-(..)\\ )\\/\\/^_^
;; ||----w |
;; __.-''*-,.,____||_____||___,_.-
;; '' ''
")
;; -------- things i might want ---------
;; typing when mark is active will delete highlighted
; (delete-selection-mode t)
;; common highlighting keystrokes
;; mix emacs and x keyboard (i don't seem to need this)
; (setq x-select-enable-clipboard t)
;; get rid of backup files
(setq make-backup-files nil)
;; y and n instead of yes and no
(defalias 'yes-or-no-p 'y-or-n-p)
(defun comment-or-uncomment-region-or-line ()
"Like comment-or-uncomment-region, but if there's no mark \(that means no
region\) apply comment-or-uncomment to the current line"
(interactive)
(if (not mark-active)
(comment-or-uncomment-region
(line-beginning-position) (line-end-position))
(if (< (point) (mark))
(comment-or-uncomment-region (point) (mark))
(comment-or-uncomment-region (mark) (point)))))
;; ----------------------------------
;; ---------- Key Bindings ----------
;; ----------------------------------
(global-set-key (kbd "RET") 'newline-and-indent)
;; (global-set-key (kbd "C-;") 'comment-or-uncomment-region)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key "\C-x\C-b" 'electric-buffer-list)
(global-set-key "\C-c\C-r" 'comment-or-uncomment-region-or-line)
(global-set-key (kbd "C-;") 'comment-or-uncomment-region-or-line)
;; ----------------------------------
;; ------------ Org-mode ------------
;; ----------------------------------
(global-set-key (kbd "C-c a") 'org-agenda)
(setq org-log-done t)
(setq org-todo-keywords
'((sequence "TODO" "INPROGRESS" "WAITING" "DONE")))
(setq org-todo-keyword-faces
'(("INPROGRESS" . (:foreground "blue" :weight bold))))
(setq org-agenda-files (list "~/Dropbox/org-mode/personal.org"))
;; Ido mode provides a nice way to navigate the filesystem. This is mostly just turning it on.
(ido-mode t)
(setq ido-enable-flex-matching t
ido-use-virtual-buffers t)
(jwh-require-package 'ido-vertical-mode)
(ido-vertical-mode t)
;; makes temporary files go away
(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
;; track recently-opened files
(recentf-mode 1)
(setq recentf-max-menu-items 100)
;; uniquify for buffer names
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; ----------------------------------
;; - UTF-8 -
;; ----------------------------------
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(defun insertdate ()
"Spit out the current time"
(interactive)
(insert (format-time-string "%Y-%m-%d")))
(global-set-key [(f5)] 'insertdate)
;; (defun jonnay-sign () ;;
;; "spit out my name, email and the current time" ;;
;; (interactive) ;;
;; (insert "-- Jonathan Arkell (jonathana@criticalmass.com)") ;;
;; (jonnay-timestamp)) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; never quit accidentally
(setq confirm-kill-emacs 'yes-or-no-p)
;; load images as images
(auto-image-file-mode 1)
;; Recent files
(recentf-mode 1)
;; yank at point
(setq mouse-yank-at-point t)
(setq kill-whole-line t)
(setq user-mail-address "jwh@laydros.net")
(setq display-time-mode t)
(global-linum-mode 1)
;;;;;;;;;;;;;
;; ERC stuff
;;;;;;;;;;;;
(setq erc-fill-function 'erc-fill-static)
(setq erc-fill-static-center 22)
(erc :server "irc.freenode.net" :port 6667 :nick "laydros")
(add-hook 'erc-after-connect '(lambda ("freenode.net")
(erc-message "PRIVMSG" "NickServ identify mypassword")))
(setq erc-autojoin-channels-alist
'(("freenode.net" "#emacs" "#cm6-snap" "#nethack")))
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
;;;;;;;;;;;;;;;;;;;
;; Beautify JSON ;;
;;;;;;;;;;;;;;;;;;;
(defun beautify-json ()
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e
"python -mjson.tool" (current-buffer) t)))
;; Enable Markdown mode and setup additional file extensions.
;; Use pandoc to generate HTML previews from within the mode.
;; Use a custom css file to make it a little prettier.
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdown$" . markdown-mode))
(add-hook 'markdown-mode-hook (lambda () (visual-line-mode t)))
;(setq markdown-command "pandoc --smart -f markdown -t html")
;(setq markdown-css-path (expand-file-name "markdown.css" abedra/vendor-dir))
(defun totd ()
(interactive)
(random t) ;; seed with time-of-day
(with-output-to-temp-buffer "*Tip of the day*"
(let* ((commands (loop for s being the symbols
when (commandp s) collect s))
(command (nth (random (length commands)) commands)))
(princ
(concat "Your tip for the day is:\\n"
"========================\\n\\n"
(describe-function command)
"\\n\\nInvoke with:\\n\\n"
(with-temp-buffer
(where-is command t)
(buffer-string)))))))
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(when (require 'em-term)
(dolist (i '("kop" "ledger" "mc" "htop"))
(add-to-list 'eshell-visual-commands i)))
(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.
)
(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.
)