/
init.el
executable file
·236 lines (207 loc) · 7.48 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
(setq on-mac (eq 'darwin system-type))
(setq on-linux (eq 'gnu/linux system-type))
(setq on-windows (eq 'windows-nt system-type))
(setq load-path
(append load-path
'("~/.emacs.d"
"~/.emacs.d/progmodes"
"~/.emacs.d/progmodes/haskell-mode-2.4"
"~/.emacs.d/color-theme-6.6.0")))
(if on-mac
(defun maximize-frame ()
(interactive)
(set-frame-position (selected-frame) 0 0)
(set-frame-size (selected-frame) 1000 1000))
(require 'maxframe))
(defun setup-frame (frame)
(select-frame frame)
(if on-mac (set-frame-font "Monaco 14"))
(if on-linux (set-frame-font "Inconsolata 14"))
(if on-windows (set-frame-font "-*-Consolas-normal-r-*-*-17-*-*-*-c-*-*-iso8859-1"))
(maximize-frame))
(defun toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(add-hook 'after-make-frame-functions 'setup-frame)
(add-hook 'window-setup-hook (lambda () (setup-frame (selected-frame))))
(global-set-key (kbd "<f11>") 'toggle-fullscreen)
(ido-mode 1)
(menu-bar-mode (if on-mac 1 0))
(tool-bar-mode 0)
(scroll-bar-mode 0)
(show-paren-mode 1)
(which-func-mode 1)
(line-number-mode 1)
(column-number-mode 1)
(dynamic-completion-mode 1)
(auto-compression-mode 1)
(global-font-lock-mode 1)
(global-auto-revert-mode 1)
(windmove-default-keybindings)
(fset 'yes-or-no-p 'y-or-n-p)
(setq confirm-nonexistent-file-or-buffer nil)
(setq inhibit-startup-message t)
(setq visible-bell nil)
(setq bell-volume 0)
(setq scroll-step 1)
(setq make-backup-files nil)
(setq windmove-wrap-around t)
(setq parens-require-spaces nil)
(setq tab-always-indent 'complete)
(setq x-select-enable-primary t)
(setq x-select-enable-clipboard t)
(setq ido-enable-flex-matching t)
(setq ido-create-new-buffer 'always)
(setq shell-file-name "bash")
(setq explicit-shell-file-name "bash")
(setq kill-buffer-query-functions
(remq 'process-kill-buffer-query-function kill-buffer-query-functions))
(setq default-major-mode 'text-mode)
(setq-default tab-width 8)
(setq-default fill-column 80)
(setq-default indent-tabs-mode nil)
(setq-default ispell-program-name "aspell")
(setq current-language-environment "Bulgarian")
(setq default-input-method "bulgarian-phonetic")
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-c n") 'linum-mode)
(global-set-key (kbd "C-c w") 'whitespace-mode)
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((/= (count-windows) 2)
(message "You need exactly 2 windows to do this."))
(t (let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1))))
(other-window 1))
(global-set-key (kbd "C-c s") 'swap-windows)
(require 'psvn)
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(require 'pager)
(global-set-key (kbd "C-v") 'pager-page-down)
(global-set-key (kbd "M-v") 'pager-page-up)
(global-set-key (kbd "M-p") 'pager-row-up)
(global-set-key (kbd "M-n") 'pager-row-down)
(require 'redo+)
(global-set-key (kbd "C-/") 'undo)
(global-set-key (kbd "C-?") 'redo)
(require 'color-theme)
(color-theme-initialize)
(require 'zenburn)
(color-theme-zenburn)
(require 'htmlize)
(load "haskell-site-file")
(autoload 'go-mode "go-mode" "Go editing mode." t)
(autoload 'cg-mode "cg-mode" "Cg editing mode." t)
(autoload 'mel-mode "mel-mode" "Mel editting mode." t)
(autoload 'lua-mode "lua-mode" "Lua editting mode." t)
(autoload 'mma-mode "mma.el" "Mathematica package file mode" t)
(autoload 'rsl-mode "rsl-mode" "RenderMan Shading Language editing mode" t)
(autoload 'rib-mode "rib-mode" "RenderMan Interface Bytestream editing mode" t)
(setq auto-mode-alist
(append '(("\\.cl$" . c-mode)
("\\.go$" . go-mode)
("\\.cs$" . c++-mode)
("\\.cg$" . cg-mode)
("\\.hlsl$" . cg-mode)
("\\.f[xh]$" . cg-mode)
("\\.o?sl$" . rsl-mode)
("\\.rib$" . rib-mode)
("\\.ma$" . mel-mode)
("\\.mel$" . mel-mode)
("\\.lua$" . lua-mode)
("\\.m$" . mma-mode)
("\\.org$" . org-mode)
("SConstruct" . python-mode)
("SConscript" . python-mode))
auto-mode-alist))
(add-hook
'text-mode-hook
(lambda ()
(flyspell-mode 1)
(auto-fill-mode 1)))
(add-hook
'c-mode-hook
(lambda ()
(c-set-style "linux")
(setq indent-tabs-mode t)))
(add-hook
'c++-mode-hook
(lambda ()
(setq tab-width 4)
(c-add-style
"my-c++-style"
'((c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +)
(inline-open . 0)
(inexpr-class . 0)
(innamespace . 0)
(comment-intro . 0)
(arglist-intro . +)
(arglist-cont . /)
(arglist-close . 0)
(inher-intro . *)
(inher-cont . 0)
(member-init-intro . *)
(member-init-cont . /)))))
(c-set-style "my-c++-style")))
(add-hook
'haskell-mode-hook
(lambda ()
(turn-on-haskell-indent)
(turn-on-haskell-doc-mode)
(turn-on-haskell-decl-scan)))
(add-hook
'mel-mode-hook
(lambda ()
(require 'etom)
(setq etom-default-host "localhost")
(setq etom-default-port 2323)
(local-set-key (kbd "C-c C-r") 'etom-send-region)
(local-set-key (kbd "C-c C-c") 'etom-send-buffer)
(local-set-key (kbd "C-c C-l") 'etom-send-buffer)
(local-set-key (kbd "C-c C-z") 'etom-show-buffer)))
(add-hook 'lua-mode-hook (lambda () (setq lua-indent-level 4)))
(add-hook 'shell-mode-hook (lambda () (ansi-color-for-comint-mode-on)))
(defadvice python-send-buffer (after advice-switch-to-python)
"Switch to *Python* after C-c C-c"
(python-switch-to-python t))
(if on-windows
(progn
;; Suppress the '~/.emacs.d/server is unsafe' error
(when (= emacs-major-version 23)
(require 'server)
(defun server-ensure-safe-dir (dir) "Noop" t))
;; Cygwin setup
(require 'cygwin-mount)
(cygwin-mount-activate)
(add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt nil t)
(defadvice grep-compute-defaults (around grep-compute-defaults-advice-null-device)
"Use cygwin's /dev/null as the null-device."
(let ((null-device "/dev/null"))
ad-do-it))
(ad-activate 'grep-compute-defaults)))
(server-start)
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
(message "init.el loaded successfully.")