forked from lest/emacs-config
-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.el
156 lines (118 loc) · 3.74 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
;; turn off toolbar and scrollbar
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
;; directory with config
(setq config-dir (file-name-directory
(or (buffer-file-name) load-file-name)))
(defmacro load-config (filename)
`(load (concat config-dir ,filename)))
(defmacro load-configs (&rest filenames)
`(progn
,@(mapcar #'(lambda (f)
`(load-config ,f))
filenames)))
(defmacro load-config-if-exists (filename)
`(if (file-exists-p (concat config-dir ,filename))
(load-config ,filename)))
;; Enhanced Ruby Mode
(add-to-list 'load-path (concat config-dir "vendor/Enhanced-Ruby-Mode"))
;; variable enh-ruby-program will be specified in env.el later
;; environment settings
(load-config-if-exists "env.el")
(load-config-if-exists (concat system-name ".el"))
;; vendor
(add-to-list 'load-path (concat config-dir "vendor"))
;; stop creating backup~ and #auto-save# files
(setq make-backup-files nil)
(setq auto-save-default nil)
;; delete selection when typing
(delete-selection-mode t)
;; save last cursor position in file
(require 'saveplace)
(setq-default save-place t)
;; default input method
(setq default-input-method 'russian-computer)
;; don't use tabs for indent
(set-default 'indent-tabs-mode nil)
;; whitespace mode settings
(setq whitespace-style '(trailing lines space-before-tab
indentation space-after-tab)
whitespace-line-column 120)
;; save history
(savehist-mode t)
;; encoding
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(ansi-color-for-comint-mode-on)
;; switch windows with C-left, C-right, C-up, C-down
(windmove-default-keybindings 'control)
;; yes and no
(fset 'yes-or-no-p 'y-or-n-p)
;; ido mode
(ido-mode t)
(setq ido-enable-flex-matching t
ido-ignore-buffers '("\\` "
"^\*Mess"
".*Completion"
"^\*compilation"
"^\*rake"
"^\*generate"
"^\*magit"
"^\*rhtml-ruby-hook"))
;; delete trailing whitespace on save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; (remove-hook 'before-save-hook 'delete-trailing-whitespace)
;; require final newline
(setq require-final-newline t)
;; show empty lines
(setq-default indicate-empty-lines t)
;; Truncate, do not wrap lines
(setq-default truncate-lines t)
;; uniquify buffer names
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; always linum-mode
(defun linum-mode-find-file-hook ()
(linum-mode t))
(add-hook 'find-file-hook 'linum-mode-find-file-hook)
;; recent files
(require 'recentf)
(recentf-mode 1)
;; winner mode
(require 'winner)
(setq winner-dont-bind-my-keys t)
(global-set-key (kbd "<C-s-left>") 'winner-undo)
(global-set-key (kbd "<C-s-right>") 'winner-redo)
(winner-mode t)
;; gui options
(if window-system
(load-config "rc-gui.el"))
;; custom functions
(load-config "rc-defuns.el")
;; custom hotkeys
(load-config "rc-hotkeys.el")
;; misc modes
(load-config "rc-misc.el")
;; programming languages
(load-configs "rc-ruby.el"
"rc-erlang.el"
"rc-js.el"
"rc-haskell.el")
;; spell checking
(load-config "rc-spell.el")
;; org-mode
(load-config "rc-org.el")
;; dedicated-mode
(load-config "vendor/dedicated.el")
;; auto reloading of chanded files from disk
(auto-revert-mode t)
;; use rvm default ruby
(rvm-use-default)
;; php mode
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
;; start server
(require 'server)
(when (not (server-running-p))
(server-start))