summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/emacs.el
blob: d7080e360d35800a631cd5ac19ca10d15947ae0c (plain)
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
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)

(setq inhibit-startup-message t)
(defalias 'yes-or-no-p 'y-or-n-p)

(set-face-attribute 'default nil :font "FiraCode Nerd Font Mono" :height 49)

(require 'package)
(setq package-archives nil)
(package-initialize)
(require 'use-package)
(use-package use-package-ensure-system-package :ensure t)

(require 'evil)
(evil-mode 1)

(global-subword-mode)
(global-undo-tree-mode)
(global-fira-code-mode)

(evil-set-undo-system 'undo-tree)

(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "M-g") 'magit-status)
(global-set-key (kbd "M-?") 'vc-git-grep)

(require 'git-gutter)
(global-git-gutter-mode t)
(custom-set-variables '(git-gutter:update-interval 2))
(custom-set-variables '(git-gutter:hide-gutter t))

(setq backup-directory-alist `(("." . "~/.saves")))
(setq undo-tree-history-directory-alist `(("." . "~/.undo")))
(setq delete-old-versions t
      kept-new-versions 6
      kept-old-versions 2
      version-control t)

(setq undo-tree-visualizer-timestamps t
      undo-tree-visualizer-diff t
      ;; 10X bump of the undo limits to avoid issues with premature
      ;; Emacs GC which truncages the undo history very aggresively
      undo-limit 800000
      undo-strong-limit 12000000
      undo-outer-limit 120000000)

(add-hook 'haskell-mode-hook 'haskell-indentation-mode)
(add-hook 'haskell-mode-hook 'subword-mode)
(add-hook 'haskell-mode-hook 'highlight-symbol-mode)
(add-hook 'haskell-mode-hook 'highlight-paretheses-mode)

(add-hook 'js-mode-hook 'highlight-symbol-mode)
(add-hook 'js-mode-hook 'highlight-parentheses-mode)
(defun my-js-mode-hook ()
  "Custom `js-mode' behaviours."
  (setq js-indent-level 2)
  )
(add-hook 'js-mode-hook 'my-js-mode-hook)

(setq undo-tree-auto-save-history t)

(defvar expand-file-name-custom-tilde-alist '())
(defun my/add-to-tilde-alist (hash)
  (let* ((tilde:dir (split-string hash "="))
	 (tilde (car tilde:dir))
	 (dir (cadr tilde:dir)))
    (push (cons tilde dir) expand-file-name-custom-tilde-alist)))
(mapc #'my/add-to-tilde-alist
      (split-string (with-output-to-string
		      (call-process "zsh" nil standard-output nil "-ic" "hash -d"))
		    "\n" t))

(defadvice expand-file-name (before expand-file-name-custom-tilde
                             (name &optional default-directory)
                             activate compile)
  "User-defined expansions for ~NAME in file names."
  (save-match-data
    (when (string-match "\\`\\(\\(.*/\\)?~\\([^:/]+\\)\\)/" name)
      (let ((replacement (assoc (match-string 3 name) expand-file-name-custom-tilde-alist)))
        (when replacement
          (setq name (replace-match (cdr replacement) t t name 1)))))))

(setq notmuch-address-internal-completion '(received nil))
(setq notmuch-always-prompt-for-sender t)
(setq notmuch-command "notmuch-ssh")
(setq notmuch-crypto-process-mime t)
(setq notmuch-draft-tags '("+draft" "-inbox"))
(setq notmuch-fcc-dirs nil)
(setq notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches))
(setq notmuch-hello-thousands-separator " ")
(setq notmuch-identities '("gkleen@yggdrasil.li" "g@141.li" "kleen@cip.ifi.lmu.de" "Gregor.Kleen@stud.ifi.lmu.de" "G.Kleen@campus.lmu.de" "G.Kleen@lmu.de" "gregor.kleen@ifi.lmu.de" "uni2work@ifi.lmu.de" "gregor@kleen.li"))
(setq notmuch-message-headers '("Subject" "To" "Cc" "Date"))
(setq notmuch-message-replied-tags '("+replied" "-unread" "-inbox"))
(setq notmuch-saved-searches
      (quote
       ((:name "inbox" :query "tag:inbox" :key "i")
	(:name "unread" :query "tag:unread AND tag:inbox" :key "u")
	(:name "drafts" :query "tag:draft" :key "d")
	(:name "all mail" :query "date:month.." :key "a" :count-query "*")
	(:name "sent" :query "is:sent" :key "s" :count-query "is:sent")
      )))
(setq notmuch-search-oldest-first nil)
(setq notmuch-show-all-tags-list t)
(setq notmuch-show-logo nil)

(setq send-mail-function 'sendmail-send-it)
(setq mail-envelope-from 'header)
(setq mail-specify-envelope-from 't)
(setq mail-default-headers nil)
(setq message-default-headers "")
(setq message-default-mail-headers "")
(setq message-sendmail-envelope-from 'header)

(setq highlight-symbol-idle-delay 0)

(setq indent-tabs-mode nil)

(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)

(setq mail-host-address "sif.midgard.yggdrasil")
(setq user-full-name "Gregor Kleen")

(defun tell-emacsclients-for-buffer-to-die ()
  "Sends error exit command to every client for the current buffer."
  (interactive)
  (dolist (proc server-buffer-clients)
    (server-send-string proc "-error die")))

(defun kill-buffer-with-special-emacsclient-handling ()
  "Wrapper around kill-buffer that ensures tell-emacsclients-for-buffer-to-die is on the hooks"
  (interactive)
  (add-hook 'kill-buffer-hook 'tell-emacsclients-for-buffer-to-die nil t)
  (kill-buffer))

;; (global-set-key (kbd "C-x k") 'kill-buffer)

(defun install-emacsclient-wrapped-kill-buffer ()
  "Installs wrapped kill-buffer with special emacsclient handling.
Best not to install it unconditionally because the server is not
necessarily running."
  (interactive)
  (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling))

(add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer)