-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
407 lines (324 loc) · 12.2 KB
/
init.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
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
395
396
397
398
399
400
401
402
403
404
405
406
407
;;; Emacs.el --- Starting point in Emacs configuration.
;;; Commentary:
;;;
;;; Starting point in Emacs configuration.
;;; Code:
; Dvorak tweak
(define-key key-translation-map [?\C-x] [?\C-u])
(define-key key-translation-map [?\C-u] [?\C-x])
(require 'cl-lib) ; cl-set-difference
; Widgets and themes
(setq inhibit-splash-screen t)
(let* ((monospaced "Noto Mono-11")
(sans-serif "Noto Sans-13")
(serif "Noto Serif")
(font monospaced))
(setq default-frame-alist
`((fullscreen . nil)
(width . 80)
(height . 40)
(line-spacing . 3)
(font . ,font))))
(add-to-list 'same-window-regexps "\*magit: .*\*")
(tool-bar-mode 0)
(menu-bar-mode 0)
(if (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
; Environment
(setenv "PAGER" "cat")
; Global parameters
(setq make-backup-files nil)
(setq default-directory "~/")
(setq-default indent-tabs-mode nil)
(setq ring-bell-function 'ignore)
(setq buffer-file-coding-system 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-language-environment "utf-8")
(global-font-lock-mode -1)
(auto-save-mode 0)
(column-number-mode 1)
(display-time-mode)
(electric-pair-mode 1)
;;(global-linum-mode -1)
; Packages
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("gnu-devel" . "https://elpa.gnu.org/devel/")
("melpa". "https://melpa.org/packages/")))
(package-initialize)
(unless package-activated-list (package-refresh-contents))
(let ((needed-packages '(ace-jump-mode
adoc-mode
ag
elpy
go-mode
helm
jq-mode
julia-mode
julia-repl
magit
monkeytype
monotropic-theme
paredit
restclient
slime
solarized-theme
markdown-mode
use-package
)))
(when
(or (null package-activated-list)
(cl-set-difference package-activated-list needed-packages))
(mapc (lambda (p) (or (package-installed-p p) (package-install p)))
needed-packages)))
(require 'use-package)
; Theme
(when (display-graphic-p)
(setq x-underline-at-descent-line t)
(load-theme 'solarized-light t))
; Helm
(require '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)
(setq helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t
helf-ff-search-library-in-sexp t
helm-scroll-amount 8
helm-ff-file-name-history-use-recentf t
helm-echo-input-in-header-line t)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
;;(helm-autoresize-mode 1)
(helm-mode 1)
; Dvorak tweaks
(global-set-key (kbd "C-x h") 'helm-M-x)
(global-set-key (kbd "C-x C-h") 'helm-M-x)
; Paths
(setq load-path (cons "~/.emacs.d/lisp" load-path))
; Keybindings
(global-set-key (kbd "C-c w") 'eww)
(global-set-key (kbd "C-c i") 'erc-tls)
(global-set-key (kbd "C-c s") 'eshell)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c h") 'help-map)
(global-set-key (kbd "C-c n") 'gnus)
(global-set-key (kbd "C-c SPC") 'ace-jump-mode)
; Gnus
;;(setq gnus-select-method '(nntp "news.gmane.org"))
(setq gnus-select-method
'(nnimap "imap.fastmail.com"
(nnimap-expunge t)
(nnimap-stream ssl)))
; SMTP
(setq user-full-name "Marco Benelli"
user-mail-address "[email protected]")
(setq message-send-mail-function 'smtpmail-send-it)
(setq smtpmail-smtp-server "smtp.fastmail.com"
smtpmail-smtp-service 465
smtpmail-stream-type 'ssl
smtpmail-smtp-user "[email protected]")
; Special characters
(fset 'euro
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "EURO SIGN"))))
(fset 'epsilon
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "GREEK SMALL LETTER EPSILON"))))
(fset 'section
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "SECTION SIGN"))))
(fset 'diminished
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "DEGREE SIGN"))))
(fset 'half-diminished
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "EMPTY SET"))))
(fset 'flat
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "MUSIC FLAT SIGN"))))
(fset 'sharp
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "MUSIC SHARP SIGN"))))
(fset 'natural
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(insert (char-from-name "MUSIC NATURAL SIGN"))))
; Tramp
(setq tramp-default-method "ssh")
; Org
(add-hook 'org-mode-hook
'(lambda nil
(visual-line-mode)
(turn-on-font-lock)
(disable-show-trailing-whitespace)))
; Markdown
(autoload 'markdown-mode "markdown-mode")
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-hook 'markdown-mode-hook
'(lambda nil
(visual-line-mode)))
; Lilypond
(autoload 'LilyPond-mode "lilypond-mode")
(add-to-list 'auto-mode-alist '("\\.ly$" . LilyPond-mode))
(add-hook 'LilyPond-mode-hook
'(lambda nil
(define-key LilyPond-mode-map "\C-c\C-p"
'LilyPond-command-viewpdf)))
; Eshell
(require 'eshell)
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
(add-hook 'eshell-mode-hook
'(lambda nil
(setenv "PATH"
(concat (getenv "PATH") ":" (getenv "HOME") "/bin"))))
(defun eshell/clear ()
"04Dec2001 - sailor, to clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
; Tables
(setq table-cell-horizontal-chars "\u2500")
(setq table-cell-vertical-char ?\u2502)
(setq table-cell-intersection-char ?\u253C)
; Org Mode
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
; Autopair
;; (require 'autopair)
;; (autopair-global-mode 1)
;; (setq autopair-autowrap t)
; Irc
(require 'erc)
; Projectile
;; (projectile-global-mode)
;; (setq projectile-completion-system 'helm)
;; (setq projectile-mod-line nil)
;; (add-to-list 'projectile-globally-ignored-directories ".cquery_cached_index")
;; (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
; Elisp
(add-hook 'emacs-lisp-mode-hook
(lambda ()
;;(auto-complete-mode 1)
))
; Slime
(setq inferior-lisp-program "sbcl")
; Gambit Scheme
(autoload 'gambit-inferior-mode "gambit" "Hook Gambit mode into cmuscheme.")
(autoload 'gambit-mode "gambit" "Hook Gambit mode into scheme.")
(add-hook 'inferior-scheme-mode-hook (function gambit-inferior-mode))
(add-hook 'scheme-mode-hook (function gambit-mode))
(setq scheme-program-name "gsi -:d-")
; C++
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(setq c-default-style "stroustrup"
c-basic-offset 4
indent-tabs-mode nil)
; Golang
(add-hook 'before-save-hook 'gofmt-before-save)
; Julia
(add-hook 'julia-mode-hook 'julia-repl-mode)
; misc
;; (autoload 'ace-jump-mode "ace-jump-mode")
; Paredit
(autoload 'enable-paredit-mode "paredit"
"Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode)
(add-hook 'slime-mode-hook #'enable-paredit-mode)
; QML
;;(autoload 'qml-mode "qml-mode" "Editing Qt Declarative." t)
;;(add-to-list 'auto-mode-alist '("\\.qml$" . qml-mode))
; Javascript
(setq js-indent-level 4)
; Json
(with-eval-after-load "json-mode"
(define-key json-mode-map (kbd "C-c C-j") #'jq-interactively))
(add-hook 'js-json-mode-hook
(lambda ()
(define-key js-json-mode-map (kbd "C-c C-j") #'jq-interactively)))
; Mode line cleaner
(defvar mode-line-cleaner-alist
`((yas/minor-mode . " y")
(yas-minor-mode . " y")
(paredit-mode . " π")
(flycheck-mode . " φ")
(eldoc-mode . "")
(abbrev-mode . "")
(golden-ratio-mode . "")
(projectile-mode . " Π")
(magit-auto-revert-mode . "")
(helm-mode . " h")
(helm-gtags-mode . " gh")
(autopair-mode . "")
(auto-complete-mode . " α")
(company-mode . " c")
;; Major modes
(lisp-interaction-mode . "λ")
(scheme-mode . "λ")
(clojure-mode . "λ")
(cider-repl-mode . "λ")
(hi-lock-mode . "")
(python-mode . "Py")
(emacs-lisp-mode . "ɛλ")
(nxhtml-mode . "nx"))
"Alist for `clean-mode-line'.
When you add a new element to the alist, keep in mind that you
must pass the correct minor/major mode symbol and a string you
want to use in the modeline *in lieu of* the original.")(defun clean-mode-line ()
"Clean-up the mode-line according to rules defined in `mode-line-cleaner-alist'."
(interactive)
(dolist (cleaner mode-line-cleaner-alist)
(let* ((mode (car cleaner))
(mode-str (cdr cleaner))
(old-mode-str (cdr (assq mode minor-mode-alist))))
(when old-mode-str
(setcar old-mode-str mode-str))
;; major mode
(when (eq mode major-mode)
(setq mode-name mode-str)))))
(add-hook 'after-change-major-mode-hook 'clean-mode-line)
(require 'local)
;;
(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.
'(battery-mode-line-format "[%b%p%%]")
'(compilation-scroll-output 'first-error)
'(display-time-24hr-format t)
'(eww-download-directory "~/downloads/")
'(markdown-xhtml-header-content
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />")
'(send-mail-function 'sendmail-send-it))
(provide 'init)
;;; init.el ends here