-
Notifications
You must be signed in to change notification settings - Fork 7
/
.emacs
executable file
·329 lines (272 loc) · 10.9 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
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
(setq user-full-name "nofxx")
(setq user-mail-address "[email protected]")
(prefer-coding-system 'utf-8)
(setq load-path
(append (list nil "~/.emacs.d"
"~/.emacs.d/plugins"
"~/.emacs.d/includes"
"~/.emacs.d/plugins/color-theme"
"~/.emacs.d/plugins/nxhtml"
"~/.emacs.d/plugins/rinari"
"~/.emacs.d/plugins/rinari/rhtml"
"~/.emacs.d/plugins/emacs-rails"
"~/.emacs.d/plugins/eieio"
"~/.emacs.d/plugins/semantic"
"~/.emacs.d/plugins/speedbar"
"~/.emacs.d/plugins/ecb"
"~/.emacs.d/plugins/jump.el")
load-path))
; Color Theme
(require 'color-theme)
(color-theme-initialize)
;(color-theme-twilight)
(color-theme-arjen)
;(load-file "~/.emacs.d/includes/twit.el")
; Configurações dos Snippets
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/snippets")
(setq yas/window-system-popup-function 'yas/x-popup-menu-for-template)
;;; rhtml mode
(add-to-list 'load-path "~/.emacs.d/includes/rhtml-mode")
(require 'rhtml-mode)
; CSS Mode
(autoload 'css-mode "css-mode" "Major mode for editing css files." t)
(setq auto-mode-alist (cons '(".css$" . css-mode) auto-mode-alist))
; JavaScript Mode
(autoload 'js2-mode "js2" "Major mode for editing javascript scripts." t)
(setq auto-mode-alist (cons '(".js$" . js2-mode) auto-mode-alist))
; Ruby Mode
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".erb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".god$" . ruby-mode) auto-mode-alist))
(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
)
)
)
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(define-key ruby-mode-map "\C-m" 'newline-and-indent)
(require 'ruby-electric)
(ruby-electric-mode t)
)
)
;;; starter-kit-ruby.el --- Some helpful Ruby code
;;
;; Part of the Emacs Starter Kit
(eval-after-load 'ruby-mode
'(progn
;; (require 'ruby-compilation)
(setq ruby-use-encoding-map nil)
(add-hook 'ruby-mode-hook 'inf-ruby-keys)
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)
(define-key ruby-mode-map (kbd "C-c l") "lambda")))
(global-set-key (kbd "C-h r") 'ri)
;; Rake files are ruby, too, as are gemspecs.
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")
;;; Rake
(defun pcomplete/rake ()
"Completion rules for the `ssh' command."
(pcomplete-here (pcmpl-rake-tasks)))
(defun pcmpl-rake-tasks ()
"Return a list of all the rake tasks defined in the current
projects. I know this is a hack to put all the logic in the
exec-to-string command, but it works and seems fast"
(delq nil (mapcar '(lambda(line)
(if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
(split-string (shell-command-to-string "rake -T") "[\n]"))))
(defun rake (task)
(interactive (list (completing-read "Rake (default: default): "
(pcmpl-rake-tasks))))
(shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
;; Clear the compilation buffer between test runs.
;;(eval-after-load 'ruby-compilation
;; '(progn
;; (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
;; (let ((comp-buffer-name (format "*%s*" name)))
;; (when (get-buffer comp-buffer-name)
;; (with-current-buffer comp-buffer-name
;; (delete-region (point-min) (point-max))))))
;; (ad-activate 'ruby-do-run-w/compilation)))
(add-hook 'ruby-mode-hook 'coding-hook)
;;; Flymake
(eval-after-load 'ruby-mode
'(progn
(require 'flymake)
;; Invoke ruby with '-c' to get syntax checking
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
flymake-err-line-patterns)
(add-hook 'ruby-mode-hook
(lambda ()
(when (and buffer-file-name
(file-writable-p
(file-name-directory buffer-file-name))
(file-writable-p buffer-file-name))
(local-set-key (kbd "C-c d")
'flymake-display-err-menu-for-current-line)
(flymake-mode t))))))
;;(eval-after-load 'haml-mode
;;(if (functionp 'whitespace-mode)
;; (add-hook 'haml-mode-hook 'whitespace-mode)))
;; TODO: set up ri
;; TODO: electric
(provide 'starter-kit-ruby)
;; starter-kit-ruby.el ends here
; YAML Mode
(autoload 'yaml-mode "yaml-mode" "Major mode for editing yaml files." t)
(setq auto-mode-alist (cons '(".yml$" . yaml-mode) auto-mode-alist))
; XHTML Mode
(load "autostart.el")
(require 'mumamo-fun)
(setq
nxhtml-global-minor-mode t
mumamo-chunk-coloring 'submode-colored
nxhtml-skip-welcome t
indent-region-mode t
rng-nxml-auto-validate-flag nil
nxml-degraded t
)
(add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . eruby-nxhtml-mumamo))
(add-to-list 'auto-mode-alist '("\.html.erb$" . html-mode))
; Php Mode
(require 'php-mode)
;(setq auto-mode-alist (cons '(".php$" . php-mode) auto-mode-alist))
;(setq auto-mode-alist (cons '(".inc$" . php-mode) auto-mode-alist))
;(setq auto-mode-alist (cons '(".phtml$" . php-mode) auto-mode-alist))
;(setq auto-mode-alist (cons '(".tpl$" . php-mode) auto-mode-alist))
(define-key php-mode-map (kbd "RET") 'newline-and-indent)
(defun wicked/php-mode-init ()
"Set some buffer-local variables."
; (setq case-fold-search t)
(setq indent-tabs-mode nil)
; (setq show-paren-mode t)
(setq fill-column 78))
; (setq c-basic-offset 2)
; (c-set-offset 'arglist-cont 0)
; (c-set-offset 'arglist-intro '+)
; (c-set-offset 'case-label 2)
; (c-set-offset 'arglist-close 0))
(add-hook 'php-mode-hook 'wicked/php-mode-init)
; Emacs-Rails
(load "snippet")
(load "find-recursive")
(require 'rails)
; Rinari (RAILS) Configurações
(require 'rinari)
(setq rinari-tags-file-name "TAGS")
; Interactively Do Things
(require 'ido)
(ido-mode t)
; ECB Config
(setq semantic-load-turn-everything-on t)
(require 'semantic-load)
(require 'ecb)
(require 'ecb-autoloads)
(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.
'(cua-mode t nil (cua-base))
'(display-time-mode t)
'(ecb-enlarged-compilation-window-max-height (quote best))
'(ecb-eshell-auto-activate nil)
'(ecb-layout-name "town")
'(ecb-layout-nr 9)
'(ecb-layout-window-sizes (quote (("town" (0.21794871794871795 . 0.4878048780487805) (0.21794871794871795 . 0.4878048780487805)) ("left-analyse" (0.21794871794871795 . 0.43902439024390244) (0.21794871794871795 . 0.34146341463414637) (0.21794871794871795 . 0.0975609756097561) (0.21794871794871795 . 0.0975609756097561)))))
'(ecb-non-semantic-parsing-function nil)
'(ecb-options-version "2.32")
'(ecb-other-window-behavior (quote edit-and-compile))
'(ecb-other-window-jump-behavior (quote edit-and-compile))
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1))
'(ecb-source-path (quote ("/home/" "Home" ("/home/nofxx/git/rtrac" "rtrac") (#("/home/nofxx/git/imoby" 0 21 (help-echo "Mouse-2 toggles maximizing, mouse-3 displays a popup-menu")) "imoby") ("/home/nofxx/git/farm" "farm"))))
'(ecb-tip-of-the-day nil)
'(flymake-js-off t)
'(flymake-php-off t)
'(inhibit-startup-screen t)
'(menu-bar-mode t)
'(php-mode-force-pear t)
'(php-mode-hook (quote (wicked/php-mode-init)))
'(scroll-bar-mode (quote right))
'(tool-bar-mode nil)
'(tooltip-mode nil)
'(twit-pass "")
'(twit-user ""))
; Configurando o sistema de backup do Emacs
(setq backup-by-copying t ; don't clobber symlinks
backup-directory-alist
'(("." . "~/.emacs.d/backups")) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(add-hook 'ruby-mode-hook
'(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])))
(require 'tabbar)
(tabbar-mode)
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
(require 'rspec-mode)
(setq default-truncate-lines t)
(require 'linum)
(global-linum-mode)
(require 'haml-mode nil 't)
(add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
(require 'magit)
(defun autotest ()
(interactive)
(let ((buffer (shell "autotest")))
(comint-send-string buffer "autotest\n")))
(defun autotest-switch ()
(interactive)
(if (equal "autotest" (buffer-name))
(previous-buffer)
(switch-to-buffer "autotest")))
; add to ruby mode hook:
(define-key ruby-mode-map "\C-c\C-s" 'autotest-switch)
; nofxx
(global-set-key "\C-x\C-g" 'magit-status)
(global-set-key "\M-/" 'comment-or-uncomment-region)
(global-set-key "\M-[" 'indent-region)
(global-set-key "\M-]" 'indent-according-to-mode)
(global-set-key "\M-s" 'save-buffer)
(global-set-key "\M-t" 'ido-find-file)
(global-set-key "\M-q" 'kill-this-buffer)
(global-set-key "\M-a" 'magit-status)
(global-set-key "\M-r" 'query-replace)
(global-set-key "\M-w" 'ido-switch-buffer)
(autoload 'findr "findr" "Find file name." t)
(define-key global-map [(meta control S)] 'findr)
(autoload 'findr-search "findr" "Find text in files." t)
(define-key global-map [(meta control s)] 'findr-search)
(autoload 'findr-query-replace "findr" "Replace text in files." t)
(define-key global-map [(meta control r)] 'findr-query-replace)
;(define-key shell-mode-map "\C-c\C-a" 'autotest-switch)