-
Notifications
You must be signed in to change notification settings - Fork 0
/
.emacs
394 lines (339 loc) · 13.6 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
;; ---------------------------------------------------------------------------
;; Linum (line numbers) M-x linum-mode to enable
;; ---------------------------------------------------------------------------
(load-file "~/.emacs.d/linum/linum.el")
(require 'linum)
(setq linum-format "%d ")
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
;; ---------------------------------------------------------------------------
;; Smooth scrolling
;; ---------------------------------------------------------------------------
;; scroll one line at a time (less "jumpy" than defaults)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
;; ---------------------------------------------------------------------------
;; Highlighting
;; ---------------------------------------------------------------------------
;; highlight region between point and mark
(transient-mark-mode t)
;; highlight during query
(setq query-replace-highlight t)
;; highlight incremental search
(setq search-highlight t)
;; Show matching parenthesis. How can you live without it.
(show-paren-mode t)
;; ---------------------------------------------------------------------------
;; Package install from MELPA
;;----------------------------------------------------------------------------
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://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)
;; ---------------------------------------------------------------------------
;; Editing modes
;;----------------------------------------------------------------------------
(load-file "~/.emacs.d/cmake-mode.el")
(require 'cmake-mode)
(require 'log-edit)
(require 'vc-git)
(setq auto-mode-alist
'(("\\.[Cc][Oo][Mm]\\'" . text-mode)
("\\.bat\\'" . bat-generic-mode)
("\\.inf\\'" . inf-generic-mode)
("\\.rc\\'" . rc-generic-mode)
("\\.reg\\'" . reg-generic-mode)
("\\.cob\\'" . cobol-mode)
("\\.cbl\\'" . cobol-mode)
("\\.te?xt\\'" . text-mode)
("\\.c\\'" . c-mode)
("\\.h\\'" . c++-mode)
("\\.adoc\\'" . adoc-mode)
("\\.d\\'" . d-mode)
("\\.tex$" . LaTeX-mode)
("\\.sty$" . LaTeX-mode)
("\\.bbl$" . LaTeX-mode)
("\\.bib$" . BibTeX-mode)
("\\.el\\'" . emacs-lisp-mode)
("\\.scm\\'" . scheme-mode)
("\\.l\\'" . lisp-mode)
("\\.lisp\\'" . lisp-mode)
("\\.f\\'" . fortran-mode)
("\\.F\\'" . fortran-mode)
("\\.for\\'" . fortran-mode)
("\\.p\\'" . pascal-mode)
("\\.pas\\'" . pascal-mode)
("\\.ad[abs]\\'" . ada-mode)
("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode)
("\\.cgi$" . perl-mode)
("\\.s?html?\\'" . sgml-mode)
("\\.idl\\'" . c++-mode)
("\\.cc\\'" . c++-mode)
("\\.hh\\'" . c++-mode)
("\\.hpp\\'" . c++-mode)
("\\.C\\'" . c++-mode)
("\\.H\\'" . c++-mode)
("\\.cpp\\'" . c++-mode)
("\\.[cC][xX][xX]\\'" . c++-mode)
("\\.hxx\\'" . c++-mode)
("\\.c\\+\\+\\'" . c++-mode)
("\\.h\\+\\+\\'" . c++-mode)
("\\.m\\'" . octave-mode)
("\\.java\\'" . java-mode)
("\\.ma?k\\'" . makefile-mode)
("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?" . makefile-mode)
("\\.am\\'" . makefile-mode)
("\\.mms\\'" . makefile-mode)
("CMakeLists.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode)
("\\.texinfo\\'" . texinfo-mode)
("\\.te?xi\\'" . texinfo-mode)
("\\.s\\'" . asm-mode)
("\\.S\\'" . asm-mode)
("\\.asm\\'" . asm-mode)
("ChangeLog\\'" . change-log-mode)
("change\\.log\\'" . change-log-mode)
("changelo\\'" . change-log-mode)
("ChangeLog\\.[0-9]+\\'" . change-log-mode)
("changelog\\'" . change-log-mode)
("changelog\\.[0-9]+\\'" . change-log-mode)
("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
("\\.scm\\.[0-9]*\\'" . scheme-mode)
("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
("\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'"
. sh-mode)
("\\(/\\|\\`\\)\\.\\(bash_logout\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'"
. sh-mode)
("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'"
. sh-mode)
("\\.mm\\'" . nroff-mode)
("\\.me\\'" . nroff-mode)
("\\.ms\\'" . nroff-mode)
("\\.man\\'" . nroff-mode)
("\\.[12345678]\\'" . nroff-mode)
("\\.TeX\\'" . TeX-mode)
("\\.sty\\'" . LaTeX-mode)
("\\.cls\\'" . LaTeX-mode)
("\\.clo\\'" . LaTeX-mode)
("\\.bbl\\'" . LaTeX-mode)
("\\.bib\\'" . BibTeX-mode)
("\\.m4\\'" . m4-mode)
("\\.mc\\'" . m4-mode)
("\\.mf\\'" . metafont-mode)
("\\.mp\\'" . metapost-mode)
("\\.vhdl?\\'" . vhdl-mode)
("\\.article\\'" . text-mode)
("\\.letter\\'" . text-mode)
("\\.tcl\\'" . tcl-mode)
("\\.exp\\'" . tcl-mode)
("\\.itcl\\'" . tcl-mode)
("\\.itk\\'" . tcl-mode)
("\\.icn\\'" . icon-mode)
("\\.sim\\'" . simula-mode)
("\\.mss\\'" . scribe-mode)
("\\.f90\\'" . f90-mode)
("\\.lsp\\'" . lisp-mode)
("\\.awk\\'" . awk-mode)
("\\.prolog\\'" . prolog-mode)
("\\.tar\\'" . tar-mode)
("\\.\\(arc\\|zip\\|lzh\\|zoo\\|jar\\)\\'" . archive-mode)
("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|JAR\\)\\'" . archive-mode)
("\\`/tmp/Re" . text-mode)
("/Message[0-9]*\\'" . text-mode)
("/drafts/[0-9]+\\'" . mh-letter-mode)
("\\.zone\\'" . zone-mode)
("\\`/tmp/fol/" . text-mode)
("\\.y\\'" . c-mode)
("\\.lex\\'" . c-mode)
("\\.oak\\'" . scheme-mode)
("\\.sgml?\\'" . sgml-mode)
("\\.xml\\'" . sgml-mode)
("\\.dtd\\'" . sgml-mode)
("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
("\\.idl\\'" . c++-mode)
("[]>:/\\]\\..*emacs\\'" . emacs-lisp-mode)
("\\`\\..*emacs\\'" . emacs-lisp-mode)
("[:/]_emacs\\'" . emacs-lisp-mode)
("\\.org\\'" . org-mode)
("\\.ml\\'" . lisp-mode)
("\\.tex$" . LaTeX-mode)
("\\.sty$" . LaTeX-mode)
("\\.bbl$" . LaTeX-mode)
("\\.bib$" . BibTeX-mode)
("\\.cls$" . LaTeX-mode)
("\\.clo$" . LaTeX-mode)
("\\.pdf$" . doc-view-mode)))
(autoload 'cmake-mode "~/.emacs.d/cmake-mode.el" t)
;; ---------------------------------------------------------------------------
;; Behaviour
;; --------------------------------------------------------------------------
;; don't make pesky backup files
(setq make-backup-files nil)
;; don't use version numbers for backup files
(setq version-control 'never)
;; Open unidentified files in text mode
(setq default-major-mode 'text-mode)
;; Do only one line scrolling.
(setq scroll-step 1)
;; Don't wrap long lines.
(set-default 'truncate-lines t)
;; Make the region visible (but only up to the next operation on it)
(setq transient-mark-mode t)
;; Colours ("Colors" in some other languages)
;; Give me colours in major editing modes!!!!!
(require 'font-lock)
(global-font-lock-mode t)
;; Don't add new lines to the end of a file when using down-arrow key
(setq next-line-add-newlines nil)
;; Dont show the GNU splash screen
;(setq inhibit-startup-message t)
;; Make all "yes or no" prompts show "y or n" instead
(fset 'yes-or-no-p 'y-or-n-p)
;; Delete selection when writing over it
(delete-selection-mode 1)
;; Make M-q equivalent to yank
(require 'bind-key)
(bind-key* "M-q" 'yank)
;; ---------------------------------------------------------------------------
;; Modeline
;; ---------------------------------------------------------------------------
;; Current line & column of cursor in the mode line (bar at the bottom)
(line-number-mode 1)
(setq column-number-mode t)
;; show current function in modeline
(which-func-mode t)
;; Display time in the mode line
;; Put this line last to prove (by the time in the mode line)
;; that the .emacs loaded without error to this point.
;; Unnaproved (too long, use calendar)
;;(setq display-time-day-and-date t )
;; Unnaproved (too long, replace by short format)
;;(setq display-time-24hr-format t)
;;(display-time)
(display-time-mode 1)
;; ---------------------------------------------------------------------------
;; Development: Debugger
;; ---------------------------------------------------------------------------
;; GDB (Debugger)
;; Split windows for gdb screens
(setq gdb-many-windows t
gdb-show-main t)
;; ---------------------------------------------------------------------------
;; Frames and windows sizes
;; ---------------------------------------------------------------------------
;; Disabling menubar, toolbar and scrollbar
(menu-bar-mode -1)
;(scroll-bar-mode -1)
;(tool-bar-mode -1)
;; (set-default-font "Terminus-12")
(setq default-frame-alist '((width . 120) (height . 43)))
;; (add-to-list 'default-frame-alist '(font . "Terminus-12"))
(add-to-list 'default-frame-alist '(foreground-color . "white"))
(add-to-list 'default-frame-alist '(background-color . "black"))
(setq initial-frame-alist '((width . 140) (height . 72)))
;; ---------------------------------------------------------------------------
;; No splash
;; ---------------------------------------------------------------------------
(setq inhibit-startup-message t)
;; ---------------------------------------------------------------------------
;; Advanced highlight (see also 'highlight' section)
;; ---------------------------------------------------------------------------
;(setq search-highlight t) ; Highlight search object
;(setq query-replace-highlight t) ; Highlight query object
(setq mouse-sel-retain-highlight t) ; Keep mouse high-lightening
(set-face-background 'region "red") ; Set region background color
(set-face-foreground 'region "black") ; Set region foreground color
(set-face-background 'isearch-lazy-highlight-face "yellow") ; Set isearch background color
(set-face-foreground 'isearch-lazy-highlight-face "black") ; Set isearch foreground color
(set-face-background 'isearch "green") ; Set highlight background color
(set-face-foreground 'isearch "black") ; Set highlight foreground color
; blue-white
; green-black
;; ---------------------------------------------------------------------------
;; C indentation
;; ---------------------------------------------------------------------------
; Set basic indentation in c of 4 spaces
(setq-default c-default-style "linux"
c-basic-offset 4)
;Auto indent
(add-hook 'c-mode-common-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
; Auto-close braces
(setq electric-layout-rules '((?\{ . around) (?\} . around)))
;; ---------------------------------------------------------------------------
;; TABs vs Spaces
;; ---------------------------------------------------------------------------
(setq-default indent-tabs-mode 'nil)
;; ---------------------------------------------------------------------------
;; Compile
;; ---------------------------------------------------------------------------
; Compile and handling regions for errors
(global-set-key (kbd "C-c c") 'compile)
;; ---------------------------------------------------------------------------
;; Regions
;; ---------------------------------------------------------------------------
;; Important keybinding C-M-\ for indent region
;; Comment and uncomment regions
(global-set-key (kbd "C-c ,") 'comment-region)
(global-set-key (kbd "C-c .") 'uncomment-region)
;; ---------------------------------------------------------------------------
;; TRAMP
;; ---------------------------------------------------------------------------
(require 'tramp)
(setq tramp-default-method "ssh")
;; C-x C-f /remotehost:filename RET (or /method:user@remotehost:filename)
;; C-x C-f /su::/etc/hosts
;; C-x C-f /sudo::/etc/hosts
; Enable for debugging purposes
(setq tramp-debug-buffer t)
(setq tramp-verbose 10)
;; /<user>@<host>:/path/to/file or
;; /<protocol>:<user>@<host>:/path/to/file,
;; ---------------------------------------------------------------------------
;; SEMANTIC
;; ---------------------------------------------------------------------------
(add-hook
'c-mode-common-hook
(lambda()
(define-key c-mode-base-map
(kbd "M-<right>") 'semantic-ia-fast-jump)))
(global-set-key
(kbd "M-<left>")
(lambda()(interactive) (set-mark-command 4)))
(global-set-key [M-up] 'pop-global-mark)
;; ---------------------------------------------------------------------------
;; EDIFF MODE
;; ---------------------------------------------------------------------------
(setq ediff-split-window-function 'split-window-horizontally)
;; ---------------------------------------------------------------------------
;; SCALE FONT
;; ---------------------------------------------------------------------------
(set-face-attribute 'default (selected-frame) :height 135)
(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.
'(package-selected-packages
(quote
(adoc-mode zygospore yasnippet ws-butler volatile-highlights use-package undo-tree sr-speedbar rtags rpm-spec-mode neotree json-mode iedit helm-swoop helm-projectile helm-gtags ggtags dtrt-indent d-mode company cmake-ide clean-aindent-mode anzu))))
(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.
)
;; ---------------------------------------------------------------------------
;; HELM
;; ---------------------------------------------------------------------------
(require 'helm-config)
(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(with-eval-after-load 'helm
(define-key helm-map (kbd "TAB") #'helm-maybe-exit-minibuffer))
(helm-mode 1)