/
.emacs
264 lines (211 loc) · 8.82 KB
/
.emacs
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
(package-initialize)
(prefer-coding-system 'utf-8) ;; use utf8 as default file encoding
(require 'cask (and (file-exists-p "~/.cask/cask.el") "~/.cask/cask.el"))
(cask-initialize (file-name-directory (file-symlink-p "~/.emacs")))
(require 'cl)
(dolist (module
'(redo+ ;; need key mappings
rect-mark
sr-speedbar
autopair
pairs
lazy-frame))
(require module))
(require 'yasnippet)
(yas-global-mode 1)
(when (require 'ibus nil :noerror)
(add-hook 'after-init-hook 'ibus-mode-on)
(global-set-key (kbd "M-SPC") 'ibus-toggle))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; BINDING SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-unset-key (kbd "C-/")) ;; unset C-/
(global-unset-key (kbd "C-_")) ;; unset C-_
;; redo/undo
(global-set-key (kbd "s-Z") 'redo)
(global-set-key (kbd "s-z") 'undo)
;; windows jumping
(global-set-key (kbd "M-[") 'previous-multiframe-window)
(global-set-key (kbd "M-]") 'next-multiframe-window)
;; line manipulating
(global-set-key
(kbd "M-k") ;; backward kill line
'(lambda ()
(interactive)
(kill-line 0)))
(global-set-key
(kbd "C-x j") ;; join line below
'(lambda ()
(interactive)
(next-line)
(join-line)))
;; alignment
(global-set-key (kbd "C-x a a") 'align)
(global-set-key (kbd "C-x a c") 'align-current)
(global-set-key (kbd "C-x a r") 'align-regexp)
(global-set-key
(kbd "C-x p") ;; sr-speedbar focus toggle
'(lambda ()
(interactive)
(if (sr-speedbar-exist-p)
(sr-speedbar-close)
(sr-speedbar-open))
(if (sr-speedbar-exist-p)
(sr-speedbar-select-window)
nil)))
(global-set-key (kbd "C-x l") 'global-linum-mode)
(global-set-key (kbd "C-x c") 'recompile-emacs.d)
(global-set-key (kbd "C-c TAB") 'folding-toggle-show-hide)
(global-set-key (kbd "M-!") 'eshell)
;; rectangle region editing
(global-set-key (kbd "C-x r C-SPC") 'rm-set-mark)
(global-set-key (kbd "C-x r C-x") 'rm-exchange-point-and-mark)
(global-set-key (kbd "C-x r C-w") 'rm-kill-region)
(global-set-key (kbd "C-x r M-w") 'rm-kill-ring-save)
(global-set-key (kbd "C-x r r") 'replace-rectangle)
;; window resizing
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MODE SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 'function "file" doc interactive type(nil, keymap, macro)
(autoload 'cperl-mode "cperl-mode" nil t)
(autoload 'sgml-mode "sgml-mode" nil t)
(autoload 'applescript-mode "applescript-mode" nil t)
(autoload 'erlang-mode "erlang" nil t)
(autoload 'yaml-mode "yaml-mode" nil t)
(autoload 'ruby-mode "ruby-mode" nil t)
(autoload 'rhtml-mode "rhtml-mode" nil t)
(autoload 'puppet-mode "puppet-mode" nil t)
(autoload 'scss-mode "scss-mode" nil t)
(autoload 'haml-mode "haml-mode" nil t)
(autoload 'guru-mode "guru-mode" nil t)
(autoload 'rcirc "rcirc" nil t)
(autoload 'highlight-parentheses-mode
"highlight-parentheses"
"Minor mode to highlight the surrounding parentheses."
t
nil)
(add-hook 'after-init-hook
'guru-global-mode)
(setq auto-mode-alist
(append '(("\\.rb\\'" . ruby-mode)
("\\.rake$" . ruby-mode)
("Gemfile$" . ruby-mode)
("Capfile$" . ruby-mode)
("\\.builder$" . ruby-mode)
("\\rakefile\\'" . ruby-mode)
("\\.rhtml\\'" . rhtml-mode)
("\\.erb\\'" . rhtml-mode)
("\\.org\\'" . org-mode)
("\\.js$" . javascript-mode)
("\\.bash\\\\'" . shell-script-mode)
("\\.applescript$" . applescript-mode)
("\\.md$" . markdown-mode)
("\\.markdown$" . markdown-mode)
("\\.pp$" . puppet-mode)
("Cask" . emacs-lisp-mode)
("\\.pod$" . pod-mode)
("\\.t$" . cperl-mode)
("\\.p[lm]\\'" . cperl-mode))
auto-mode-alist))
(nconc interpreter-mode-alist
'(("scheme" . scheme-mode)
("osascript" . applescript-mode)
("node" . javascript-mode)
("erl" . erlang-mode)))
(add-hook 'emacs-lisp-mode-hook
'highlight-parentheses-mode)
(add-hook 'markdown-mode-hook
'turn-on-auto-fill)
(defalias 'perl-mode 'cperl-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CUSTOMIZATION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load-theme 'zenburn t)
(set-fontset-font "fontset-default" 'han '("LiHei_Pro" . "iso10646-1"))
(set-face-attribute
'mode-line nil
:box nil)
(custom-set-variables
'(custom-safe-themes '("be7eadb2971d1057396c20e2eebaa08ec4bfd1efe9382c12917c6fe24352b7c1" default))
'(package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
;; '(Info-default-directory-list (append Info-default-directory-list '("~/.info")))
'(Info-additional-directory-list '("~/.info"))
'(initial-buffer-choice t)
'(global-font-lock-mode t)
'(auto-save-mode nil) ;; forbidden auto-save
'(global-hl-line-mode t) ;; highlight current line
'(delete-old-versions t) ;; kill all filename~
'(make-backup-files nil) ;; not back up file into filename~
'(completion-ignore-case t)
'(default-fill-column 80)
'(fill-column 80)
'(show-paren-mode t)
'(autopair-global-mode t)
'(lazy-frame-json "~/.lazy-frame.json")
'(yas-snippet-dirs (cons "~/.snippets" ;; construct from original value
(eval (car (get 'yas-snippet-dirs 'standard-value)))))
'(default-frame-alist (frame-setting-read))
'(initial-frame-alist (frame-setting-read))
'(face-font-rescale-alist '((".*LiHei_Pro.*" . 1.10)))
'(ibus-cursor-color '("#4EA4D9" "#EB6528" "#C9DE55"))
'(split-height-threshold 30) ;;
'(split-width-threshold 60) ;;
'(column-number-mode t) ;; show column number
'(line-number-mode t) ;; show line number
'(tool-bar-mode nil nil (tool-bar)) ;; hidden tool-bar
'(scroll-bar-mode nil nil (scroll-bar)) ;; hidden scroll-bar
'(menu-bar-mode nil nil (menu-bar)) ;; hidden menu-bar
'(transient-mark-mode t) ;; highlight marked region
'(ring-bell-function 'ignore) ;; turn the alarm totally off
'(ido-mode t)
'(ido-enable-flex-matching t)
'(ido-everywhere t)
'(cperl-indent-level 2)
'(cperl-hairy nil)
'(cperl-electric-parens nil)
'(cperl-electric-keywords nil)
'(cperl-indent-parens-as-block t)
'(cperl-close-paren-offset -2)
'(ruby-indent-level 2)
'(js-indent-level 2)
'(scss-compile-at-save nil)
'(haml-indent-offset 2)
'(puppet-indent-level 2)
'(sgml-basic-offset 2) ;; for html-mode
'(indent-tabs-mode nil) ;; expand tab to set
'(default-tab-width 2) ;; tab as 2 space
'(tab-width 2)
'(sr-speedbar-right-side nil)
'(speedbar-show-unknown-files t)
'(truncate-lines t)
'(rcirc-server-alist
'(("irc.freenode.net"
:channels
("#emacs"
"#chupei.pm"
"#shelling"
"#g0v.tw"
"#perl.tw"
"#haskell"
"#pegex"
"#bpan"
"#osdc.tw"
"#dot"))))
'(rcirc-default-nick "shelling_emacs")
'(rcirc-default-full-name "shelling ford")
;; '(cua-mode t nil (cua-base)) ;; using C-x, C-c, C-v to cut, copy and paste
'(mac-option-modifier 'meta) ;; set mac option as meta
'(mac-command-modifier 'super))
(custom-set-faces)
(require 'load-recursive)
(let ((local-lib "~/projects/local.el"))
(if (file-exists-p local-lib)
(recursive-load local-lib)))
(cd "~")