-
Notifications
You must be signed in to change notification settings - Fork 2
/
.emacs
313 lines (255 loc) · 9.59 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
;; -*- mode: emacs-lisp -*-
(package-initialize)
(require 'xcscope)
(require 'cc-mode)
;; MELPA packages
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
;; set style
;;(setq-default c-basic-offset 2 c-default-style "linux")`(setq-default tab-width 8 indent-tabs-mode t)
;;(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
;; auto repair brackets
;;(require 'autopair)
;;(autopair-global-mode 1)
;;(setq autopair-autowrap t)
;;; yasnippet
;;; should be loaded before auto complete so that they can work together
;;(require 'yasnippet)
;;(yas-global-mode 1)
;;; auto complete mod
;;; should be loaded after yasnippet so that they can work together
(add-to-list 'load-path "~/.emacs.d/elpa")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
;;; set the trigger key so that it can work together with yasnippet on tab key,
;;; if the word exists in yasnippet, pressing tab will cause yasnippet to
;;; activate, otherwise, auto-complete will
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")
(require 'ac-clang)
(define-key c++-mode-map (kbd "C-S-<return>") 'ac-complete-clang)
;; replace C-S-<return> with a key binding that you want
; change moving between windows to Shift+{left,up,down,right}
(windmove-default-keybindings)
(setq windmove-wrap-around t)
; Save space
(menu-bar-mode nil)
; Handle .gz files
(auto-compression-mode t)
; Provide templates for new files
(auto-insert-mode t)
;display column number
(column-number-mode 1)
; Allow completions like em-s-region to complete to emacspeak-speak-region
;;(partial-completion-mode)
;; This somehow produced a failure on excelior
;;(add-hook 'after-init-hook 'server-start)
;;(add-hook 'server-done-hook
;; (lambda ()
;; (shell-command "screen -r -X select `cat ~/tmp/emacsclient-caller`");;))
;;(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
;;(unless (featurep 'emacspeak)
;; (add-hook 'emacs-lisp-mode-hook 'eldoc-mode))
; Update string in the first 8 lines looking like Timestamp: <> or " "
;;(add-hook 'write-file-hooks 'time-stamp)
;;; Diary
;(setq diary-file "~/emacs/diary")
;(add-hook 'diary-hook 'appt-make-list)
;(diary 0)
;;; Eshell
;;(eval-after-load "em-term"
;; '(add-to-list 'eshell-visual-commands "zsh"))
;;; Gnus
;;(setq gnus-init-file "~/emacs/.gnus.el")
;;; Abbrevs
; Use C-xaig to correct common typos
(setq abbrev-file-name "~/emacs/abbrev_defs")
(if (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file))
(set-default 'abbrev-mode t)
;; Misc options I just prefer everytime
(setq cperl-indent-level 2
custom-buffer-indent 2
gc-cons-threshold (* 1024 1024)
european-calendar-style t
mail-user-agent 'message-user-agent
message-generate-headers-first t
w3-display-frames 'ask
widget-choice-toggle t
widget-menu-minibuffer-flag t
url-privacy-level '(os agent)
vc-cvs-diff-switches "-u")
(put 'narrow-to-region 'disabled nil)
;;; Crypt++
(require 'crypt++ nil t)
(setq crypt-encryption-type 'mcrypt)
;;; Internet Time
;(add-to-list 'load-path (expand-file-name "~/emacs/lisp/"))
;(require 'itime)
;(setq display-time-string-forms
; '(24-hours ":" minutes " "
; (itime-string 24-hours minutes seconds)
; (if mail
; " Mail"
; ""))
; display-time-interval 30)
;(display-time-mode 1)
;;; Load local configuration
;;(condition-case data
;; (let ((default-directory "~/emacs/"))
;; (load-file "./local"))
;; (file-error 'notfound))
;;; Load Customize
;;(if (file-exists-p
;; (setq custom-file;
;; (concat "~/emacs/custom-"
;; (int-to-string emacs-major-version))))
;; (load-file custom-file))
;;; Semantic
;(unless (featurep 'emacspeak)
; (global-semantic-auto-parse-mode 1)
; (unless (featurep 'emacspeak)
; (setq semantic-auto-parse-no-working-message t))
; (add-hook 'semantic-init-hooks 'senator-minor-mode))
;; Emacs wiki
;;(require 'emacs-wiki)
;;(add-to-list 'emacs-wiki-interwiki-names '("Bug" . "http://bugs.debian.org/"))
;;(add-to-list 'emacs-wiki-interwiki-names '("Package" . "http://packages.debian.org/"))
;;(setq
;; emacs-wiki-projects
;; '(
;; ("PrivateNotes"
;; (emacs-wiki-directories "~/doc/private"))
;; ("DebianWiki"
;; (emacs-wiki-directories "~/debian/notes")
; (emacs-wiki-publishing-directory . "/[su/mlang@gluck.debian.org]~/public_html/")
;; (emacs-wiki-publishing-directory . "~/debian/public_html")
;; )))
(when (featurep 'emacspeak)
(defun viavoice-set-language (lang)
(cond
((eq lang 'german)
(dtk-interp-queue "`l4 Deutsch")
(dtk-interp-speak))
((eq lang 'english)
(dtk-interp-queue "`l1 English")
(dtk-interp-speak))
(t (error "Unknown language"))))
(defun emacspeak-set-language-to-german ()
(interactive)
(viavoice-set-language 'german))
(defun emacspeak-set-language-to-english ()
(interactive)
(viavoice-set-language 'english))
(global-set-key (kbd "C-c e") 'emacspeak-set-language-to-english)
(global-set-key (kbd "C-c d") 'emacspeak-set-language-to-german))
(global-set-key (kbd "C-c c") 'compile)
(global-set-key (kbd "C-c g") 'grep)
;(define-prefix-command 'f8-map nil "f7=grep, f8=compile")
;(define-key f8-map [f8] 'compile)
;(define-key f8-map [f7] 'grep)
;(global-set-key [f8] 'f8-map)
;(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.
'(column-number-mode t)
'(load-home-init-file t t)
(custom-set-faces
;; custom-set-faces 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.
'(default ((t (:family "DejaVu Sans" :foundry "unknown" :slant normal :weight normal :height 120 :width normal)))))
;;(defun c-lineup-arglist-tabs-only (ignored)
;; "Line up argument lists by tabs, not spaces"
;; (let* ((anchor (c-langelem-pos c-syntactic-element))
;; (column (c-langelem-2nd-pos c-syntactic-element))
;; (offset (- (1+ column) anchor))
;; (steps (floor offset c-basic-offset)))
;; (* (max steps 1)
;; c-basic-offset)))
;; Add kernel style
;;(c-add-style
;; "linux-tabs-only"
;; '("linux" (c-offsets-alist
;; (arglist-cont-nonempty
;; c-lineup-gcc-asm-reg
;; c-lineup-arglist-tabs-only))))
;;(custom-set-variables
;; '(c-default-style "linux-tabs-only")
;;)
'(c-max-one-liner-length 80)
'(fill-column 80)
'(c-ignore-auto-fill (quote (string cpp)))
; cedet semantic
;;(semantic-mode 1)
;;(require 'semantic/ia)
;;(require 'semantic/bovine/gcc)
;;(defun my-semantic-hook ()
;; (imenu-add-to-menubar "TAGS"))
;;(add-hook 'semantic-init-hooks 'my-semantic-hook)
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 120))
(add-to-list 'default-frame-alist (cons 'width 80)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200)
(frame-char-height)))))))
(set-frame-size-according-to-resolution)
;;;;;;;;;;
;;; c-mode
(setq c-default-style '((c-mode . "cc-mode")
(java-mode . "java")
(awk-mode . "awk")
(other . "cc-mode")))
(setq-default indent-tabs-mode nil)
;;(setq-default c-default-style "cc-mode")
;;defun my-c-mode-hook ()
;; (setq c-basic-offset 4
;; c-indent-level 4
;; c-default-style "cc-mode"))
;;(add-hook 'c-mode-common-hook 'my-c-mode-hook)
(c-add-style "my-style"
'("cc-mode"
(indent-tabs-mode t) ; use spaces rather than tabs
(c-basic-offset . 2) ; indent by 2 spaces
(c-offsets-alist . ((inline-open . 0) ; custom indentation rules
(brace-list-open . 0)
(statement-case-open . +)))))
(defun my-c++-mode-hook ()
(c-set-style "my-style") ; use my-style defined above
(auto-fill-mode)
(c-toggle-auto-hungry-state 1)
(c-toggle-auto-state 1)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(setq-default show-trailing-whitespace t)
(load-file "/home/owasserm/emacs-for-python/epy-init.el")
(add-to-list 'load-path "/home/owasserm/emacs-for-python/") ;; tell where to load the various files
(require 'epy-setup) ;; It will setup other loads, it is required!
(require 'epy-python) ;; If you want the python facilities [optional]
(require 'epy-completion) ;; If you want the autocompletion settings [optional]
(require 'epy-editing) ;; For configurations related to editing [optional]
(require 'epy-nose) ;; For nose integration
(add-hook 'python-mode-hook (function cscope:hook))