-
Notifications
You must be signed in to change notification settings - Fork 0
/
.emacs
275 lines (218 loc) · 7.83 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
;; Environnement
(set-language-environment "UTF-8")
(setq emacs-lisp-dir "~/.emacs.d/"
my-elmode-dir (concat emacs-lisp-dir "elmodes/"))
(setq load-path
(append load-path
(list my-elmode-dir)))
(setq inhibit-default-init t)
(setq display-time-24hr-format t)
(display-time)
;; display lines and columns
(line-number-mode 1)
(column-number-mode 1)
;; turn off tool bars
(menu-bar-mode -1)
;; (tool-bar-mode -1)
;; (scroll-bar-mode -1)
;; show parenthesis match
(defvar show-paren-delay 0)
(defvar show-paren-style 'expression)
(show-paren-mode 1)
(transient-mark-mode t)
(setq search-highlight t)
(setq gc-cons-threshold (max 500000 gc-cons-threshold))
(setq max-lisp-eval-depth (max 2000 max-lisp-eval-depth))
(setq max-specpdl-size (max 2000 max-specpdl-size))
(setq backup-inhibited t)
(setq-default case-fold-search nil)
(setq visible-bell t)
(setq bell-volume 10)
(setq next-line-add-newlines nil)
(setq minibuffer-confirm-incomplete t)
(setq next-screen-context-lines 1)
(setq minibuffer-max-depth nil)
(setq find-file-compare-truenames t)
(put 'narrow-to-region 'disabled nil)
(setq enable-recursive-minibuffers t)
(global-set-key [S-iso-lefttab] 'hippie-expand)
(global-set-key [f4] 'gnus)
(global-set-key [f2] 'iso-accents-mode)
(define-key global-map [delete] 'delete-char)
(define-key global-map [(meta l)] 'goto-line)
(global-set-key [(control tab)] 'other-window)
(defun my-kill-buffer ()
"kill buffer sans confirmation"
(interactive)
(kill-buffer nil))
(global-set-key [(control x) ?k] 'my-kill-buffer)
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
(global-set-key [(control home)] 'beginning-of-buffer-other-window)
(global-set-key [(control end)] 'end-of-buffer-other-window)
(defvar LIMIT 1)
(defvar time 0)
(defvar mylist nil)
(defun time-now ()
(car (cdr (current-time))))
(defun bubble-buffer ()
(interactive)
(if (or (> (- (time-now) time) LIMIT) (null mylist))
(progn (setq mylist (copy-alist (buffer-list)))
(delq (get-buffer " *Minibuf-0*") mylist)
(delq (get-buffer " *Minibuf-1*") mylist)))
(bury-buffer (car mylist))
(setq mylist (cdr mylist))
(setq newtop (car mylist))
(switch-to-buffer (car mylist))
(setq rest (cdr (copy-alist mylist)))
(while rest
(bury-buffer (car rest))
(setq rest (cdr rest)))
(setq time (time-now)))
(global-set-key [(control \`)] 'bubble-buffer)
(defun scroll-down-keep-cursor ()
"Scroll the text one line down while keeping the cursor"
(interactive)
(scroll-down 1))
(defun scroll-up-keep-cursor ()
"Scroll the text one line up while keeping the cursor"
(interactive)
(scroll-up 1))
(global-set-key [kp-divide] 'scroll-down-keep-cursor)
(global-set-key [kp-multiply] 'scroll-up-keep-cursor)
(defun scroll-other-window-down-keep-cursor ()
"Scroll the text one line down while keeping the cursor"
(interactive)
(scroll-other-window-down 1))
(defun scroll-other-window-up-keep-cursor ()
"Scroll the text one line up while keeping the cursor"
(interactive)
(scroll-other-window 1))
(global-set-key [(control down)] 'scroll-other-window-up-keep-cursor)
(global-set-key [(control up)] 'scroll-other-window-down-keep-cursor)
(global-set-key [(control meta down)] 'scroll-other-window)
(global-set-key [(control meta up)] 'scroll-other-window-down)
;; match parenthesis witth M-?
(global-set-key "\e?" 'match-paren)
(defun match-paren (arg)
"Go to the matching parenthesis."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
;; Completion automatique via Shift-Tab
(global-set-key (quote [S-tab]) (quote dabbrev-expand))
;-------------------------------------------------------------;
; Gestion de la roulette de la souris avec plusieurs vitesses ;
;-------------------------------------------------------------;
; control + scroll : grande vitesse ;
; shift + scroll : petite vitesse ;
; scroll seul : vitesse normale ;
;-------------------------------------------------------------;
(defun up-slightly () (interactive) (scroll-up 5))
(defun down-slightly () (interactive) (scroll-down 5))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
(defun up-one () (interactive) (scroll-up 1))
(defun down-one () (interactive) (scroll-down 1))
(global-set-key [S-mouse-4] 'down-one)
(global-set-key [S-mouse-5] 'up-one)
(defun up-a-lot () (interactive) (scroll-up))
(defun down-a-lot () (interactive) (scroll-down))
(global-set-key [C-mouse-4] 'down-a-lot)
(global-set-key [C-mouse-5] 'up-a-lot)
;;
;--------------------------------------------------;
; correction orthographique : aspell ;
;--------------------------------------------------;
; control \ : v rifie la r gion ou le buffer ;
; meta \ : v rifie une mot ;
; control meta \ : change de dictionnaire ;
;--------------------------------------------------;
(defun ispell-check ()
(interactive)
(if mark-active
(if (< (mark) (point))
(ispell-region (mark) (point))
(ispell-region (point) (mark)))
(ispell-buffer)))
(global-set-key [(control \\)] `ispell-check)
(global-set-key [(meta \\)] `ispell-word)
(global-set-key [(control meta \\)] `ispell-change-dictionary)
; Pour utiliser aspell au lieu de ispell d commenter la ligne suivante
(setq ispell-program-name "aspell")
(setq ispell-local-dictionary "francais")
;;
;---------;
; Couleur ;
;---------;
(global-font-lock-mode t)
(setq my-back-color "black")
(set-face-foreground 'default "white")
(set-face-background 'default my-back-color)
;------------------;
; File association ;
;------------------;
(setq auto-mode-alist
(append '(("\\.tex\\'" . latex-mode)
)
auto-mode-alist)
)
(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.
'(c-basic-offset 4)
'(c-indent-level 4)
'(c-default-style "bsd")
'(mode-line-inverse-video nil)
'(package-selected-packages (quote (php-mode yaml-mode markdown-mode go-mode rust-mode)))
)
(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.
)
(defun des-knf ()
(interactive)
;; Basic indent is 8 spaces
(make-local-variable 'c-basic-offset)
(setq c-basic-offset 8)
;; http://www.gnu.org/software/emacs/manual/html_node/ccmode/Brace_002fParen-Line_002dUp.html
(c-lineup-close-paren 1)
;; Continuation lines are indented 4 spaces
(make-local-variable 'c-offsets-alist)
(c-set-offset 'arglist-cont 4)
(c-set-offset 'arglist-cont-nonempty 4)
(c-set-offset 'statement-cont 4)
;; Labels are flush to the left
(c-set-offset 'label [0])
;; Fill column
(make-local-variable 'fill-column)
(setq fill-column 74))
(defun des-programming-keys ()
(local-set-key "\C-m" 'newline-and-indent)
(local-set-key [RET] 'newline-and-indent))
(defun des-c-mode-hook ()
(des-knf)
(des-programming-keys))
(add-hook 'c-mode-common-hook 'des-c-mode-hook)
(setq-default indent-tabs-mode nil)
;; remove trailing whitespace on save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; ensure there is a new line at the end of the file
(setq require-final-newline t)
;; No startup screen
(setq inhibit-startup-screen t)
;; No cursor blinking
(blink-cursor-mode 0)
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
'("melpa" . "https://stable.melpa.org/packages/")
t)
(package-initialize))