diff options
Diffstat (limited to 'accounts/gkleen@sif/emacs.el')
-rw-r--r-- | accounts/gkleen@sif/emacs.el | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/emacs.el b/accounts/gkleen@sif/emacs.el new file mode 100644 index 00000000..b22c00f5 --- /dev/null +++ b/accounts/gkleen@sif/emacs.el | |||
@@ -0,0 +1,178 @@ | |||
1 | (menu-bar-mode -1) | ||
2 | (scroll-bar-mode -1) | ||
3 | (tool-bar-mode -1) | ||
4 | |||
5 | (setq inhibit-startup-message t) | ||
6 | (defalias 'yes-or-no-p 'y-or-n-p) | ||
7 | |||
8 | (set-face-attribute 'default nil :font "FiraCode Nerd Font Mono" :height 49) | ||
9 | |||
10 | (require 'package) | ||
11 | (setq package-archives nil) | ||
12 | (package-initialize) | ||
13 | (require 'use-package) | ||
14 | (use-package use-package-ensure-system-package :ensure t) | ||
15 | |||
16 | (require 'evil) | ||
17 | (evil-mode 1) | ||
18 | |||
19 | (global-subword-mode) | ||
20 | (global-undo-tree-mode) | ||
21 | (global-fira-code-mode) | ||
22 | |||
23 | (evil-set-undo-system 'undo-tree) | ||
24 | |||
25 | (global-set-key (kbd "RET") 'newline-and-indent) | ||
26 | (global-set-key (kbd "M-g") 'magit-status) | ||
27 | (global-set-key (kbd "M-?") 'vc-git-grep) | ||
28 | |||
29 | (require 'git-gutter) | ||
30 | (global-git-gutter-mode t) | ||
31 | (custom-set-variables '(git-gutter:update-interval 2)) | ||
32 | (custom-set-variables '(git-gutter:hide-gutter t)) | ||
33 | |||
34 | ;; (require 'scratch) | ||
35 | (global-set-key (kbd "C-x B") 'scratch-create) | ||
36 | (setq initial-major-mode 'scratch-mode) | ||
37 | (setq initial-scratch-message "") | ||
38 | |||
39 | (global-set-key (kbd "C-x K") 'kill-current-buffer) | ||
40 | |||
41 | (setq backup-directory-alist `(("." . "~/.saves"))) | ||
42 | (setq undo-tree-history-directory-alist `(("." . "~/.undo"))) | ||
43 | (setq delete-old-versions t | ||
44 | kept-new-versions 6 | ||
45 | kept-old-versions 2 | ||
46 | version-control t) | ||
47 | |||
48 | (setq undo-tree-visualizer-timestamps t | ||
49 | undo-tree-visualizer-diff t | ||
50 | ;; 10X bump of the undo limits to avoid issues with premature | ||
51 | ;; Emacs GC which truncages the undo history very aggresively | ||
52 | undo-limit 800000 | ||
53 | undo-strong-limit 12000000 | ||
54 | undo-outer-limit 120000000) | ||
55 | |||
56 | (add-hook 'haskell-mode-hook 'haskell-indentation-mode) | ||
57 | (add-hook 'haskell-mode-hook 'subword-mode) | ||
58 | (add-hook 'haskell-mode-hook 'highlight-symbol-mode) | ||
59 | (add-hook 'haskell-mode-hook 'highlight-paretheses-mode) | ||
60 | |||
61 | (add-hook 'js-mode-hook 'highlight-symbol-mode) | ||
62 | (add-hook 'js-mode-hook 'highlight-parentheses-mode) | ||
63 | (defun my-js-mode-hook () | ||
64 | "Custom `js-mode' behaviours." | ||
65 | (setq js-indent-level 2) | ||
66 | ) | ||
67 | (add-hook 'js-mode-hook 'my-js-mode-hook) | ||
68 | |||
69 | (setq undo-tree-auto-save-history t) | ||
70 | |||
71 | (defvar expand-file-name-custom-tilde-alist '(("u2w-dev1" . "/ssh:uni2work-dev1:/home/gkleen/projects/uni2work"))) | ||
72 | (defun my/add-to-tilde-alist (hash) | ||
73 | (let* ((tilde:dir (split-string hash "=")) | ||
74 | (tilde (car tilde:dir)) | ||
75 | (dir (cadr tilde:dir))) | ||
76 | (push (cons tilde dir) expand-file-name-custom-tilde-alist))) | ||
77 | (mapc #'my/add-to-tilde-alist | ||
78 | (split-string (with-output-to-string | ||
79 | (call-process "zsh" nil standard-output nil "-ic" "hash -d")) | ||
80 | "\n" t)) | ||
81 | |||
82 | (defadvice expand-file-name (before expand-file-name-custom-tilde | ||
83 | (name &optional default-directory) | ||
84 | activate compile) | ||
85 | "User-defined expansions for ~NAME in file names." | ||
86 | (save-match-data | ||
87 | (when (string-match "\\`\\(\\(.*/\\)?~\\([^:/]+\\)\\)/" name) | ||
88 | (let ((replacement (assoc (match-string 3 name) expand-file-name-custom-tilde-alist))) | ||
89 | (when replacement | ||
90 | (setq name (replace-match (cdr replacement) t t name 1))))))) | ||
91 | |||
92 | (setq notmuch-address-internal-completion '(received nil)) | ||
93 | (setq notmuch-always-prompt-for-sender t) | ||
94 | (setq notmuch-command "notmuch-ssh") | ||
95 | (setq notmuch-crypto-process-mime t) | ||
96 | (setq notmuch-draft-tags '("+draft" "-inbox")) | ||
97 | (setq notmuch-fcc-dirs nil) | ||
98 | (setq notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches)) | ||
99 | (setq notmuch-hello-thousands-separator " ") | ||
100 | (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")) | ||
101 | (setq notmuch-message-headers '("Subject" "To" "Cc" "Date")) | ||
102 | (setq notmuch-message-replied-tags '("+replied" "-unread" "-inbox")) | ||
103 | (setq notmuch-saved-searches | ||
104 | (quote | ||
105 | ((:name "inbox" :query "tag:inbox" :key "i") | ||
106 | (:name "unread" :query "tag:unread AND tag:inbox" :key "u") | ||
107 | (:name "drafts" :query "tag:draft" :key "d") | ||
108 | (:name "all mail" :query "date:month.." :key "a" :count-query "*") | ||
109 | (:name "sent" :query "is:sent" :key "s" :count-query "is:sent") | ||
110 | ))) | ||
111 | (setq notmuch-search-oldest-first nil) | ||
112 | (setq notmuch-show-all-tags-list t) | ||
113 | (setq notmuch-show-logo nil) | ||
114 | |||
115 | (setq send-mail-function 'sendmail-send-it) | ||
116 | (setq mail-envelope-from 'header) | ||
117 | (setq mail-specify-envelope-from 't) | ||
118 | (setq mail-default-headers nil) | ||
119 | (setq message-default-headers "") | ||
120 | (setq message-default-mail-headers "") | ||
121 | (setq message-sendmail-envelope-from 'header) | ||
122 | |||
123 | (setq highlight-symbol-idle-delay 0) | ||
124 | |||
125 | (setq indent-tabs-mode nil) | ||
126 | |||
127 | (setq ido-enable-flex-matching t) | ||
128 | (setq ido-everywhere t) | ||
129 | (ido-mode 1) | ||
130 | |||
131 | (setq tramp-default-method "ssh") | ||
132 | (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) | ||
133 | |||
134 | (setq direnv-enabled-hosts '("uni2work-dev1")) | ||
135 | |||
136 | (defun tramp-sh-handle-start-file-process@my-direnv (args) | ||
137 | "Enable Direnv for hosts in `direnv-enabled-hosts'." | ||
138 | (with-parsed-tramp-file-name (expand-file-name default-directory) nil | ||
139 | (if (member host direnv-enabled-hosts) | ||
140 | (pcase-let ((`(,name ,buffer ,program . ,args) args)) | ||
141 | `(,name | ||
142 | ,buffer | ||
143 | "direnv" | ||
144 | "exec" | ||
145 | ,localname | ||
146 | ,program | ||
147 | ,@args)) | ||
148 | args))) | ||
149 | |||
150 | (with-eval-after-load "tramp-sh" | ||
151 | (advice-add 'tramp-sh-handle-start-file-process | ||
152 | :filter-args #'tramp-sh-handle-start-file-process@my-direnv)) | ||
153 | |||
154 | (setq mail-host-address "sif.midgard.yggdrasil") | ||
155 | (setq user-full-name "Gregor Kleen") | ||
156 | |||
157 | (defun tell-emacsclients-for-buffer-to-die () | ||
158 | "Sends error exit command to every client for the current buffer." | ||
159 | (interactive) | ||
160 | (dolist (proc server-buffer-clients) | ||
161 | (server-send-string proc "-error die"))) | ||
162 | |||
163 | (defun kill-buffer-with-special-emacsclient-handling () | ||
164 | "Wrapper around kill-buffer that ensures tell-emacsclients-for-buffer-to-die is on the hooks" | ||
165 | (interactive) | ||
166 | (add-hook 'kill-buffer-hook 'tell-emacsclients-for-buffer-to-die nil t) | ||
167 | (kill-buffer)) | ||
168 | |||
169 | ;; (global-set-key (kbd "C-x k") 'kill-buffer) | ||
170 | |||
171 | (defun install-emacsclient-wrapped-kill-buffer () | ||
172 | "Installs wrapped kill-buffer with special emacsclient handling. | ||
173 | Best not to install it unconditionally because the server is not | ||
174 | necessarily running." | ||
175 | (interactive) | ||
176 | (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) | ||
177 | |||
178 | (add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) | ||