-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
313 lines (243 loc) · 8.95 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
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
(let ((minver "23.3"))
(when (version<= emacs-version "23.1")
(error "Your Emacs is too old -- this config requires v%s or higher" minver)))
(when (version<= emacs-version "24")
(message "Your Emacs is old, and some functionality in this config will be disabled. Please upgrade if possible."))
;; Tell emacs where is your personal elisp lib dir
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elisp/" user-emacs-directory))
(add-to-list 'load-path "~/.emacs.d/lisp/")
(add-to-list 'load-path "~/.emacs.d/use-package/")
(require 'init-benchmarking) ;; Measure startup time
(defconst *spell-check-support-enabled* nil) ;; Enable with t if you prefer
(defconst *is-a-mac* (eq system-type 'darwin))
;;----------------------------------------------------------------------------
;; Bootstrap config
;;----------------------------------------------------------------------------
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;;(require 'init-compat)
(require 'bind-key)
(require 'use-package)
(require 'init-utils)
(require 'init-site-lisp) ;; Must come before elpa, as it may provide package.el
;;Calls (package-initialize)
(require 'init-elpa) ;; Machinery for installing required packages
(require 'init-exec-path) ;; Set up $PATH
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'load-path "~/.emacs.d/elisp/")
(let ((default-directory "~/.emacs.d/site-lisp/"))
(normal-top-level-add-subdirs-to-load-path))
;;(add-to-list 'load-path "~/.emacs.d/site-lisp/emacs-scala-mode")
(add-to-list 'load-path "/.emacs.d/emacs-eclim/")
(add-to-list 'load-path "./emacs-async")
(package-initialize)
(global-set-key (kbd "M-c") 'other-window) ;
;; easy keys for split windows
(global-set-key (kbd "M-1") 'delete-other-windows) ; 【Alt+3】 unsplit all
(global-set-key (kbd "M-2") 'split-window-below)
(global-set-key (kbd "M-3") 'split-window-right)
(add-to-list 'auto-mode-alist '("\\.cql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\|todo\\)$" . org-mode))
(setenv "DICTIONARY" "en_GB")
(require 'auto-complete)
(auto-complete-mode)
(global-auto-complete-mode t)
;; yasnippet for templating
(require 'yasnippet)
(yas-global-mode 1)
;;OSX modifiers
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
(setq multi-term-program "/bin/zsh")
;; (add-to-list 'load-path "~/.emacs.d/orgmode-mediawiki")
;; (require 'ox-mediawiki)
;; Markdown mode
(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)
(writegood-mode t)
(flyspell-mode t)))
(setq markdown-command "pandoc --smart -f markdown -t html")
;;(add-to-list 'load-path "./helm")
;;(require 'helm-config)
;;(helm-mode 1)
(require 'init-ido)
;; use ffap for guessing files
(setq ido-use-filename-at-point 'guess)
(setq ido-create-new-buffer 'always)
(setq ido-ignore-extensions t)
(require 'org-mode)
(add-to-list 'org-modules 'org-habit)
(require 'org-habit)
(require 'smooth-scrolling)
;; no backups
(setq make-backup-files nil)
;;text increase
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; (setq echo-keystrokes 0.1
;; use-dialog-box nil
;; visible-bell t)
(show-paren-mode t)
(setq column-number-mode t)
(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
;; pair brackets
(require 'autopair)
;; spell
(setq flyspell-issue-welcome-flag nil)
(if (eq system-type 'darwin)
(setq-default ispell-program-name "/usr/local/bin/aspell")
(setq-default ispell-program-name "/usr/bin/aspell"))
(setq-default ispell-list-command "list")
;; Lose UI
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(setq path-to-ctags "~/tags") ;; <- your ctags path here
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(shell-command
(format "ctags -f %s -e -R %s" path-to-ctags (directory-file-name dir-name)))
)
;;go to previous
;;(bind-key "C-x p" 'pop-to-mark-command)
(setq set-mark-command-repeat-pop t)
(use-package smartscan
:init
(global-smartscan-mode t))
(require 'recentf)
;; get rid of `find-file-read-only' and replace it with something
;; more useful.
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
;; enable recent files mode.
(recentf-mode t)
; 50 files ought to be enough.
(setq recentf-max-saved-items 50)
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
;; set F7 to list recently opened file
(global-set-key (kbd "<f7>") 'recentf-open-files)
(setq inhibit-splash-screen t
initial-scratch-message nil
initial-major-mode 'org-mode)
(defalias 'yes-or-no-p 'y-or-n-p)
(add-hook 'emacs-startup-hook 'toggle-frame-maximized)
(autoload 'typing-of-emacs "typing" "The Typing Of Emacs, a game." t)
(desktop-save-mode 1)
(setq desktop-restore-eager 10)
(put 'narrow-to-region 'disabled nil)
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
;; you can select the key you prefer to
;; (define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(global-set-key (kbd "C-c SPC") 'ace-jump-mode)
;;
;; enable a more powerful jump back function from ace jump mode
;;
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
;; When org-mode starts it (org-mode-map) overrides the ace-jump-mode.
(add-hook 'org-mode-hook
(lambda ()
(local-set-key (kbd "\C-c SPC") 'ace-jump-mode)))
(projectile-global-mode)
(put 'scroll-left 'disabled nil)
(require 'deft)
(setq deft-directory "~/Dropbox/org")
(setq deft-extensions '("org" "org_archive"))
(setq deft-default-extension "org")
(setq deft-text-mode 'org-mode)
(setq deft-use-filename-as-title t)
;;(setq deft-use-filter-string-for-filename t)
(setq deft-auto-save-interval 0)
;;key to launch deft
(global-set-key (kbd "C-c d") 'deft)
(require 'undo-tree)
(global-undo-tree-mode 1)
;;http://ergoemacs.org/emacs/emacs_copy_cut_current_line.html
(require 'copy-paste)
(global-set-key (kbd "<f2>") 'xah-cut-line-or-region) ; cut
;; (global-set-key (kbd "<f3>") 'xah-copy-line-or-region) ; copy
;;ediff window plain
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(add-to-list 'load-path "~/.emacs.d/swiper/")
(require 'ivy)
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-height 10)
(setq ivy-count-format "(%d/%d) ")
(setq fiplr-ignored-globs '((directories (".git" ".svn"))
(files ("*.jpg" "*.png" "*.zip" "*~" "*.class" "*.jar"))))
(setq fiplr-root-markers '(".git" ".svn"))
(global-set-key (kbd "C-x f") 'fiplr-find-file)
(require 'move-lines)
(move-lines-binding)
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(autoload 'ibuffer "ibuffer" "List buffers." t)
(setq ibuffer-expert t)
(setq ibuffer-show-empty-filter-groups nil)
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-vc-set-filter-groups-by-vc-root)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))
;;prevent splitting windows by default
(setq split-height-threshold nil
split-width-threshold nil)
;; (setq visible-bell 1)
(setq ring-bell-function 'ignore)
(defun duplicate-line()
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank)
)
;;(global-set-key (kbd "C-d d") 'duplicate-line)
(require 'scala-mode)
;; split windows vertically whenever theer is a choice
(setq split-height-threshold nil)
(setq split-width-threshold 160)
;; copy word at point
;; (defun copy-word (&optional arg)
;; "Copy words at point into kill-ring"
;; (interactive "P")
;; (copy-thing 'backward-word 'forward-word arg)
;; ;;(paste-to-mark arg)
;; )
;; (global-set-key (kbd "C-c w")
(require 'grep-o-matic)
(require 'projectile-speedbar)
(defun now ()
"Insert string for the current time formatted like '2:34 PM'."
(interactive) ; permit invocation in minibuffer
(insert (format-time-string "%D %-I:%M %p")))
(defun today ()
"Insert string for today's date nicely formatted in American style,
e.g. Sunday, September 17, 2000."
(interactive) ; permit invocation in minibuffer
(insert (format-time-string "%A, %B %e, %Y")))