public
Description: My Emacs Configs
Homepage: http://tiago.zusee.com/
Clone URL: git://github.com/bastos/emacs.d.git
emacs.d / bastos.el
100644 251 lines (198 sloc) 7.245 kb
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
(custom-set-variables
 '(column-number-mode t)
 '(ecb-options-version "2.32")
 '(show-paren-mode t)
 '(speedbar-frame-parameters (quote ((minibuffer) (width . 20) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (set-background-color "black"))))
 '(transient-mark-mode t))
 
;; Some imports
(setq load-path (cons "~/.emacs.d" load-path))
 
(setq load-path (cons "~/.emacs.d/color-theme" load-path))
 
(setq load-path (cons "~/.emacs.d/gist.el" load-path))
 
(setq load-path (cons "~/.emacs.d/cheat.el" load-path))
 
(setq load-path (cons "~/.emacs.d/icicles" load-path))
 
(setq load-path (cons "~/.emacs.d/textmate.el" load-path))
 
;; Erlang
(setq load-path (cons "/usr/lib/erlang/lib/tools-2.6.1/emacs"
      load-path))
      (setq erlang-root-dir "/usr/lib/erlang")
      (setq exec-path (cons "/usr/lib/erlang/bin" exec-path))
 
;; Python
(autoload 'python-mode "python-mode.el" "Python mode." t)
 
(setq auto-mode-alist (append '(("/*.\.py$" . python-mode))
auto-mode-alist))
 
;; Ruby
(setq load-path (cons "~/.emacs.d/emacs-rails" load-path))
(setq load-path (cons "~/.emacs.d/ruby-mode" load-path))
 
(autoload 'run-ruby "inf-ruby"
  "Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
  "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)
))
 
(require 'rails)
 
;; (require 'ido)
;; (ido-mode t)
 
;; Rinari
;; (add-to-list 'load-path "~/.emacs.d/rinari")
;; (require 'rinari)
 
;; Fuzzy Find in Project
;; GEM: sudo gem install --source http://gems.github.com jamis-fuzzy_file_finder
;; Example: (fuzzy-find-project-root "~/path/to/project")
(add-to-list 'load-path "~/.emacs.d/fuzzy-find-in-project")
(require 'fuzzy-find-in-project)
 
;; Example: (set-key "<f11>" 'gdb)
(defun set-key (kbd funct)
  (global-set-key (read-kbd-macro kbd) funct))
 
(load-file "/usr/share/emacs/site-lisp/cedet/common/cedet.el")
 
;; Some requires
;; (require 'ecb-autoloads)
(require 'snippet)
(require 'find-recursive)
(require 'psvn)
(require 'color-theme)
(require 'gist)
(require 'cheat)
(require 'erlang-start)
(require 'twittering-mode)
;; (require 'icicles)
(require 'lacarte)
(require 'textmate)
 
;; Turn on textmate mode http://github.com/defunkt/textmate.el/tree/master
(textmate-mode)
 
;; JS Mode
;; (autoload 'js2-mode "js2" nil t)
;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
 
;; icicles
;; (icicle-mode 1) ; Turn on Icicle mode.
 
;; ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t)
(ido-everywhere 1)
 
;; iswitchb
;;(iswitchb-mode t)
;; (global-set-key "\C-x\C-b" 'iswitchb-buffer)
 
;; Load local values
(load "local")
 
;; Erlang config
(defvar inferior-erlang-prompt-timeout t)
 
;; Disable ecb tip
;; (setq ecb-tip-of-the-day nil)
 
(setq color-theme-is-global t)
 
;; (set-face-background 'flymake-errline "red4")
;; (set-face-background 'flymake-warnline "dark slate blue")
 
;; (set-default-font "Bitstream Vera Sans Mono-11")
;; (set-fontset-font (frame-parameter nil 'font)
;; 'han '("cwTeXHeiBold" . "unicode-bmp"))
 
;; (require 'color-theme)
;; (color-theme-initialize)
;; (setq color-theme-is-global t)
 
(load-file "~/.emacs.d/twilight-emacs/color-theme-twilight.el")
(color-theme-twilight)
; pick your font
; M-x describe-font
(setq default-frame-alist '((font . "-unknown-Monaco-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1")))
(cua-mode)
 
;; (ecb-activate)
 
;; Comment region
(defalias 'cr 'comment-region)
(defalias 'ucr 'uncomment-region)
 
;; Set up recentf so I can get a list of recent files when I start
(recentf-mode 1)
 
;;(recentf-open-files nil "*Recent Files*")
(setq recentf-max-saved-items 1200)
 
(defun yes-or-no-p (prompt)
  "replace tedious yes/no+enter with y/n keypress"
  (ding t)
  (y-or-n-p prompt))
 
;; go to line
(global-set-key (kbd "C-M-g") 'goto-line)
 
;; remove toolbar
(tool-bar-mode nil)
 
;; Count TODO's: http://gist.github.com/20152
(defun count-todos-in-buffer ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (message "Number of TODO's in the current buffer: %d" (count-matches "TODO"))))
    
(set-key "<C-f7>" 'count-todos-in-buffer)
 
;; turn off the annoying alarm bell
(setq ring-bell-function 'ignore)
 
;; Aliases
 
(defalias 'qrr 'query-replace-regexp)
 
;; Window resize
(defun win-resize-top-or-bot ()
  "Figure out if the current window is on top, bottom or in the
middle"
  (let* ((win-edges (window-edges))
(this-window-y-min (nth 1 win-edges))
(this-window-y-max (nth 3 win-edges))
(fr-height (frame-height)))
    (cond
     ((eq 0 this-window-y-min) "top")
     ((eq (- fr-height 1) this-window-y-max) "bot")
     (t "mid"))))
 
(defun win-resize-left-or-right ()
  "Figure out if the current window is to the left, right or in the
middle"
  (let* ((win-edges (window-edges))
(this-window-x-min (nth 0 win-edges))
(this-window-x-max (nth 2 win-edges))
(fr-width (frame-width)))
    (cond
     ((eq 0 this-window-x-min) "left")
     ((eq (+ fr-width 4) this-window-x-max) "right")
     (t "mid"))))
 
(defun win-resize-enlarge-horiz ()
  (interactive)
  (cond
   ((equal "top" (win-resize-top-or-bot)) (enlarge-window -1))
   ((equal "bot" (win-resize-top-or-bot)) (enlarge-window 1))
   ((equal "mid" (win-resize-top-or-bot)) (enlarge-window -1))
   (t (message "nil"))))
 
(defun win-resize-minimize-horiz ()
  (interactive)
  (cond
   ((equal "top" (win-resize-top-or-bot)) (enlarge-window 1))
   ((equal "bot" (win-resize-top-or-bot)) (enlarge-window -1))
   ((equal "mid" (win-resize-top-or-bot)) (enlarge-window 1))
   (t (message "nil"))))
 
(defun win-resize-enlarge-vert ()
  (interactive)
  (cond
   ((equal "left" (win-resize-left-or-right)) (enlarge-window-horizontally -1))
   ((equal "right" (win-resize-left-or-right)) (enlarge-window-horizontally 1))
   ((equal "mid" (win-resize-left-or-right)) (enlarge-window-horizontally -1))))
 
(defun win-resize-minimize-vert ()
  (interactive)
  (cond
   ((equal "left" (win-resize-left-or-right)) (enlarge-window-horizontally 1))
   ((equal "right" (win-resize-left-or-right)) (enlarge-window-horizontally -1))
   ((equal "mid" (win-resize-left-or-right)) (enlarge-window-horizontally 1))))
 
;; Set keys
;; (set-key "<f12>" 'ecb-toggle-ecb-windows)
(set-key "<f11>" 'menu-bar-mode)
(global-set-key [C-tab] 'other-window) ;; vimy window switching
(server-start)
;;(set-key "<f12>" 'win-resize-enlarge-vert)
;;(set-key "<f11>" 'win-resize-minimize-vert)
 
;; (global-set-key [C-M-down] 'win-resize-minimize-vert)
;; (global-set-key [C-M-up] 'win-resize-enlarge-vert)
;; (global-set-key [C-M-left] 'win-resize-minimize-horiz)
;; (global-set-key [C-M-right] 'win-resize-enlarge-horiz)
;; (global-set-key [C-M-up] 'win-resize-enlarge-horiz)
;; (global-set-key [C-M-down] 'win-resize-minimize-horiz)
;; (global-set-key [C-M-left] 'win-resize-enlarge-vert)
;; (global-set-key [C-M-right] 'win-resize-minimize-vert)
 
;; See http://www.emacswiki.org/cgi-bin/wiki/InteractivelyDoThings#toc5
(defun ido-execute ()
  (interactive)
  (call-interactively
   (intern
    (ido-completing-read
     "M-x "
     (let (cmd-list)
       (mapatoms (lambda (S) (when (commandp S) (setq cmd-list (cons (format "%S" S) cmd-list)))))
       cmd-list)))))
 
(global-set-key "\M-x" 'ido-execute)