home · contact · privacy
Improve mail setup.
[config] / buster / home_files / user_eeepc / .emacs.d / init.el
1 ;; general layout
2 ;; ==============
3
4 ;; need no stinkin emacs help screen as start up, and no menu bar
5 (setq inhibit-startup-screen t)
6 (menu-bar-mode -1)
7
8 ;; highlight cursor line, parentheses
9 (global-hl-line-mode 1)
10 (show-paren-mode 1)
11
12 ;; show line numbers, use separator space
13 (global-linum-mode)
14 (setq linum-format "%d ")
15
16 ;; count cursor column, row in mode line
17 (setq column-number-mode t)
18
19 ;; settings to make GUI tolerable
20 (if window-system
21   (progn
22     (add-to-list 'default-frame-alist '(foreground-color . "white"))
23     (add-to-list 'default-frame-alist '(background-color . "black"))
24     (set-face-attribute 'default nil :height 80)
25     (scroll-bar-mode -1)
26     (setq visible-bell t)
27     (setq linum-format "%d")))
28
29 ;; use as default browser what XDG offers
30 (setq-default browse-url-browser-function 'browse-url-xdg-open)
31
32 ;; general keybindings
33 ;; ===================
34
35 ;; create and use a minimal global map using just the self-insert command
36 ;; bindings and a selection of some to me very common keystrokes
37 (setq minimal-map (make-sparse-keymap))
38 (substitute-key-definition 'self-insert-command 'self-insert-command
39                            minimal-map global-map)
40 (use-global-map minimal-map)
41 (global-set-key (kbd "DEL") 'backward-delete-char-untabify)
42 (global-set-key (kbd "RET") 'newline)
43 (global-set-key (kbd "TAB") 'indent-for-tab-command)
44 (global-set-key (kbd "<up>") 'previous-line)
45 (global-set-key (kbd "<down>") 'next-line)
46 (global-set-key (kbd "<left>") 'left-char)
47 (global-set-key (kbd "<right>") 'right-char)
48 (global-set-key (kbd "<prior>") 'scroll-down-command)
49 (global-set-key (kbd "<next>") 'scroll-up-command)
50 (global-set-key (kbd "M-x") 'execute-extended-command)
51 (global-set-key (kbd "C-g") 'keyboard-quit)
52 ;(global-set-key (kbd "<f3>") 'kmacro-start-macro-or-insert-counter)
53 ;(global-set-key (kbd "<f4>") 'kmacro-end-or-call-macro)
54 ;; note how to switch back to the original map: (use-global-map global-map)
55 (setq shr-map (make-sparse-keymap))  ; got annoying in elfeed-show on URLs
56
57
58 ;; minibuffer
59 ;; ==========
60
61 ;; incremental minibuffer completion
62 (icomplete-mode 1)
63
64
65
66 ;; text editing
67 ;; ============
68
69 ;; tabs are evil
70 (setq-default indent-tabs-mode nil)
71 (setq-default tab-width 4)
72 (setq indent-line-function 'insert-tab)
73
74 ;; show trailing whitespace
75 (setq-default show-trailing-whitespace 1)
76
77 ;; on save, ask whether to ensure text file's last line ends in a
78 ;; newline character
79 (setq require-final-newline 1)
80
81 ;; use dedicated directory for version-controlled, endless backups;
82 ;; never delete old versions
83 (setq make-backup-files t
84       backup-directory-alist `(("." . "~/.emacs_backups"))
85       backup-by-copying t
86       version-control t
87       delete-old-versions 1)  ;; neither t nor nil: never delete
88
89
90
91 ;; package management
92 ;; ==================
93
94 ;; where we get packages from
95 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
96                          ("melpa-unstable" . "https://melpa.org/packages/")
97                          ("melpa-stable" . "https://stable.melpa.org/packages/")))
98
99 ;; ensure certain packages are installed (actually, we use Debian repos here)
100 ;; credit to <https://stackoverflow.com/a/10093312>
101 ;(setq package-list '(elfeed ledger-mode))
102 ;(package-initialize)
103 ;(dolist (package package-list)
104 ;  (unless (package-installed-p package)
105 ;    (package-install package)))
106
107
108
109 ;;; window management
110 ;;; =================
111 ;
112 ;;; track window configurations to allow window config undo
113 ;(winner-mode 1)
114
115
116
117 ;; mail setup
118 ;; ==========
119
120 (setq send-mail-function 'smtpmail-send-it)
121 (setq smtpmail-smtp-server "core.plomlompom.com")
122 (setq smtpmail-smtp-service 465)
123 (setq smtpmail-stream-type 'ssl)
124 (setq smtpmail-smtp-user "plom")
125 (setq mml-secure-openpgp-encrypt-to-self t)
126
127 ;; constructs From: domain if mail composer directly called (from without
128 ;; notmuch), but we don't actually intend to do that
129 ;(setq mail-host-address "plomlompom.com")
130
131 ;; otherwise notmuch becomes extremely slow in some cases
132 (setq-default notmuch-show-indent-content nil)
133
134 ;; this only works if we use notmuch-mua-send instead of message-send
135 (setq notmuch-fcc-dirs '(("plom@plomlompom.com" . "maildir/Sent")))
136
137
138 ;; org mode
139 ;; ========
140
141 ;; unsure why, but to re-set the key map, we not only have to explicitely do it
142 ;; only after org-mode loading, but also have to explicitely overwrite the
143 ;; C-c keybinding; TODO: investigate
144 (with-eval-after-load 'org
145     (setq org-mode-map (make-sparse-keymap))
146     (define-key org-mode-map (kbd "C-c") nil)
147     (define-key org-mode-map (kbd "TAB") 'org-cycle)
148     (define-key org-mode-map (kbd "<backtab>") 'org-shifttab))
149
150 ;; basic org-capture config
151 (setq org-capture-templates
152       '(("x" "test" plain (file "~/org/notes.org") "%T: %?")))
153 (add-hook 'org-capture-mode-hook 'evil-insert-state)
154
155 ;; agenda view on startup
156 (load-library "find-lisp")
157 (setq org-agenda-files (find-lisp-find-files "~/org" "\.org$"))
158 (setq org-agenda-span 90)
159 (setq org-agenda-use-time-grid nil)
160 (add-hook 'emacs-startup-hook (lambda ()
161                                  (org-agenda-list)
162                                  (switch-to-buffer "*Org Agenda*")
163                                  (other-window 1)))
164
165 ;;; for calendar, use ISO date style
166 ;(setq calendar-date-style 'iso)
167 ;(setq diary-number-of-entries 7)
168 ;(diary)
169 ;(setq org-agenda-time-grid '((today require-timed remove-match)
170 ;                             #("----------------" 0 16 (org-heading t))
171 ;                             (0 200 400 600 800 1000 1200
172 ;                                1400 1600 1800 2000 2200)))
173
174 ;; empty org-agenda-mode keybindings
175 (add-hook 'org-agenda-mode-hook
176           (lambda ()
177             (setq org-agenda-mode-map (make-sparse-keymap))))
178 (add-hook 'org-agenda-mode-hook
179           (lambda ()
180             (use-local-map (make-sparse-keymap))))
181
182 ;; org-publish-all
183 (setq org-publish-project-alist
184       '(
185         ("website"
186          :base-directory "~/org/web/"
187          :base-extension "org"
188          :publishing-directory "~/html/"
189          :recursive t
190          :publishing-function org-html-publish-to-html
191          :headline-levels 4             ; Just the default for this project.
192          :auto-preamble t
193           )))
194
195 ;; use [ki:] syntax to hide stuff from exports
196 (defun classify-information (text backend info)
197   "Replaces '[ki:WHATEVER]' with '[klassifizierte Information]'."
198   (replace-regexp-in-string "\\[ki:[^\]]*\]" "[klassifizierte Information]" text))
199 (add-hook 'org-export-filter-plain-text-functions 'classify-information)
200
201 ;; add HTML validator link to exports
202 (setq org-html-validation-link "<a href=\"https://validator.w3.org/check?uri=referer\">Validate</a>")
203
204
205
206 ;;; plomvi mode
207 ;;; ===========
208 (load "~/public_repos/plomvi.el/plomvi.el")
209 (global-set-key (kbd "C-c") 'plomvi-activate)
210 (plomvi-global-mode 1)
211
212
213
214 ;;; Info mode
215 ;;; =========
216
217 (setq Info-mode-map (make-sparse-keymap))
218 (define-key Info-mode-map (kbd "RET") 'Info-follow-nearest-node)
219 (define-key Info-mode-map (kbd "u") 'Info-up)
220 (define-key Info-mode-map (kbd "TAB") 'Info-next-reference)
221 (define-key Info-mode-map (kbd "<backtab>") 'Info-prev-reference)
222 (define-key Info-mode-map (kbd "H") 'Info-history-back)
223 (define-key Info-mode-map (kbd "L") 'Info-history-forward)
224 (define-key Info-mode-map (kbd "I") 'Info-goto-node)
225 (define-key Info-mode-map (kbd "i") 'Info-index)
226
227 ;; help mode
228 ;; =========
229
230 (setq help-mode-map (make-sparse-keymap))
231 (define-key help-mode-map (kbd "TAB") 'forward-button)
232 (define-key help-mode-map (kbd "RET") 'help-follow)
233 (define-key help-mode-map (kbd "<backtab>") 'backward-button)
234
235 ;; elfeed
236 ;; ======
237
238 (require 'elfeed)  ; needed so we can set the font faces
239 (set-face-background 'elfeed-search-title-face "magenta")
240 (set-face-background 'elfeed-search-unread-count-face "magenta")
241 (setq elfeed-feeds
242       '("https://capsurvival.blogspot.com/feeds/posts/default"
243         "https://jungle.world/rss.xml"
244         "http://news.dieweltistgarnichtso.net/bin/index.xml"
245         "https://taz.de/!s=&ExportStatus=Intern&SuchRahmen=Online;rss/"
246         "http://www.tagesschau.de/xml/atom"))
247 (setq elfeed-search-mode-map (make-sparse-keymap))
248 (define-key elfeed-search-mode-map (kbd "RET") 'elfeed-search-show-entry)
249 (defun elfeed-search-mark-as-read() (interactive)
250   (elfeed-search-untag-all 'unread))
251 (define-key elfeed-search-mode-map (kbd "r") 'elfeed-search-mark-as-read)
252 (define-key elfeed-search-mode-map (kbd "R") 'elfeed-search-tag-all-unread)
253 (define-key elfeed-search-mode-map (kbd "f") 'elfeed-search-live-filter)
254 (define-key elfeed-search-mode-map (kbd "u") 'elfeed-update)
255 (setq elfeed-show-mode-map (make-sparse-keymap))
256 (define-key elfeed-show-mode-map (kbd "u") 'elfeed)
257 (define-key elfeed-show-mode-map (kbd "TAB") 'shr-next-link)
258 (define-key elfeed-show-mode-map (kbd "<backtab>") 'shr-previous-link)
259 (define-key elfeed-show-mode-map (kbd "a") 'elfeed-show-prev)
260 (define-key elfeed-show-mode-map (kbd "d") 'elfeed-show-next)
261 (define-key elfeed-show-mode-map (kbd "y") 'shr-copy-url)
262 (define-key elfeed-show-mode-map (kbd "RET") 'shr-browse-url)
263
264 ;; eww
265 ;; ===
266
267 (setq eww-mode-map (make-sparse-keymap))
268 (define-key eww-mode-map (kbd "TAB") 'shr-next-link)
269 (define-key eww-mode-map (kbd "<backtab>") 'shr-previous-link)
270 (define-key eww-mode-map (kbd "H") 'eww-back-url)
271 (define-key eww-mode-map (kbd "L") 'eww-forward-url)
272
273 ;; ledger
274 ;; ======
275 (setq ledger-mode-map (make-sparse-keymap))
276 (define-key ledger-mode-map (kbd "TAB") 'ledger-magic-tab)
277
278
279 ;; unset other maps so they don't disturb C-c keybinding
280 ;; =====================================================
281 ;; TODO: saner solution would be a default-activated minor mode that binds
282 ;; C-c
283 (setq conf-mode-map (make-sparse-keymap))
284 (setq sh-mode-map (make-sparse-keymap))
285 (setq python-mode-map (make-sparse-keymap))