-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy-custom.el
204 lines (164 loc) · 5.86 KB
/
my-custom.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
;;show file in title
(setq frame-title-format '("%f"))
;;'y' for 'yes', 'n' for 'no'
(fset 'yes-or-no-p 'y-or-n-p)
;;highlight current line
(require 'hl-line)
(global-hl-line-mode t)
;;screen set
(setq default-frame-alist '((top . 1) (left . 1) (height . 29) (width . 117)))
;;ido
(require 'ido)
(setq ido-confirm-unique-completion t)
(setq ido-default-buffer-method 'samewindow)
(setq ido-use-filename-at-point t)
(setq ido-enable-flex-matching t)
(ido-mode t)
(ido-everywhere t)
(set-face-background 'ido-first-match "green")
(set-face-foreground 'ido-subdir "blue3")
(setq ido-enable-flex-matching t)
;;cursor
(setq-default cursor-type 'bar)
;;copy to other place
(setq x-select-enable-clipboard t)
;;no backup file
(setq make-backup-files nil)
;;twilight theme
(setq load-path (cons "~/.emacs.d/themes" load-path))
(require 'color-theme)
(color-theme-initialize)
(load-file "~/.emacs.d/themes/color-theme-twilight.el")
(color-theme-twilight)
;;(load-file "~/.emacs.d/themes/color-theme-railscasts.el")
;;(color-theme-railscasts)
;;ecb
(load-file "~/.emacs.d/cedet/common/cedet.el")
(global-ede-mode 1) ; Enable the Project management system
(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
(global-srecode-minor-mode 1) ; Enable template insertion menu
(setq load-path (cons "~/.emacs.d/ecb" load-path))
(require 'ecb)
(setq ecb-auto-activate t)
(add-hook 'ecb-activate-hook
'(lambda()
(setq ecb-auto-activate t
ecb-tip-of-the-day nil
)))
;;better copy
(defadvice kill-ring-save (before slickcopy activate compile)
"When called interactively with no active region, copy a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice kill-region (before slickcut activate compile)
"When called interactively with no active region, kill a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
;;add one line
(global-set-key (kbd "s-l")
'(lambda ()(interactive)(end-of-line 1)(newline-and-indent)))
;;ruby on rails
(setq load-path (cons "~/.emacs.d/ruby" load-path))
(setq load-path (cons "~/.emacs.d/rails" load-path))
(require 'rails)
;;flymake
(require 'flymake-ruby)
(add-hook 'ruby-mode-hook 'flymake-ruby-load)
;;smart-compile
(require 'smart-compile)
;;run
(setq smart-compile-alist
'( ("\\.rb$" . "spec %f")))
(global-set-key [(f5)] 'smart-compile)
(add-to-list 'load-path "~/.emacs.d/rhtml-mode")
(require 'rhtml-mode)
(add-hook 'rhtml-mode-hook
'(lambda ()
(auto-fill-mode -1)))
;;yaml
(add-to-list 'load-path "~/.emacs.d/yaml-mode")
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;;kill-this-buffer
(global-set-key [(f12)] 'kill-this-buffer)
;; Rinari
(setq load-path (cons "~/.emacs.d/rinari" load-path))
(require 'rinari)
(global-set-key (kbd "s-c") 'rinari-find-controller)
(global-set-key (kbd "s-m") 'rinari-find-model)
(global-set-key (kbd "s-v") 'rinari-find-view)
(global-set-key (kbd "s-h") 'rinari-find-helper)
(global-set-key (kbd "s-s") 'rinari-find-rspec)
(global-set-key (kbd "s-f") 'rinari-find-file-in-project)
;; kill all rinari buffers
(defun kill-buffers-in-subdir (subdir buffer)
"Kills the given buffer if it is linked to a file in the current rinari project."
(if (buffer-in-subdir-p subdir buffer)
(kill-buffer buffer)))
(defun buffer-in-subdir-p (subdir buffer)
"Returns true if buffer belongs to the current rinari project"
(and (buffer-file-name buffer)
(string-match subdir (buffer-file-name buffer))))
(defun kill-all-rinari-buffers ()
"Kills all buffers linked to the current rinari project"
(interactive)
(let ((path (rinari-root)))
(if path
(dolist (buffer (buffer-list))
(kill-buffers-in-subdir path buffer)))))
(global-set-key [(C-f12)] 'kill-all-rinari-buffers)
;;goto line
(global-set-key (kbd "s-g") 'goto-line)
;;commit
(global-set-key (kbd "s-o") 'comment-region)
(global-set-key (kbd "s-u") 'uncomment-region)
;;code toggle
(global-set-key (kbd "s-h") 'hs-hide-all)
(global-set-key (kbd "s-s") 'hs-show-all)
(global-set-key (kbd "s-t") 'hs-toggle-hiding)
(global-set-key [(f8)] 'ecb-toggle-ecb-windows)
;; Rspec
(load-file "~/.emacs.d/rspec/rspec-mode.el")
(require 'rspec-mode)
(local-set-key (kbd "s-z") 'rspec-toggle-spec-and-target)
;;most popular
(global-set-key (kbd "C-c C-c C-s") 'tags-search)
(global-set-key (kbd "C-c C-c C-n") 'tags-loop-continue)
(global-set-key (kbd "C-c C-c C-c") 'rinari-find-controller)
(global-set-key (kbd "C-c C-c C-m") 'rinari-find-model)
(global-set-key (kbd "C-c C-c C-v") 'rinari-find-view)
(global-set-key (kbd "C-c C-c C-r") 'rinari-find-rspec)
(global-set-key (kbd "C-c C-c C-f") 'rinari-find-file-in-project)
(global-set-key (kbd "C-c C-c C-h") 'hs-hide-all)
(global-set-key (kbd "C-c C-c C-t") 'hs-toggle-hiding)
(global-set-key (kbd "C-c C-c C-o") 'comment-region)
(global-set-key (kbd "C-c C-c C-u") 'uncomment-region)
(global-set-key (kbd "C-c C-c C-g") 'goto-line)
(load-file "~/.emacs.d/others/browse-kill-ring.el")
(require 'browse-kill-ring)
(global-set-key (kbd "s-p") 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
(load-file "~/.emacs.d/others/browse-kill-ring.el")
(require 'browse-kill-ring)
(global-set-key (kbd "C-c C-c C-p") 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;; (add-to-list 'load-path "~/.emacs.d/ruby-complexity/")
;; (require 'linum)
;; (require 'ruby-complexity)
;; (add-hook 'ruby-mode-hook
;; (function (lambda ()
;; (flymake-mode)
;; (linum-mode)
;; (ruby-complexity-mode))))
(global-set-key [f11] 'my-fullscreen)
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)