Commit | Line | Data |
---|---|---|
49e9503b | 1 | ;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t -*- |
41d290a2 AB |
2 | |
3 | ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org> | |
4 | ||
5 | ;; This program is free software: you can redistribute it and/or modify | |
6 | ;; it under the terms of the GNU General Public License as published by | |
7 | ;; the Free Software Foundation, either version 3 of the License, or | |
8 | ;; (at your option) any later version. | |
9 | ||
10 | ;; This program is distributed in the hope that it will be useful, | |
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;; GNU General Public License for more details. | |
14 | ||
15 | ;; You should have received a copy of the GNU General Public License | |
16 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | |
17 | ||
18 | ;;; Commentary: | |
19 | ||
20 | ;; Emacs configuration of Amin Bandali, computer scientist, functional | |
b57457b2 AB |
21 | ;; programmer, and free software advocate. Uses straight.el for |
22 | ;; purely functional and fully reproducible package management. | |
23 | ||
24 | ;; Over the years, I've taken inspiration from configurations of many | |
25 | ;; great people. Some that I can remember off the top of my head are: | |
26 | ;; | |
27 | ;; - https://github.com/dieggsy/dotfiles | |
28 | ;; - https://github.com/dakra/dmacs | |
29 | ;; - http://pages.sachachua.com/.emacs.d/Sacha.html | |
30 | ;; - https://github.com/dakrone/eos | |
31 | ;; - http://doc.rix.si/cce/cce.html | |
32 | ;; - https://github.com/jwiegley/dot-emacs | |
33 | ;; - https://github.com/wasamasa/dotemacs | |
34 | ;; - https://github.com/hlissner/doom-emacs | |
41d290a2 | 35 | |
49e9503b AB |
36 | ;;; Code: |
37 | ||
b57457b2 AB |
38 | ;;; Emacs initialization |
39 | ||
41d290a2 AB |
40 | (defvar a/before-user-init-time (current-time) |
41 | "Value of `current-time' when Emacs begins loading `user-init-file'.") | |
42 | (message "Loading Emacs...done (%.3fs)" | |
43 | (float-time (time-subtract a/before-user-init-time | |
44 | before-init-time))) | |
45 | ||
b57457b2 AB |
46 | ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage' |
47 | ;; during startup to reduce garbage collection frequency. clearing | |
48 | ;; `file-name-handler-alist' seems to help reduce startup time too. | |
41d290a2 AB |
49 | (defvar a/gc-cons-threshold gc-cons-threshold) |
50 | (defvar a/gc-cons-percentage gc-cons-percentage) | |
51 | (defvar a/file-name-handler-alist file-name-handler-alist) | |
52 | (setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB | |
53 | gc-cons-percentage 0.6 | |
54 | file-name-handler-alist nil | |
55 | ;; sidesteps a bug when profiling with esup | |
56 | esup-child-profile-require-level 0) | |
57 | ||
b57457b2 | 58 | ;; set them back to their defaults once we're done initializing |
41d290a2 AB |
59 | (add-hook |
60 | 'after-init-hook | |
61 | (lambda () | |
62 | (setq gc-cons-threshold a/gc-cons-threshold | |
63 | gc-cons-percentage a/gc-cons-percentage | |
64 | file-name-handler-alist a/file-name-handler-alist))) | |
65 | ||
b57457b2 | 66 | ;; increase number of lines kept in *Messages* log |
41d290a2 AB |
67 | (setq message-log-max 20000) |
68 | ||
b57457b2 AB |
69 | ;; optionally, uncomment to supress some byte-compiler warnings |
70 | ;; (see C-h v byte-compile-warnings RET for more info) | |
41d290a2 AB |
71 | ;; (setq byte-compile-warnings |
72 | ;; '(not free-vars unresolved noruntime lexical make-local)) | |
73 | ||
b57457b2 AB |
74 | \f |
75 | ;;; whoami | |
76 | ||
41d290a2 AB |
77 | (setq user-full-name "Amin Bandali" |
78 | user-mail-address "amin@bndl.org") | |
79 | ||
b57457b2 AB |
80 | \f |
81 | ;;; comment macro | |
82 | ||
83 | ;; useful for commenting out multiple sexps at a time | |
84 | (defmacro comment (&rest _) | |
85 | "Comment out one or more s-expressions." | |
86 | (declare (indent defun)) | |
87 | nil) | |
88 | ||
89 | \f | |
90 | ;;; Package management | |
91 | ||
92 | ;; No package.el (for emacs 26 and before, uncomment the following) | |
93 | ;; Not necessary when using straight.el | |
94 | ;; (C-h v straight-package-neutering-mode RET) | |
95 | ||
16842394 AB |
96 | (when (and |
97 | (not (featurep 'straight)) | |
98 | (version< emacs-version "27")) | |
b57457b2 AB |
99 | (setq package-enable-at-startup nil) |
100 | ;; (package-initialize) | |
101 | ) | |
102 | ||
103 | ;; for emacs 27 and later, we use early-init.el. see | |
104 | ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b | |
105 | ||
106 | ;; straight.el | |
107 | ||
41d290a2 AB |
108 | ;; Main engine start... |
109 | ||
110 | (setq straight-repository-branch "develop" | |
111 | straight-check-for-modifications '(check-on-save find-when-checking)) | |
112 | ||
113 | (defun a/bootstrap-straight () | |
114 | (defvar bootstrap-version) | |
115 | (let ((bootstrap-file | |
116 | (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
117 | (bootstrap-version 5)) | |
118 | (unless (file-exists-p bootstrap-file) | |
119 | (with-current-buffer | |
120 | (url-retrieve-synchronously | |
121 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
122 | 'silent 'inhibit-cookies) | |
123 | (goto-char (point-max)) | |
124 | (eval-print-last-sexp))) | |
125 | (load bootstrap-file nil 'nomessage))) | |
126 | ||
127 | ;; Solid rocket booster ignition... | |
128 | ||
41d290a2 AB |
129 | (a/bootstrap-straight) |
130 | ||
131 | ;; We have lift off! | |
132 | ||
133 | (setq straight-use-package-by-default t) | |
134 | ||
135 | (defmacro use-feature (name &rest args) | |
136 | "Like `use-package', but with `straight-use-package-by-default' disabled." | |
137 | (declare (indent defun)) | |
138 | `(use-package ,name | |
139 | :straight nil | |
140 | ,@args)) | |
141 | ||
142 | (with-eval-after-load 'recentf | |
143 | (add-to-list 'recentf-exclude | |
144 | (expand-file-name "~/.emacs.d/straight/build/"))) | |
145 | ||
146 | (defun a/reload-init () | |
147 | "Reload init.el." | |
148 | (interactive) | |
149 | (straight-transaction | |
150 | (straight-mark-transaction-as-init) | |
29ea9439 | 151 | (load user-init-file))) |
41d290a2 | 152 | |
b57457b2 | 153 | ;; use-package |
41d290a2 AB |
154 | (straight-use-package 'use-package) |
155 | (if nil ; set to t when need to debug init | |
156 | (progn | |
157 | (setq use-package-verbose t | |
158 | use-package-expand-minimally nil | |
159 | use-package-compute-statistics t | |
160 | debug-on-error t) | |
161 | (require 'use-package)) | |
162 | (setq use-package-verbose nil | |
163 | use-package-expand-minimally t)) | |
164 | ||
165 | (setq use-package-always-defer t) | |
166 | (require 'bind-key) | |
167 | ||
b57457b2 AB |
168 | ;; for browsing the Emacsmirror package database |
169 | (comment | |
170 | (use-package epkg | |
171 | :commands (epkg-list-packages epkg-describe-package) | |
172 | :bind | |
173 | (("C-c p e d" . epkg-describe-package) | |
174 | ("C-c p e p" . epkg-list-packages)) | |
175 | :config | |
176 | (setq epkg-repository "~/.emacs.d/straight/repos/epkgs/") | |
177 | (eval-when-compile (defvar ivy-initial-inputs-alist)) | |
178 | (with-eval-after-load 'ivy | |
179 | (add-to-list | |
180 | 'ivy-initial-inputs-alist '(epkg-describe-package . "^") t)))) | |
181 | ||
182 | \f | |
183 | ;;; Initial setup | |
184 | ||
185 | ;; keep ~/.emacs.d clean | |
41d290a2 AB |
186 | (use-package no-littering |
187 | :demand t | |
188 | :config | |
189 | (savehist-mode 1) | |
190 | (add-to-list 'savehist-additional-variables 'kill-ring) | |
191 | (save-place-mode 1) | |
192 | (setq auto-save-file-name-transforms | |
193 | `((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))) | |
194 | ||
b57457b2 | 195 | ;; separate custom file (don't want it mixing with init.el) |
41d290a2 AB |
196 | (use-feature custom |
197 | :no-require t | |
198 | :config | |
199 | (setq custom-file (no-littering-expand-etc-file-name "custom.el")) | |
200 | (when (file-exists-p custom-file) | |
201 | (load custom-file)) | |
b57457b2 | 202 | ;; while at it, treat themes as safe |
41d290a2 AB |
203 | (setf custom-safe-themes t)) |
204 | ||
b57457b2 | 205 | ;; load the secrets file if it exists, otherwise show a warning |
41d290a2 AB |
206 | (with-demoted-errors |
207 | (load (no-littering-expand-etc-file-name "secrets"))) | |
208 | ||
b57457b2 | 209 | ;; better $PATH (and other environment variable) handling |
41d290a2 AB |
210 | (use-package exec-path-from-shell |
211 | :defer 0.4 | |
212 | :init | |
213 | (setq exec-path-from-shell-arguments nil | |
214 | exec-path-from-shell-check-startup-files nil) | |
215 | :config | |
216 | (exec-path-from-shell-initialize) | |
217 | ;; while we're at it, let's fix access to our running ssh-agent | |
218 | (exec-path-from-shell-copy-env "SSH_AGENT_PID") | |
219 | (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")) | |
220 | ||
b57457b2 AB |
221 | ;; only one custom theme at a time |
222 | (comment | |
223 | (defadvice load-theme (before clear-previous-themes activate) | |
224 | "Clear existing theme settings instead of layering them" | |
225 | (mapc #'disable-theme custom-enabled-themes))) | |
226 | ||
227 | ;; start up emacs server. see | |
228 | ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server | |
41d290a2 AB |
229 | (use-feature server |
230 | :defer 0.4 | |
231 | :config (or (server-running-p) (server-mode))) | |
232 | ||
b57457b2 AB |
233 | ;; unicode support |
234 | (comment | |
235 | (dolist (ft (fontset-list)) | |
236 | (set-fontset-font | |
237 | ft | |
238 | 'unicode | |
239 | (font-spec :name "Source Code Pro" :size 14)) | |
240 | (set-fontset-font | |
241 | ft | |
242 | 'unicode | |
243 | (font-spec :name "DejaVu Sans Mono") | |
244 | nil | |
245 | 'append) | |
246 | ;; (set-fontset-font | |
247 | ;; ft | |
248 | ;; 'unicode | |
249 | ;; (font-spec | |
250 | ;; :name "Symbola monospacified for DejaVu Sans Mono") | |
251 | ;; nil | |
252 | ;; 'append) | |
253 | ;; (set-fontset-font | |
254 | ;; ft | |
255 | ;; #x2115 ; ℕ | |
256 | ;; (font-spec :name "DejaVu Sans Mono") | |
257 | ;; nil | |
258 | ;; 'append) | |
259 | (set-fontset-font | |
260 | ft | |
261 | (cons ?Α ?ω) | |
262 | (font-spec :name "DejaVu Sans Mono" :size 14) | |
263 | nil | |
264 | 'prepend))) | |
265 | ||
266 | ;; gentler font resizing | |
41d290a2 AB |
267 | (setq text-scale-mode-step 1.05) |
268 | ||
b57457b2 | 269 | ;; focus follows mouse |
41d290a2 AB |
270 | (setq mouse-autoselect-window t) |
271 | ||
272 | (defun a/no-mouse-autoselect-window () | |
b57457b2 AB |
273 | "Conveniently disable `focus-follows-mouse'. |
274 | For disabling the behaviour for certain buffers and/or modes." | |
41d290a2 AB |
275 | (make-local-variable 'mouse-autoselect-window) |
276 | (setq mouse-autoselect-window nil)) | |
277 | ||
b57457b2 | 278 | ;; better scrolling |
41d290a2 AB |
279 | (setq ;; scroll-margin 1 |
280 | ;; scroll-conservatively 10000 | |
281 | scroll-step 1 | |
282 | scroll-conservatively 10 | |
283 | scroll-preserve-screen-position 1) | |
284 | ||
285 | (use-feature mwheel | |
286 | :defer 0.4 | |
287 | :config | |
288 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time | |
289 | mouse-wheel-progressive-speed nil ; don't accelerate scrolling | |
290 | mouse-wheel-follow-mouse t)) ; scroll window under mouse | |
291 | ||
292 | (use-feature pixel-scroll | |
293 | :defer 0.4 | |
294 | :config (pixel-scroll-mode 1)) | |
295 | ||
b57457b2 | 296 | ;; ask for GPG passphrase in minibuffer |
41d290a2 AB |
297 | (setq epg-pinentry-mode 'loopback) |
298 | ||
b57457b2 | 299 | ;; useful libraries |
41d290a2 AB |
300 | (require 'cl-lib) |
301 | (require 'subr-x) | |
302 | ||
b57457b2 AB |
303 | \f |
304 | ;;; Useful utilities | |
305 | ||
41d290a2 AB |
306 | (defmacro a/setq-every (value &rest vars) |
307 | "Set all the variables from VARS to value VALUE." | |
308 | (declare (indent defun) (debug t)) | |
309 | `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars))) | |
310 | ||
311 | (defun a/start-process (program &rest args) | |
312 | "Same as `start-process', but doesn't bother about name and buffer." | |
313 | (let ((process-name (concat program "_process")) | |
314 | (buffer-name (generate-new-buffer-name | |
315 | (concat program "_output")))) | |
316 | (apply #'start-process | |
317 | process-name buffer-name program args))) | |
318 | ||
319 | (defun a/dired-start-process (program &optional args) | |
320 | "Open current file with a PROGRAM." | |
321 | ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can | |
322 | ;; be nil, so remove it). | |
323 | (apply #'a/start-process | |
324 | program | |
325 | (remove nil (list args (dired-get-file-for-visit))))) | |
326 | ||
b57457b2 AB |
327 | (defun a/add-elisp-section () |
328 | (interactive) | |
329 | (insert "\n") | |
330 | (previous-line) | |
331 | (insert "\n\f\n;;; ")) | |
332 | ||
333 | \f | |
334 | ;;; Defaults | |
335 | ||
336 | ;; time and battery in mode-line | |
337 | (comment | |
338 | (use-package time | |
339 | :init | |
340 | (setq display-time-default-load-average nil) | |
341 | :config | |
342 | (display-time-mode)) | |
343 | ||
344 | (use-package battery | |
345 | :config | |
346 | (display-battery-mode))) | |
347 | ||
348 | ;; smaller fringe | |
41d290a2 AB |
349 | ;; (fringe-mode '(3 . 1)) |
350 | (fringe-mode nil) | |
351 | ||
b57457b2 | 352 | ;; disable disabled commands |
41d290a2 AB |
353 | (setq disabled-command-function nil) |
354 | ||
b57457b2 AB |
355 | ;; Save what I copy into clipboard from other applications into Emacs' |
356 | ;; kill-ring, which would allow me to still be able to easily access | |
357 | ;; it in case I kill (cut or copy) something else inside Emacs before | |
358 | ;; yanking (pasting) what I'd originally intended to. | |
41d290a2 AB |
359 | (setq save-interprogram-paste-before-kill t) |
360 | ||
b57457b2 | 361 | ;; minibuffer |
41d290a2 AB |
362 | (setq enable-recursive-minibuffers t |
363 | resize-mini-windows t) | |
364 | ||
b57457b2 | 365 | ;; lazy-person-friendly yes/no prompts |
41d290a2 AB |
366 | (defalias 'yes-or-no-p #'y-or-n-p) |
367 | ||
b57457b2 | 368 | ;; i want *scratch* as my startup buffer |
41d290a2 AB |
369 | (setq initial-buffer-choice t) |
370 | ||
b57457b2 | 371 | ;; i don't need the default hint |
41d290a2 AB |
372 | (setq initial-scratch-message nil) |
373 | ||
b57457b2 | 374 | ;; use customizable text-mode as major mode for *scratch* |
41d290a2 AB |
375 | (setq initial-major-mode 'text-mode) |
376 | ||
b57457b2 | 377 | ;; inhibit buffer list when more than 2 files are loaded |
41d290a2 AB |
378 | (setq inhibit-startup-buffer-menu t) |
379 | ||
b57457b2 | 380 | ;; don't need to see the startup screen or the echo area message |
41d290a2 AB |
381 | (advice-add #'display-startup-echo-area-message :override #'ignore) |
382 | (setq inhibit-startup-screen t | |
383 | inhibit-startup-echo-area-message user-login-name) | |
384 | ||
b57457b2 | 385 | ;; more useful frame titles |
41d290a2 AB |
386 | (setq frame-title-format |
387 | '("" invocation-name " - " | |
388 | (:eval (if (buffer-file-name) | |
389 | (abbreviate-file-name (buffer-file-name)) | |
390 | "%b")))) | |
391 | ||
b57457b2 | 392 | ;; backups (C-h v make-backup-files RET) |
41d290a2 AB |
393 | (setq backup-by-copying t |
394 | version-control t | |
395 | delete-old-versions t) | |
396 | ||
b57457b2 | 397 | ;; enable automatic reloading of changed buffers and files |
41d290a2 AB |
398 | (global-auto-revert-mode 1) |
399 | (setq auto-revert-verbose nil | |
400 | global-auto-revert-non-file-buffers nil) | |
401 | ||
b57457b2 | 402 | ;; always use space for indentation |
41d290a2 AB |
403 | (setq-default |
404 | indent-tabs-mode nil | |
405 | require-final-newline t | |
406 | tab-width 4) | |
407 | ||
b57457b2 | 408 | ;; enable winner-mode (C-h f winner-mode RET) |
41d290a2 AB |
409 | (winner-mode 1) |
410 | ||
b57457b2 AB |
411 | ;; don't display *compilation* buffer on success. based on |
412 | ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf' | |
413 | ;; instead of the now obsolete `flet'. | |
41d290a2 AB |
414 | (with-eval-after-load 'compile |
415 | (defun a/compilation-finish-function (buffer outstr) | |
416 | (unless (string-match "finished" outstr) | |
417 | (switch-to-buffer-other-window buffer)) | |
418 | t) | |
419 | ||
420 | (setq compilation-finish-functions #'a/compilation-finish-function) | |
421 | ||
422 | (require 'cl-macs) | |
423 | ||
424 | (defadvice compilation-start | |
425 | (around inhibit-display | |
426 | (command &optional mode name-function highlight-regexp)) | |
427 | (if (not (string-match "^\\(find\\|grep\\)" command)) | |
428 | (cl-letf (((symbol-function 'display-buffer) #'ignore)) | |
429 | (save-window-excursion ad-do-it)) | |
430 | ad-do-it)) | |
431 | (ad-activate 'compilation-start)) | |
432 | ||
b57457b2 AB |
433 | ;; search for non-ASCII characters: i’d like non-ASCII characters such |
434 | ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII | |
435 | ;; counterpart. shoutout to | |
436 | ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html | |
41d290a2 | 437 | (setq search-default-mode #'char-fold-to-regexp) |
41d290a2 AB |
438 | ;; uncomment to extend this behaviour to query-replace |
439 | ;; (setq replace-char-fold t) | |
440 | ||
b57457b2 | 441 | ;; cursor shape |
41d290a2 AB |
442 | (setq-default cursor-type 'bar) |
443 | ||
b57457b2 | 444 | ;; allow scrolling in Isearch |
41d290a2 AB |
445 | (setq isearch-allow-scroll t) |
446 | ||
b1a5d811 AB |
447 | (use-feature vc |
448 | :bind ("C-x v C-=" . vc-ediff)) | |
449 | ||
450 | (use-feature ediff | |
451 | :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo) | |
452 | :custom ((ediff-window-setup-function 'ediff-setup-windows-plain) | |
453 | (ediff-split-window-function 'split-window-horizontally))) | |
454 | ||
b57457b2 AB |
455 | \f |
456 | ;;; General bindings | |
457 | ||
41d290a2 AB |
458 | (bind-keys |
459 | ("C-c a i" . ielm) | |
460 | ||
461 | ("C-c e b" . eval-buffer) | |
462 | ("C-c e r" . eval-region) | |
463 | ||
464 | ("C-c e i" . emacs-init-time) | |
465 | ("C-c e u" . emacs-uptime) | |
466 | ||
467 | ("C-c F m" . make-frame-command) | |
468 | ("C-c F d" . delete-frame) | |
435306f6 | 469 | ("C-c F D" . server-edit) |
41d290a2 AB |
470 | |
471 | ("C-c o" . other-window) | |
472 | ||
473 | ("C-S-h C" . describe-char) | |
474 | ("C-S-h F" . describe-face) | |
475 | ||
476 | ("C-x k" . kill-this-buffer) | |
477 | ("C-x K" . kill-buffer) | |
478 | ||
479 | ("s-p" . beginning-of-buffer) | |
b57457b2 AB |
480 | ("s-n" . end-of-buffer) |
481 | ||
482 | :map emacs-lisp-mode-map | |
483 | ("<C-return>" . a/add-elisp-section)) | |
41d290a2 AB |
484 | |
485 | (when (display-graphic-p) | |
486 | (unbind-key "C-z" global-map)) | |
487 | ||
488 | (bind-keys | |
489 | :prefix-map a/straight-prefix-map | |
490 | :prefix "C-c p s" | |
491 | ("u" . straight-use-package) | |
492 | ("f" . straight-freeze-versions) | |
493 | ("t" . straight-thaw-versions) | |
494 | ("P" . straight-prune-build) | |
495 | ("g" . straight-get-recipe) | |
496 | ("r" . a/reload-init) | |
497 | ;; M-x ^straight-.*-all$ | |
498 | ("a c" . straight-check-all) | |
499 | ("a f" . straight-fetch-all) | |
500 | ("a m" . straight-merge-all) | |
501 | ("a n" . straight-normalize-all) | |
502 | ("a F" . straight-pull-all) | |
503 | ("a P" . straight-push-all) | |
504 | ("a r" . straight-rebuild-all) | |
505 | ;; M-x ^straight-.*-package$ | |
506 | ("p c" . straight-check-package) | |
507 | ("p f" . straight-fetch-package) | |
508 | ("p m" . straight-merge-package) | |
509 | ("p n" . straight-normalize-package) | |
510 | ("p F" . straight-pull-package) | |
511 | ("p P" . straight-push-package) | |
512 | ("p r" . straight-rebuild-package)) | |
513 | ||
b57457b2 AB |
514 | \f |
515 | ;;; Essential packages | |
516 | ||
41d290a2 AB |
517 | (use-package auto-compile |
518 | :demand t | |
519 | :config | |
520 | (auto-compile-on-load-mode) | |
521 | (auto-compile-on-save-mode) | |
522 | (setq auto-compile-display-buffer nil | |
523 | auto-compile-mode-line-counter t | |
524 | auto-compile-source-recreate-deletes-dest t | |
525 | auto-compile-toggle-deletes-nonlib-dest t | |
526 | auto-compile-update-autoloads t) | |
527 | (add-hook 'auto-compile-inhibit-compile-hook | |
528 | 'auto-compile-inhibit-compile-detached-git-head)) | |
529 | ||
b57457b2 | 530 | ;; use the org-plus-contrib package to get the whole deal |
41d290a2 AB |
531 | (straight-use-package 'org-plus-contrib) |
532 | ||
533 | (use-feature org | |
534 | :defer 0.5 | |
535 | :config | |
536 | (setq org-src-tab-acts-natively t | |
537 | org-src-preserve-indentation nil | |
538 | org-edit-src-content-indentation 0 | |
539 | org-link-email-description-format "Email %c: %s" ; %.30s | |
540 | org-highlight-latex-and-related '(entities) | |
541 | org-use-speed-commands t | |
542 | org-startup-folded 'content | |
543 | org-catch-invisible-edits 'show-and-error | |
544 | org-log-done 'time) | |
545 | (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t) | |
546 | :bind | |
547 | (("C-c a o a" . org-agenda) | |
548 | :map org-mode-map | |
549 | ("M-L" . org-insert-last-stored-link) | |
550 | ("s-T" . org-todo)) | |
551 | :hook ((org-mode . org-indent-mode) | |
552 | (org-mode . auto-fill-mode) | |
553 | (org-mode . flyspell-mode)) | |
554 | :custom | |
555 | (org-agenda-files '("~/usr/org/todos/personal.org" | |
556 | "~/usr/org/todos/masters.org")) | |
557 | (org-agenda-start-on-weekday 0) | |
558 | (org-latex-packages-alist '(("" "listings") ("" "color"))) | |
559 | :custom-face | |
560 | '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21")))) | |
561 | '(org-block ((t (:background "#1d1f21")))) | |
562 | '(org-latex-and-related ((t (:foreground "#b294bb"))))) | |
563 | ||
564 | (use-feature ox-latex | |
565 | :after ox | |
566 | :config | |
567 | (setq org-latex-listings 'listings | |
568 | ;; org-latex-prefer-user-labels t | |
569 | ) | |
570 | (add-to-list 'org-latex-classes | |
571 | '("IEEEtran" "\\documentclass[11pt]{IEEEtran}" | |
572 | ("\\section{%s}" . "\\section*{%s}") | |
573 | ("\\subsection{%s}" . "\\subsection*{%s}") | |
574 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
575 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | |
576 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | |
577 | t) | |
578 | (require 'ox-beamer)) | |
579 | ||
580 | (use-feature ox-extra | |
581 | :config | |
582 | (ox-extras-activate '(latex-header-blocks ignore-headlines))) | |
583 | ||
b57457b2 AB |
584 | ;; asynchronous tangle, using emacs-async to asynchronously tangle an |
585 | ;; org file. closely inspired by | |
586 | ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles | |
41d290a2 AB |
587 | (with-eval-after-load 'org |
588 | (defvar a/show-async-tangle-results nil | |
589 | "Keep *emacs* async buffers around for later inspection.") | |
590 | ||
591 | (defvar a/show-async-tangle-time nil | |
592 | "Show the time spent tangling the file.") | |
593 | ||
41d290a2 AB |
594 | (defun a/async-babel-tangle () |
595 | "Tangle org file asynchronously." | |
596 | (interactive) | |
597 | (let* ((file-tangle-start-time (current-time)) | |
598 | (file (buffer-file-name)) | |
599 | (file-nodir (file-name-nondirectory file)) | |
600 | ;; (async-quiet-switch "-q") | |
601 | (file-noext (file-name-sans-extension file))) | |
602 | (async-start | |
603 | `(lambda () | |
604 | (require 'org) | |
605 | (org-babel-tangle-file ,file)) | |
606 | (unless a/show-async-tangle-results | |
607 | `(lambda (result) | |
608 | (if result | |
29ea9439 AB |
609 | (message "Tangled %s%s" |
610 | ,file-nodir | |
611 | (if a/show-async-tangle-time | |
612 | (format " (%.3fs)" | |
613 | (float-time (time-subtract (current-time) | |
614 | ',file-tangle-start-time))) | |
615 | "")) | |
41d290a2 AB |
616 | (message "Tangling %s failed" ,file-nodir)))))))) |
617 | ||
618 | (add-to-list | |
619 | 'safe-local-variable-values | |
620 | '(eval add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local)) | |
621 | ||
b57457b2 | 622 | ;; *the* right way to do git |
41d290a2 AB |
623 | (use-package magit |
624 | :defer 0.5 | |
625 | :bind (("C-x g" . magit-status) | |
626 | ("s-g s" . magit-status) | |
627 | ("s-g l" . magit-log-buffer-file)) | |
628 | :config | |
629 | (magit-add-section-hook 'magit-status-sections-hook | |
630 | 'magit-insert-modules | |
631 | 'magit-insert-stashes | |
632 | 'append) | |
633 | (setq magit-repository-directories '(("~/" . 0) | |
634 | ("~/src/git/" . 1))) | |
635 | (nconc magit-section-initial-visibility-alist | |
636 | '(([unpulled status] . show) | |
637 | ([unpushed status] . show))) | |
afbbf23a | 638 | :custom (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1) |
41d290a2 AB |
639 | :custom-face (magit-diff-file-heading ((t (:weight normal))))) |
640 | ||
b57457b2 | 641 | ;; recently opened files |
41d290a2 AB |
642 | (use-feature recentf |
643 | :defer 0.2 | |
644 | :config | |
645 | (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:") | |
646 | (setq recentf-max-saved-items 40)) | |
647 | ||
b57457b2 | 648 | ;; smart M-x enhancement (needed by counsel for history) |
41d290a2 AB |
649 | (use-package smex) |
650 | ||
651 | (use-package ivy | |
652 | :defer 0.3 | |
653 | :bind | |
654 | (:map ivy-minibuffer-map | |
655 | ([escape] . keyboard-escape-quit) | |
656 | ([S-up] . ivy-previous-history-element) | |
657 | ([S-down] . ivy-next-history-element) | |
658 | ("DEL" . ivy-backward-delete-char)) | |
659 | :config | |
660 | (setq ivy-wrap t | |
661 | ivy-height 14 | |
662 | ivy-use-virtual-buffers t | |
663 | ivy-virtual-abbreviate 'abbreviate | |
664 | ivy-count-format "%d/%d ") | |
665 | (ivy-mode 1) | |
666 | ;; :custom-face | |
667 | ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold)))) | |
668 | ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold)))) | |
669 | ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold)))) | |
670 | ) | |
671 | ||
672 | (use-package swiper | |
673 | :after ivy | |
674 | :bind (("C-s" . swiper-isearch) | |
675 | ("C-r" . swiper) | |
676 | ("C-S-s" . isearch-forward))) | |
677 | ||
678 | (use-package counsel | |
679 | :after ivy | |
680 | :bind (([remap execute-extended-command] . counsel-M-x) | |
681 | ([remap find-file] . counsel-find-file) | |
682 | ("C-c x" . counsel-M-x) | |
683 | ("C-c f ." . counsel-find-file) | |
684 | ("C-c f l" . counsel-find-library) | |
2b53c994 AB |
685 | ("C-c f r" . counsel-recentf) |
686 | ("s-." . counsel-find-file) | |
687 | ("s-r" . ivy-switch-buffer) | |
41d290a2 AB |
688 | :map minibuffer-local-map |
689 | ("C-r" . counsel-minibuffer-history)) | |
690 | :config | |
691 | (counsel-mode 1) | |
692 | (defalias 'locate #'counsel-locate)) | |
693 | ||
b57457b2 AB |
694 | (comment |
695 | (use-package helm | |
696 | :commands (helm-M-x helm-mini helm-resume) | |
697 | :bind (("M-x" . helm-M-x) | |
698 | ("M-y" . helm-show-kill-ring) | |
699 | ("C-x b" . helm-mini) | |
700 | ("C-x C-b" . helm-buffers-list) | |
701 | ("C-x C-f" . helm-find-files) | |
702 | ("C-h r" . helm-info-emacs) | |
703 | ("s-r" . helm-recentf) | |
704 | ("C-s-r" . helm-resume) | |
705 | :map helm-map | |
706 | ("<tab>" . helm-execute-persistent-action) | |
707 | ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals | |
708 | ("C-z" . helm-select-action)) ; List actions | |
709 | :config (helm-mode 1))) | |
710 | ||
41d290a2 AB |
711 | (use-feature eshell |
712 | :defer 0.5 | |
713 | :commands eshell | |
714 | :bind ("C-c a s e" . eshell) | |
715 | :config | |
716 | (eval-when-compile (defvar eshell-prompt-regexp)) | |
717 | (defun a/eshell-quit-or-delete-char (arg) | |
718 | (interactive "p") | |
719 | (if (and (eolp) (looking-back eshell-prompt-regexp nil)) | |
720 | (eshell-life-is-too-much) | |
721 | (delete-char arg))) | |
722 | ||
723 | (defun a/eshell-clear () | |
724 | (interactive) | |
725 | (let ((inhibit-read-only t)) | |
726 | (erase-buffer)) | |
727 | (eshell-send-input)) | |
728 | ||
729 | (defun a/eshell-setup () | |
730 | (make-local-variable 'company-idle-delay) | |
731 | (defvar company-idle-delay) | |
732 | (setq company-idle-delay nil) | |
733 | (bind-keys :map eshell-mode-map | |
734 | ("C-d" . a/eshell-quit-or-delete-char) | |
735 | ("C-S-l" . a/eshell-clear) | |
736 | ("M-r" . counsel-esh-history) | |
737 | ([tab] . company-complete))) | |
738 | ||
739 | :hook (eshell-mode . a/eshell-setup) | |
740 | :custom | |
741 | (eshell-hist-ignoredups t) | |
742 | (eshell-input-filter 'eshell-input-filter-initial-space)) | |
743 | ||
744 | (use-feature ibuffer | |
745 | :bind | |
746 | (("C-x C-b" . ibuffer-other-window) | |
747 | :map ibuffer-mode-map | |
748 | ("P" . ibuffer-backward-filter-group) | |
749 | ("N" . ibuffer-forward-filter-group) | |
750 | ("M-p" . ibuffer-do-print) | |
751 | ("M-n" . ibuffer-do-shell-command-pipe-replace)) | |
752 | :config | |
753 | ;; Use human readable Size column instead of original one | |
754 | (define-ibuffer-column size-h | |
755 | (:name "Size" :inline t) | |
756 | (cond | |
757 | ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) | |
758 | ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0))) | |
759 | ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) | |
760 | (t (format "%8d" (buffer-size))))) | |
761 | :custom | |
762 | (ibuffer-saved-filter-groups | |
763 | '(("default" | |
764 | ("dired" (mode . dired-mode)) | |
765 | ("org" (mode . org-mode)) | |
766 | ("gnus" | |
767 | (or | |
768 | (mode . gnus-group-mode) | |
769 | (mode . gnus-summary-mode) | |
770 | (mode . gnus-article-mode) | |
771 | ;; not really, but... | |
772 | (mode . message-mode))) | |
773 | ("web" | |
774 | (or | |
775 | (mode . web-mode) | |
776 | (mode . css-mode) | |
777 | (mode . scss-mode) | |
778 | (mode . js2-mode))) | |
779 | ("shell" | |
780 | (or | |
781 | (mode . eshell-mode) | |
782 | (mode . shell-mode) | |
783 | (mode . term-mode))) | |
784 | ("programming" | |
785 | (or | |
786 | (mode . python-mode) | |
787 | (mode . c-mode) | |
788 | (mode . c++-mode) | |
789 | (mode . java-mode) | |
790 | (mode . emacs-lisp-mode) | |
791 | (mode . scheme-mode) | |
792 | (mode . haskell-mode) | |
793 | (mode . lean-mode) | |
794 | (mode . alloy-mode))) | |
795 | ("tex" | |
796 | (or | |
797 | (mode . bibtex-mode) | |
798 | (mode . latex-mode))) | |
799 | ("emacs" | |
800 | (or | |
801 | (name . "^\\*scratch\\*$") | |
802 | (name . "^\\*Messages\\*$"))) | |
803 | ("erc" (mode . erc-mode))))) | |
804 | (ibuffer-formats | |
805 | '((mark modified read-only locked " " | |
806 | (name 18 18 :left :elide) | |
807 | " " | |
808 | (size-h 9 -1 :right) | |
809 | " " | |
810 | (mode 16 16 :left :elide) | |
811 | " " filename-and-process) | |
812 | (mark " " | |
813 | (name 16 -1) | |
814 | " " filename))) | |
815 | :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default")))) | |
816 | ||
817 | (use-feature outline | |
818 | :hook (prog-mode . outline-minor-mode) | |
819 | :bind | |
820 | (:map | |
821 | outline-minor-mode-map | |
822 | ("<s-tab>" . outline-toggle-children) | |
823 | ("M-p" . outline-previous-visible-heading) | |
824 | ("M-n" . outline-next-visible-heading) | |
825 | :prefix-map a/outline-prefix-map | |
826 | :prefix "s-o" | |
827 | ("TAB" . outline-toggle-children) | |
828 | ("a" . outline-hide-body) | |
829 | ("H" . outline-hide-body) | |
830 | ("S" . outline-show-all) | |
831 | ("h" . outline-hide-subtree) | |
832 | ("s" . outline-show-subtree))) | |
833 | ||
834 | (use-feature ls-lisp | |
835 | :custom (ls-lisp-dirs-first t)) | |
836 | ||
837 | (use-feature dired | |
838 | :config | |
839 | (setq dired-listing-switches "-alh" | |
840 | ls-lisp-use-insert-directory-program nil) | |
841 | ||
842 | ;; easily diff 2 marked files | |
843 | ;; https://oremacs.com/2017/03/18/dired-ediff/ | |
844 | (defun dired-ediff-files () | |
845 | (interactive) | |
846 | (require 'dired-aux) | |
847 | (defvar ediff-after-quit-hook-internal) | |
848 | (let ((files (dired-get-marked-files)) | |
849 | (wnd (current-window-configuration))) | |
850 | (if (<= (length files) 2) | |
851 | (let ((file1 (car files)) | |
852 | (file2 (if (cdr files) | |
853 | (cadr files) | |
854 | (read-file-name | |
855 | "file: " | |
856 | (dired-dwim-target-directory))))) | |
857 | (if (file-newer-than-file-p file1 file2) | |
858 | (ediff-files file2 file1) | |
859 | (ediff-files file1 file2)) | |
860 | (add-hook 'ediff-after-quit-hook-internal | |
861 | (lambda () | |
862 | (setq ediff-after-quit-hook-internal nil) | |
863 | (set-window-configuration wnd)))) | |
864 | (error "no more than 2 files should be marked")))) | |
06ee5a00 AB |
865 | |
866 | (require 'dired-x) | |
867 | (setq dired-guess-shell-alist-user | |
868 | '(("\\.pdf\\'" "evince" "zathura" "okular") | |
869 | ("\\.doc\\'" "libreoffice") | |
870 | ("\\.docx\\'" "libreoffice") | |
871 | ("\\.ppt\\'" "libreoffice") | |
872 | ("\\.pptx\\'" "libreoffice") | |
873 | ("\\.xls\\'" "libreoffice") | |
874 | ("\\.xlsx\\'" "libreoffice") | |
875 | ("\\.flac\\'" "mpv"))) | |
41d290a2 AB |
876 | :bind (:map dired-mode-map |
877 | ("b" . dired-up-directory) | |
878 | ("e" . dired-ediff-files) | |
879 | ("E" . dired-toggle-read-only) | |
880 | ("\\" . dired-hide-details-mode) | |
881 | ("z" . (lambda () | |
882 | (interactive) | |
883 | (a/dired-start-process "zathura")))) | |
884 | :hook (dired-mode . dired-hide-details-mode)) | |
885 | ||
886 | (use-feature help | |
887 | :config | |
888 | (temp-buffer-resize-mode) | |
889 | (setq help-window-select t)) | |
890 | ||
891 | (use-feature tramp | |
892 | :config | |
893 | (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:")) | |
894 | (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) | |
895 | (add-to-list 'tramp-default-proxies-alist | |
896 | (list (regexp-quote (system-name)) nil nil))) | |
897 | ||
898 | (use-package dash | |
899 | :config (dash-enable-font-lock)) | |
900 | ||
901 | (use-package doc-view | |
902 | :bind (:map doc-view-mode-map | |
903 | ("M-RET" . image-previous-line))) | |
904 | ||
b57457b2 AB |
905 | \f |
906 | ;;; Editing | |
907 | ||
908 | ;; highlight uncommitted changes in the left fringe | |
41d290a2 | 909 | (use-package diff-hl |
df1c9bc8 | 910 | :defer 0.6 |
41d290a2 AB |
911 | :config |
912 | (setq diff-hl-draw-borders nil) | |
913 | (global-diff-hl-mode) | |
914 | :hook (magit-post-refresh . diff-hl-magit-post-refresh)) | |
915 | ||
b57457b2 | 916 | ;; display Lisp objects at point in the echo area |
41d290a2 AB |
917 | (use-feature eldoc |
918 | :when (version< "25" emacs-version) | |
919 | :config (global-eldoc-mode)) | |
920 | ||
b57457b2 | 921 | ;; highlight matching parens |
41d290a2 AB |
922 | (use-feature paren |
923 | :demand | |
924 | :config (show-paren-mode)) | |
925 | ||
926 | (use-feature simple | |
927 | :config (column-number-mode)) | |
928 | ||
b57457b2 | 929 | ;; save minibuffer history |
41d290a2 AB |
930 | (use-feature savehist |
931 | :config (savehist-mode)) | |
932 | ||
b57457b2 | 933 | ;; automatically save place in files |
41d290a2 AB |
934 | (use-feature saveplace |
935 | :when (version< "25" emacs-version) | |
936 | :config (save-place-mode)) | |
937 | ||
938 | (use-feature prog-mode | |
939 | :config (global-prettify-symbols-mode) | |
940 | (defun indicate-buffer-boundaries-left () | |
941 | (setq indicate-buffer-boundaries 'left)) | |
942 | (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)) | |
943 | ||
944 | (use-feature text-mode | |
945 | :hook ((text-mode . indicate-buffer-boundaries-left) | |
946 | (text-mode . abbrev-mode))) | |
947 | ||
948 | (use-package company | |
949 | :defer 0.6 | |
950 | :bind | |
951 | (:map company-active-map | |
952 | ([tab] . company-complete-common-or-cycle) | |
953 | ([escape] . company-abort)) | |
954 | :custom | |
955 | (company-minimum-prefix-length 1) | |
956 | (company-selection-wrap-around t) | |
957 | (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") | |
958 | (company-dabbrev-downcase nil) | |
959 | (company-dabbrev-ignore-case nil) | |
960 | :config | |
961 | (global-company-mode t)) | |
962 | ||
963 | (use-package flycheck | |
964 | :defer 0.6 | |
965 | :hook (prog-mode . flycheck-mode) | |
966 | :bind | |
967 | (:map flycheck-mode-map | |
968 | ("M-P" . flycheck-previous-error) | |
969 | ("M-N" . flycheck-next-error)) | |
970 | :config | |
971 | ;; Use the load-path from running Emacs when checking elisp files | |
972 | (setq flycheck-emacs-lisp-load-path 'inherit) | |
973 | ||
974 | ;; Only flycheck when I actually save the buffer | |
975 | (setq flycheck-check-syntax-automatically '(mode-enabled save))) | |
976 | ||
977 | ;; http://endlessparentheses.com/ispell-and-apostrophes.html | |
978 | (use-package ispell | |
979 | :defer 0.6 | |
980 | :config | |
981 | ;; ’ can be part of a word | |
982 | (setq ispell-local-dictionary-alist | |
983 | `((nil "[[:alpha:]]" "[^[:alpha:]]" | |
984 | "['\x2019]" nil ("-B") nil utf-8))) | |
985 | ;; don't send ’ to the subprocess | |
986 | (defun endless/replace-apostrophe (args) | |
987 | (cons (replace-regexp-in-string | |
988 | "’" "'" (car args)) | |
989 | (cdr args))) | |
990 | (advice-add #'ispell-send-string :filter-args | |
991 | #'endless/replace-apostrophe) | |
992 | ||
993 | ;; convert ' back to ’ from the subprocess | |
994 | (defun endless/replace-quote (args) | |
995 | (if (not (derived-mode-p 'org-mode)) | |
996 | args | |
997 | (cons (replace-regexp-in-string | |
998 | "'" "’" (car args)) | |
999 | (cdr args)))) | |
1000 | (advice-add #'ispell-parse-output :filter-args | |
1001 | #'endless/replace-quote)) | |
1002 | ||
b57457b2 AB |
1003 | \f |
1004 | ;;; Programming modes | |
1005 | ||
41d290a2 AB |
1006 | (use-feature lisp-mode |
1007 | :config | |
1008 | (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode) | |
1009 | (add-hook 'emacs-lisp-mode-hook 'reveal-mode) | |
1010 | (defun indent-spaces-mode () | |
1011 | (setq indent-tabs-mode nil)) | |
1012 | (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) | |
1013 | ||
1014 | (use-package alloy-mode | |
1015 | :straight (:host github :repo "dwwmmn/alloy-mode") | |
1016 | :mode "\\.als\\'" | |
1017 | :config (setq alloy-basic-offset 2)) | |
1018 | ||
b57457b2 | 1019 | (use-package proof-site ; for Coq |
41d290a2 AB |
1020 | :straight proof-general) |
1021 | ||
1022 | (eval-when-compile (defvar lean-mode-map)) | |
1023 | (use-package lean-mode | |
1024 | :defer 0.4 | |
1025 | :bind (:map lean-mode-map | |
1026 | ("S-SPC" . company-complete)) | |
1027 | :config | |
1028 | (require 'lean-input) | |
1029 | (setq default-input-method "Lean" | |
1030 | lean-input-tweak-all '(lean-input-compose | |
1031 | (lean-input-prepend "/") | |
1032 | (lean-input-nonempty)) | |
1033 | lean-input-user-translations '(("/" "/"))) | |
1034 | (lean-input-setup)) | |
1035 | ||
1036 | (use-package haskell-mode | |
1037 | :config | |
1038 | (setq haskell-indentation-layout-offset 4 | |
1039 | haskell-indentation-left-offset 4 | |
1040 | flycheck-checker 'haskell-hlint | |
1041 | flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc))) | |
1042 | ||
1043 | (use-package dante | |
1044 | :after haskell-mode | |
1045 | :commands dante-mode | |
1046 | :hook (haskell-mode . dante-mode)) | |
1047 | ||
1048 | (use-package hlint-refactor | |
1049 | :after haskell-mode | |
1050 | :bind (:map hlint-refactor-mode-map | |
1051 | ("C-c l b" . hlint-refactor-refactor-buffer) | |
1052 | ("C-c l r" . hlint-refactor-refactor-at-point)) | |
1053 | :hook (haskell-mode . hlint-refactor-mode)) | |
1054 | ||
1055 | (use-package flycheck-haskell | |
1056 | :after haskell-mode) | |
b57457b2 | 1057 | ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el |
41d290a2 AB |
1058 | |
1059 | (use-package sgml-mode | |
1060 | :config | |
1061 | (setq sgml-basic-offset 2)) | |
1062 | ||
1063 | (use-package css-mode | |
1064 | :config | |
1065 | (setq css-indent-offset 2)) | |
1066 | ||
1067 | (use-package web-mode | |
1068 | :mode "\\.html\\'" | |
1069 | :config | |
1070 | (a/setq-every 2 | |
1071 | web-mode-code-indent-offset | |
1072 | web-mode-css-indent-offset | |
1073 | web-mode-markup-indent-offset)) | |
1074 | ||
1075 | (use-package emmet-mode | |
1076 | :after (:any web-mode css-mode sgml-mode) | |
1077 | :bind* (("C-)" . emmet-next-edit-point) | |
1078 | ("C-(" . emmet-prev-edit-point)) | |
1079 | :config | |
1080 | (unbind-key "C-j" emmet-mode-keymap) | |
1081 | (setq emmet-move-cursor-between-quotes t) | |
1082 | :hook (web-mode css-mode html-mode sgml-mode)) | |
1083 | ||
b57457b2 AB |
1084 | (comment |
1085 | (use-package meghanada | |
1086 | :bind | |
1087 | (:map meghanada-mode-map | |
1088 | (("C-M-o" . meghanada-optimize-import) | |
1089 | ("C-M-t" . meghanada-import-all))) | |
1090 | :hook (java-mode . meghanada-mode))) | |
1091 | ||
1092 | (comment | |
1093 | (use-package treemacs | |
1094 | :config (setq treemacs-never-persist t)) | |
1095 | ||
1096 | (use-package yasnippet | |
1097 | :config | |
1098 | ;; (yas-global-mode) | |
1099 | ) | |
1100 | ||
1101 | (use-package lsp-mode | |
1102 | :init (setq lsp-eldoc-render-all nil | |
1103 | lsp-highlight-symbol-at-point nil) | |
1104 | ) | |
1105 | ||
1106 | (use-package hydra) | |
1107 | ||
1108 | (use-package company-lsp | |
1109 | :after company | |
1110 | :config | |
1111 | (setq company-lsp-cache-candidates t | |
1112 | company-lsp-async t)) | |
1113 | ||
1114 | (use-package lsp-ui | |
1115 | :config | |
1116 | (setq lsp-ui-sideline-update-mode 'point)) | |
1117 | ||
1118 | (use-package lsp-java | |
1119 | :config | |
1120 | (add-hook 'java-mode-hook | |
1121 | (lambda () | |
1122 | (setq-local company-backends (list 'company-lsp)))) | |
1123 | ||
1124 | (add-hook 'java-mode-hook 'lsp-java-enable) | |
1125 | (add-hook 'java-mode-hook 'flycheck-mode) | |
1126 | (add-hook 'java-mode-hook 'company-mode) | |
1127 | (add-hook 'java-mode-hook 'lsp-ui-mode)) | |
1128 | ||
1129 | (use-package dap-mode | |
1130 | :after lsp-mode | |
1131 | :config | |
1132 | (dap-mode t) | |
1133 | (dap-ui-mode t)) | |
1134 | ||
1135 | (use-package dap-java | |
1136 | :after (lsp-java)) | |
1137 | ||
1138 | (use-package lsp-java-treemacs | |
1139 | :after (treemacs))) | |
1140 | ||
1141 | (comment | |
1142 | (use-package eclim | |
1143 | :bind (:map eclim-mode-map ("S-SPC" . company-complete)) | |
1144 | :hook ((java-mode . eclim-mode) | |
1145 | (eclim-mode . (lambda () | |
1146 | (make-local-variable 'company-idle-delay) | |
1147 | (defvar company-idle-delay) | |
1148 | ;; (setq company-idle-delay 0.7) | |
1149 | (setq company-idle-delay nil)))) | |
1150 | :custom | |
1151 | (eclim-auto-save nil) | |
1152 | ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp") | |
1153 | (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim") | |
1154 | (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse")))) | |
1155 | ||
41d290a2 AB |
1156 | (use-package geiser) |
1157 | ||
1158 | (use-feature geiser-guile | |
1159 | :config | |
1160 | (setq geiser-guile-load-path "~/src/git/guix")) | |
1161 | ||
1162 | (use-package guix) | |
1163 | ||
b57457b2 AB |
1164 | (comment |
1165 | (use-package auctex | |
1166 | :custom | |
1167 | (font-latex-fontify-sectioning 'color))) | |
1168 | ||
1169 | \f | |
1170 | ;;; Theme | |
1171 | ||
1172 | (add-to-list 'custom-theme-load-path "~/.emacs.d/lisp") | |
1173 | (load-theme 'tangomod t) | |
1174 | ||
1175 | (use-package smart-mode-line | |
1176 | :commands (sml/apply-theme) | |
1177 | :demand | |
1178 | :config | |
1179 | (sml/setup)) | |
1180 | ||
1181 | (use-package doom-themes) | |
1182 | ||
1183 | (defvar a/org-mode-font-lock-keywords | |
1184 | '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)" | |
1185 | (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive | |
1186 | (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind | |
1187 | (4 '(:foreground "#c5c8c6") t)))) ; title | |
1188 | ||
1189 | (defun a/lights-on () | |
1190 | "Enable my favourite light theme." | |
1191 | (interactive) | |
1192 | (mapc #'disable-theme custom-enabled-themes) | |
1193 | (load-theme 'tangomod t) | |
1194 | (sml/apply-theme 'automatic) | |
1195 | (font-lock-remove-keywords | |
1196 | 'org-mode a/org-mode-font-lock-keywords)) | |
1197 | ||
1198 | (defun a/lights-off () | |
1199 | "Go dark." | |
1200 | (interactive) | |
1201 | (mapc #'disable-theme custom-enabled-themes) | |
1202 | (load-theme 'doom-tomorrow-night t) | |
1203 | (sml/apply-theme 'automatic) | |
1204 | (font-lock-add-keywords | |
1205 | 'org-mode a/org-mode-font-lock-keywords t)) | |
1206 | ||
1207 | (bind-keys | |
1208 | ("s-t d" . a/lights-off) | |
1209 | ("s-t l" . a/lights-on)) | |
1210 | ||
1211 | \f | |
1212 | ;;; Emacs enhancements & auxiliary packages | |
1213 | ||
41d290a2 AB |
1214 | (use-feature man |
1215 | :config (setq Man-width 80)) | |
1216 | ||
1217 | (use-package which-key | |
1218 | :defer 0.4 | |
1219 | :config | |
1220 | (which-key-add-key-based-replacements | |
1221 | ;; prefixes for global prefixes and minor modes | |
1222 | "C-c @" "outline" | |
1223 | "C-c !" "flycheck" | |
1224 | "C-c 8" "typo" | |
1225 | "C-c 8 -" "typo/dashes" | |
1226 | "C-c 8 <" "typo/left-brackets" | |
1227 | "C-c 8 >" "typo/right-brackets" | |
1228 | "C-x 8" "unicode" | |
1229 | "C-x a" "abbrev/expand" | |
1230 | "C-x r" "rectangle/register/bookmark" | |
1231 | "C-x v" "version control" | |
1232 | ;; prefixes for my personal bindings | |
1233 | "C-c a" "applications" | |
1234 | "C-c a e" "erc" | |
1235 | "C-c a o" "org" | |
1236 | "C-c a s" "shells" | |
1237 | "C-c p" "package-management" | |
1238 | ;; "C-c p e" "package-management/epkg" | |
1239 | "C-c p s" "straight.el" | |
1240 | "C-c psa" "all" | |
1241 | "C-c psp" "package" | |
1242 | "C-c c" "compile-and-comments" | |
1243 | "C-c e" "eval" | |
1244 | "C-c f" "files" | |
1245 | "C-c F" "frames" | |
1246 | "C-S-h" "help(ful)" | |
1247 | "C-c m" "multiple-cursors" | |
1248 | "C-c P" "projectile" | |
1249 | "C-c P s" "projectile/search" | |
1250 | "C-c P x" "projectile/execute" | |
1251 | "C-c P 4" "projectile/other-window" | |
1252 | "C-c q" "boxquote" | |
1253 | "s-g" "magit" | |
1254 | "s-o" "outline" | |
1255 | "s-t" "themes") | |
1256 | ||
1257 | ;; prefixes for major modes | |
1258 | (which-key-add-major-mode-key-based-replacements 'message-mode | |
1259 | "C-c f" "footnote") | |
1260 | (which-key-add-major-mode-key-based-replacements 'org-mode | |
1261 | "C-c C-v" "org-babel") | |
1262 | (which-key-add-major-mode-key-based-replacements 'web-mode | |
1263 | "C-c C-a" "web/attributes" | |
1264 | "C-c C-b" "web/blocks" | |
1265 | "C-c C-d" "web/dom" | |
1266 | "C-c C-e" "web/element" | |
1267 | "C-c C-t" "web/tags") | |
1268 | ||
1269 | (which-key-mode) | |
1270 | :custom | |
1271 | (which-key-add-column-padding 5) | |
1272 | (which-key-max-description-length 32)) | |
1273 | ||
b57457b2 | 1274 | (use-package crux ; results in Waiting for git... [2 times] |
41d290a2 AB |
1275 | :defer 0.4 |
1276 | :bind (("C-c b k" . crux-kill-other-buffers) | |
1277 | ("C-c d" . crux-duplicate-current-line-or-region) | |
1278 | ("C-c D" . crux-duplicate-and-comment-current-line-or-region) | |
1279 | ("C-c f c" . crux-copy-file-preserve-attributes) | |
1280 | ("C-c f d" . crux-delete-file-and-buffer) | |
1281 | ("C-c f r" . crux-rename-file-and-buffer) | |
1282 | ("C-c j" . crux-top-join-line) | |
1283 | ("C-S-j" . crux-top-join-line))) | |
1284 | ||
1285 | (use-package mwim | |
1286 | :bind (("C-a" . mwim-beginning-of-code-or-line) | |
1287 | ("C-e" . mwim-end-of-code-or-line) | |
1288 | ("<home>" . mwim-beginning-of-line-or-code) | |
1289 | ("<end>" . mwim-end-of-line-or-code))) | |
1290 | ||
1291 | (use-package projectile | |
1292 | :bind-keymap ("C-c P" . projectile-command-map) | |
1293 | :config | |
1294 | (projectile-mode) | |
1295 | ||
1296 | (defun my-projectile-invalidate-cache (&rest _args) | |
1297 | ;; ignore the args to `magit-checkout' | |
1298 | (projectile-invalidate-cache nil)) | |
1299 | ||
1300 | (eval-after-load 'magit-branch | |
1301 | '(progn | |
1302 | (advice-add 'magit-checkout | |
1303 | :after #'my-projectile-invalidate-cache) | |
1304 | (advice-add 'magit-branch-and-checkout | |
1305 | :after #'my-projectile-invalidate-cache))) | |
1306 | :custom (projectile-completion-system 'ivy)) | |
1307 | ||
1308 | (use-package helpful | |
1309 | :defer 0.6 | |
1310 | :bind | |
1311 | (("C-S-h c" . helpful-command) | |
1312 | ("C-S-h f" . helpful-callable) ; helpful-function | |
1313 | ("C-S-h v" . helpful-variable) | |
1314 | ("C-S-h k" . helpful-key) | |
1315 | ("C-S-h p" . helpful-at-point))) | |
1316 | ||
1317 | (use-package unkillable-scratch | |
1318 | :defer 0.6 | |
1319 | :config | |
1320 | (unkillable-scratch 1) | |
1321 | :custom | |
1322 | (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))) | |
1323 | ||
b57457b2 AB |
1324 | ;; ,---- |
1325 | ;; | make pretty boxed quotes like this | |
1326 | ;; `---- | |
41d290a2 AB |
1327 | (use-package boxquote |
1328 | :defer 0.6 | |
1329 | :bind | |
1330 | (:prefix-map a/boxquote-prefix-map | |
1331 | :prefix "C-c q" | |
1332 | ("b" . boxquote-buffer) | |
1333 | ("B" . boxquote-insert-buffer) | |
1334 | ("d" . boxquote-defun) | |
1335 | ("F" . boxquote-insert-file) | |
1336 | ("hf" . boxquote-describe-function) | |
1337 | ("hk" . boxquote-describe-key) | |
1338 | ("hv" . boxquote-describe-variable) | |
1339 | ("hw" . boxquote-where-is) | |
1340 | ("k" . boxquote-kill) | |
1341 | ("p" . boxquote-paragraph) | |
1342 | ("q" . boxquote-boxquote) | |
1343 | ("r" . boxquote-region) | |
1344 | ("s" . boxquote-shell-command) | |
1345 | ("t" . boxquote-text) | |
1346 | ("T" . boxquote-title) | |
1347 | ("u" . boxquote-unbox) | |
1348 | ("U" . boxquote-unbox-region) | |
1349 | ("y" . boxquote-yank) | |
1350 | ("M-q" . boxquote-fill-paragraph) | |
1351 | ("M-w" . boxquote-kill-ring-save))) | |
1352 | ||
1353 | (use-package orgalist | |
b57457b2 | 1354 | ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html |
41d290a2 AB |
1355 | :disabled t |
1356 | :after message | |
1357 | :hook (message-mode . orgalist-mode)) | |
1358 | ||
b57457b2 | 1359 | ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹› |
41d290a2 AB |
1360 | (use-package typo |
1361 | :defer 0.5 | |
1362 | :config | |
1363 | (typo-global-mode 1) | |
1364 | :hook (text-mode . typo-mode)) | |
1365 | ||
b57457b2 | 1366 | ;; highlight TODOs in buffers |
41d290a2 AB |
1367 | (use-package hl-todo |
1368 | :defer 0.5 | |
1369 | :config | |
1370 | (global-hl-todo-mode)) | |
1371 | ||
1372 | (use-package shrink-path | |
1373 | :defer 0.5 | |
1374 | :after eshell | |
1375 | :config | |
1376 | (defvar user-@-host (concat (user-login-name) "@" (system-name) " ")) | |
1377 | (defun +eshell/prompt () | |
1378 | (let ((base/dir (shrink-path-prompt default-directory))) | |
1379 | (concat (propertize user-@-host 'face 'default) | |
1380 | (propertize (car base/dir) | |
1381 | 'face 'font-lock-comment-face) | |
1382 | (propertize (cdr base/dir) | |
1383 | 'face 'font-lock-constant-face) | |
1384 | (propertize "> " 'face 'default)))) | |
1385 | (setq eshell-prompt-regexp (concat user-@-host ".*> ") | |
1386 | eshell-prompt-function #'+eshell/prompt)) | |
1387 | ||
1388 | (use-package eshell-up | |
1389 | :after eshell | |
1390 | :commands eshell-up) | |
1391 | ||
1392 | (use-package multi-term | |
1393 | :defer 0.6 | |
fb078e63 AB |
1394 | :bind (("C-c a s m m" . multi-term) |
1395 | ("C-c a s m d" . multi-term-dedicated-toggle) | |
1396 | ("C-c a s m p" . multi-term-prev) | |
1397 | ("C-c a s m n" . multi-term-next) | |
41d290a2 | 1398 | :map term-mode-map |
0af1e91a | 1399 | ("C-c C-j" . term-char-mode)) |
41d290a2 | 1400 | :config |
96c704d7 AB |
1401 | (setq multi-term-program "screen" |
1402 | multi-term-program-switches (concat "-c" | |
1403 | (getenv "XDG_CONFIG_HOME") | |
1404 | "/screen/screenrc") | |
41d290a2 AB |
1405 | ;; TODO: add separate bindings for connecting to existing |
1406 | ;; session vs. always creating a new one | |
1407 | multi-term-dedicated-select-after-open-p t | |
1408 | multi-term-dedicated-window-height 20 | |
1409 | multi-term-dedicated-max-window-height 30 | |
1410 | term-bind-key-alist | |
1411 | '(("C-c C-c" . term-interrupt-subjob) | |
1412 | ("C-c C-e" . term-send-esc) | |
0af1e91a | 1413 | ("C-c C-j" . term-line-mode) |
41d290a2 | 1414 | ("C-k" . kill-line) |
fb078e63 AB |
1415 | ;; ("C-y" . term-paste) |
1416 | ("C-y" . term-send-raw) | |
41d290a2 AB |
1417 | ("M-f" . term-send-forward-word) |
1418 | ("M-b" . term-send-backward-word) | |
1419 | ("M-p" . term-send-up) | |
1420 | ("M-n" . term-send-down) | |
fb078e63 AB |
1421 | ("M-j" . term-send-raw-meta) |
1422 | ("M-y" . term-send-raw-meta) | |
1423 | ("M-/" . term-send-raw-meta) | |
1424 | ("M-0" . term-send-raw-meta) | |
1425 | ("M-1" . term-send-raw-meta) | |
1426 | ("M-2" . term-send-raw-meta) | |
1427 | ("M-3" . term-send-raw-meta) | |
1428 | ("M-4" . term-send-raw-meta) | |
1429 | ("M-5" . term-send-raw-meta) | |
1430 | ("M-6" . term-send-raw-meta) | |
1431 | ("M-7" . term-send-raw-meta) | |
1432 | ("M-8" . term-send-raw-meta) | |
1433 | ("M-9" . term-send-raw-meta) | |
41d290a2 AB |
1434 | ("<C-backspace>" . term-send-backward-kill-word) |
1435 | ("<M-DEL>" . term-send-backward-kill-word) | |
1436 | ("M-d" . term-send-delete-word) | |
1437 | ("M-," . term-send-raw) | |
1438 | ("M-." . comint-dynamic-complete)) | |
1439 | term-unbind-key-alist | |
fb078e63 AB |
1440 | '("C-z" "C-x" "C-c" "C-h" |
1441 | ;; "C-y" | |
1442 | "<ESC>"))) | |
41d290a2 AB |
1443 | |
1444 | (use-package page-break-lines | |
b57457b2 | 1445 | :defer 0.5 |
41d290a2 AB |
1446 | :config |
1447 | (global-page-break-lines-mode)) | |
1448 | ||
1449 | (use-package expand-region | |
1450 | :bind ("C-=" . er/expand-region)) | |
1451 | ||
1452 | (use-package multiple-cursors | |
1453 | :bind | |
1454 | (("C-S-<mouse-1>" . mc/add-cursor-on-click) | |
1455 | (:prefix-map a/mc-prefix-map | |
1456 | :prefix "C-c m" | |
1457 | ("c" . mc/edit-lines) | |
1458 | ("n" . mc/mark-next-like-this) | |
1459 | ("p" . mc/mark-previous-like-this) | |
1460 | ("a" . mc/mark-all-like-this)))) | |
1461 | ||
1462 | (use-package forge | |
1463 | :after magit | |
1464 | :demand) | |
1465 | ||
1466 | (use-package yasnippet | |
1467 | :defer 0.6 | |
1468 | :config | |
1469 | (defconst yas-verbosity-cur yas-verbosity) | |
1470 | (setq yas-verbosity 2) | |
1471 | (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets") | |
1472 | (yas-reload-all) | |
1473 | (setq yas-verbosity yas-verbosity-cur) | |
1474 | :hook | |
1475 | (text-mode . yas-minor-mode)) | |
1476 | ||
1477 | (use-package debbugs | |
1478 | :straight (debbugs | |
1479 | :host github | |
1480 | :repo "emacs-straight/debbugs" | |
1481 | :files (:defaults "Debbugs.wsdl"))) | |
1482 | ||
1483 | (use-package org-ref | |
1484 | :init | |
1485 | (a/setq-every '("~/usr/org/references.bib") | |
1486 | reftex-default-bibliography | |
1487 | org-ref-default-bibliography) | |
1488 | (setq | |
1489 | org-ref-bibliography-notes "~/usr/org/notes.org" | |
1490 | org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")) | |
1491 | ||
b57457b2 | 1492 | ;; ugh, temporary (still better than using the proprietary web app) |
41d290a2 AB |
1493 | (use-package slack |
1494 | :commands (slack-start) | |
1495 | :init | |
1496 | (eval-when-compile ; silence the byte-compiler | |
1497 | (defvar url-http-data nil) | |
1498 | (defvar url-http-extra-headers nil) | |
1499 | (defvar url-http-method nil) | |
1500 | (defvar url-callback-function nil) | |
1501 | (defvar url-callback-arguments nil) | |
1502 | (defvar oauth--token-data nil)) | |
1503 | (setq slack-buffer-emojify t | |
1504 | slack-prefer-current-team t) | |
1505 | :config | |
1506 | (slack-register-team | |
1507 | :name "nday-students" | |
1508 | :default t | |
1509 | :token nday-students-token | |
1510 | :subscribed-channels '(general) | |
1511 | :full-and-display-names t) | |
1512 | (add-to-list 'swiper-font-lock-exclude 'slack-message-buffer-mode t) | |
1513 | (setq lui-time-stamp-format "[%Y-%m-%d %H:%M:%S]" | |
1514 | lui-time-stamp-only-when-changed-p t | |
1515 | lui-time-stamp-position 'right) | |
1516 | :bind | |
1517 | (("C-c s s" . slack-start) | |
1518 | ("C-c s u" . slack-select-unread-rooms) | |
1519 | ("C-c s b" . slack-select-rooms) | |
1520 | ("C-c s t" . slack-change-current-team) | |
1521 | ("C-c s c" . slack-ws-close) | |
1522 | :map slack-mode-map | |
1523 | ("M-p" . slack-buffer-goto-prev-message) | |
1524 | ("M-n" . slack-buffer-goto-next-message) | |
1525 | ("C-c e" . slack-message-edit) | |
1526 | ("C-c k" . slack-message-delete) | |
1527 | ("C-c C-k" . slack-channel-leave) | |
1528 | ("C-c r a" . slack-message-add-reaction) | |
1529 | ("C-c r r" . slack-message-remove-reaction) | |
1530 | ("C-c r s" . slack-message-show-reaction-users) | |
1531 | ("C-c p l" . slack-room-pins-list) | |
1532 | ("C-c p a" . slack-message-pins-add) | |
1533 | ("C-c p r" . slack-message-pins-remove) | |
1534 | ("@" . slack-message-embed-mention) | |
1535 | ("#" . slack-message-embed-channel))) | |
1536 | ||
1537 | (use-package alert | |
1538 | :commands (alert) | |
1539 | :init | |
1540 | (setq alert-default-style 'notifier)) | |
1541 | ||
c3fc07ff AB |
1542 | (use-package ivy-xref |
1543 | :init | |
1544 | (setq xref-show-xrefs-function #'ivy-xref-show-xrefs)) | |
1545 | ||
b57457b2 AB |
1546 | \f |
1547 | ;;; Email (with Gnus) | |
1548 | ||
41d290a2 AB |
1549 | (defvar a/maildir (expand-file-name "~/mail/")) |
1550 | (with-eval-after-load 'recentf | |
1551 | (add-to-list 'recentf-exclude a/maildir)) | |
1552 | ||
1553 | (setq | |
1554 | a/gnus-init-file (no-littering-expand-etc-file-name "gnus") | |
1555 | mail-user-agent 'gnus-user-agent | |
1556 | read-mail-command 'gnus) | |
1557 | ||
1558 | (use-feature gnus | |
1559 | :bind (("s-m" . gnus) | |
1560 | ("s-M" . gnus-unplugged)) | |
1561 | :init | |
1562 | (setq | |
1563 | gnus-select-method '(nnnil "") | |
1564 | gnus-secondary-select-methods | |
1565 | '((nnimap "amin" | |
1566 | (nnimap-stream plain) | |
1567 | (nnimap-address "127.0.0.1") | |
1568 | (nnimap-server-port 143) | |
1569 | (nnimap-authenticator plain) | |
727d14d3 AB |
1570 | (nnimap-user "amin@bndl.local")) |
1571 | (nnimap "uw" | |
41d290a2 AB |
1572 | (nnimap-stream plain) |
1573 | (nnimap-address "127.0.0.1") | |
1574 | (nnimap-server-port 143) | |
1575 | (nnimap-authenticator plain) | |
727d14d3 AB |
1576 | (nnimap-user "abandali@uw.local")) |
1577 | (nnimap "csc" | |
41d290a2 AB |
1578 | (nnimap-stream plain) |
1579 | (nnimap-address "127.0.0.1") | |
1580 | (nnimap-server-port 143) | |
1581 | (nnimap-authenticator plain) | |
727d14d3 | 1582 | (nnimap-user "abandali@csc.uw.local"))) |
41d290a2 AB |
1583 | gnus-message-archive-group "nnimap+amin:Sent" |
1584 | gnus-parameters | |
1585 | '(("gnu\\.deepspec" | |
1586 | (to-address . "deepspec@lists.cs.princeton.edu") | |
1587 | (to-list . "deepspec@lists.cs.princeton.edu")) | |
1588 | ("gnu\\.emacs-devel" | |
1589 | (to-address . "emacs-devel@gnu.org") | |
1590 | (to-list . "emacs-devel@gnu.org")) | |
1591 | ("gnu\\.emacs-orgmode" | |
1592 | (to-address . "emacs-orgmode@gnu.org") | |
1593 | (to-list . "emacs-orgmode@gnu.org")) | |
1594 | ("gnu\\.emacsconf-discuss" | |
1595 | (to-address . "emacsconf-discuss@gnu.org") | |
1596 | (to-list . "emacsconf-discuss@gnu.org")) | |
1597 | ("gnu\\.fencepost-users" | |
1598 | (to-address . "fencepost-users@gnu.org") | |
1599 | (to-list . "fencepost-users@gnu.org")) | |
1600 | ("gnu\\.gnunet-developers" | |
1601 | (to-address . "gnunet-developers@gnu.org") | |
1602 | (to-list . "gnunet-developers@gnu.org")) | |
1603 | ("gnu\\.guile-devel" | |
1604 | (to-address . "guile-devel@gnu.org") | |
1605 | (to-list . "guile-devel@gnu.org")) | |
1606 | ("gnu\\.guix-devel" | |
1607 | (to-address . "guix-devel@gnu.org") | |
1608 | (to-list . "guix-devel@gnu.org")) | |
1609 | ("gnu\\.haskell-art" | |
1610 | (to-address . "haskell-art@we.lurk.org") | |
1611 | (to-list . "haskell-art@we.lurk.org")) | |
1612 | ("gnu\\.haskell-cafe" | |
1613 | (to-address . "haskell-cafe@haskell.org") | |
1614 | (to-list . "haskell-cafe@haskell.org")) | |
1615 | ("gnu\\.help-gnu-emacs" | |
1616 | (to-address . "help-gnu-emacs@gnu.org") | |
1617 | (to-list . "help-gnu-emacs@gnu.org")) | |
1618 | ("gnu\\.info-gnu-emacs" | |
1619 | (to-address . "info-gnu-emacs@gnu.org") | |
1620 | (to-list . "info-gnu-emacs@gnu.org")) | |
1621 | ("gnu\\.info-guix" | |
1622 | (to-address . "info-guix@gnu.org") | |
1623 | (to-list . "info-guix@gnu.org")) | |
1624 | ("gnu\\.notmuch" | |
1625 | (to-address . "notmuch@notmuchmail.org") | |
1626 | (to-list . "notmuch@notmuchmail.org")) | |
1627 | ("gnu\\.parabola-dev" | |
1628 | (to-address . "dev@lists.parabola.nu") | |
1629 | (to-list . "dev@lists.parabola.nu")) | |
1630 | ("gnu\\.webmasters" | |
1631 | (to-address . "webmasters@gnu.org") | |
1632 | (to-list . "webmasters@gnu.org")) | |
1633 | ("gnu\\.www-commits" | |
1634 | (to-address . "www-commits@gnu.org") | |
1635 | (to-list . "www-commits@gnu.org")) | |
1636 | ("gnu\\.www-discuss" | |
1637 | (to-address . "www-discuss@gnu.org") | |
1638 | (to-list . "www-discuss@gnu.org")) | |
1639 | ("gnu\\.~bandali\\.public-inbox" | |
1640 | (to-address . "~bandali/public-inbox@lists.sr.ht") | |
1641 | (to-list . "~bandali/public-inbox@lists.sr.ht")) | |
1642 | ("gnu\\.~sircmpwn\\.srht-admins" | |
1643 | (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht") | |
1644 | (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht")) | |
1645 | ("gnu\\.~sircmpwn\\.srht-announce" | |
1646 | (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht") | |
1647 | (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht")) | |
1648 | ("gnu\\.~sircmpwn\\.srht-dev" | |
1649 | (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht") | |
1650 | (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht")) | |
1651 | ("gnu\\.~sircmpwn\\.srht-discuss" | |
1652 | (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht") | |
1653 | (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht")) | |
1654 | ("gnu.*" | |
1655 | (gcc-self . t)) | |
1656 | ("gnu\\." | |
262483ba AB |
1657 | (subscribed . t)) |
1658 | ("nnimap\\+uw:.*" | |
1659 | (gcc-self . t))) | |
41d290a2 AB |
1660 | gnus-large-newsgroup 50 |
1661 | gnus-home-directory (no-littering-expand-var-file-name "gnus/") | |
1662 | gnus-directory (concat gnus-home-directory "news/") | |
1663 | message-directory (concat gnus-home-directory "mail/") | |
1664 | nndraft-directory (concat gnus-home-directory "drafts/") | |
1665 | gnus-save-newsrc-file nil | |
1666 | gnus-read-newsrc-file nil | |
1667 | gnus-interactive-exit nil | |
1668 | gnus-gcc-mark-as-read t) | |
1669 | :config | |
1670 | (require 'ebdb) | |
1671 | (require 'ebdb-mua) | |
1672 | (require 'ebdb-gnus) | |
1673 | ||
1674 | (with-eval-after-load 'recentf | |
1675 | (add-to-list 'recentf-exclude gnus-home-directory))) | |
1676 | ||
1677 | (use-feature gnus-art | |
1678 | :config | |
1679 | (setq | |
1680 | gnus-visible-headers | |
1681 | (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:") | |
1682 | gnus-sorted-header-list | |
1683 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" | |
1684 | "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator" | |
1685 | "^Newsgroups:" "List-Id:" "^Organization:" | |
1686 | "^User-Agent:" "^Date:") | |
1687 | ;; local-lapsed article dates | |
1688 | ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11 | |
1689 | gnus-article-date-headers '(user-defined) | |
1690 | gnus-article-time-format | |
1691 | (lambda (time) | |
1692 | (let* ((date (format-time-string "%a, %d %b %Y %T %z" time)) | |
1693 | (local (article-make-date-line date 'local)) | |
1694 | (combined-lapsed (article-make-date-line date | |
1695 | 'combined-lapsed)) | |
1696 | (lapsed (progn | |
1697 | (string-match " (.+" combined-lapsed) | |
1698 | (match-string 0 combined-lapsed)))) | |
1699 | (concat local lapsed)))) | |
1700 | (bind-keys | |
1701 | :map gnus-article-mode-map | |
1702 | ("M-L" . org-store-link))) | |
1703 | ||
1704 | (use-feature gnus-sum | |
1705 | :bind (:map gnus-summary-mode-map | |
1706 | :prefix-map a/gnus-summary-prefix-map | |
1707 | :prefix "v" | |
1708 | ("r" . gnus-summary-reply) | |
1709 | ("w" . gnus-summary-wide-reply) | |
1710 | ("v" . gnus-summary-show-raw-article)) | |
1711 | :config | |
1712 | (bind-keys | |
1713 | :map gnus-summary-mode-map | |
1714 | ("M-L" . org-store-link)) | |
1715 | :hook (gnus-summary-mode . a/no-mouse-autoselect-window)) | |
1716 | ||
1717 | (use-feature gnus-msg | |
1718 | :config | |
1719 | (setq gnus-posting-styles | |
1720 | '((".*" | |
1721 | (address "amin@bndl.org") | |
1722 | (body "\nBest,\n") | |
1723 | (eval (setq a/message-cite-say-hi t))) | |
1724 | ("gnu.*" | |
1725 | (address "bandali@gnu.org") | |
1726 | (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org"))) | |
1727 | ((header "subject" "ThankCRM") | |
1728 | (to "webmasters-comment@gnu.org") | |
1729 | (body "Added to 2019supporters.html.\n\nMoving to campaigns.\n\n-amin\n") | |
1730 | (eval (setq a/message-cite-say-hi nil))) | |
63c1969d | 1731 | ("nnimap\\+uw:.*" |
262483ba AB |
1732 | (address "abandali@uwaterloo.ca")) |
1733 | ("nnimap\\+uw:INBOX" | |
63c1969d AB |
1734 | (gcc "\"nnimap+uw:Sent Items\"")) |
1735 | ("nnimap\\+csc:.*" | |
41d290a2 | 1736 | (address "abandali@csclub.uwaterloo.ca") |
63c1969d | 1737 | (gcc "nnimap+csc:Sent"))))) |
41d290a2 AB |
1738 | |
1739 | (use-feature gnus-topic | |
1740 | :hook (gnus-group-mode . gnus-topic-mode) | |
1741 | :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n")) | |
1742 | ||
1743 | (use-feature gnus-agent | |
1744 | :config | |
1745 | (setq gnus-agent-synchronize-flags 'ask) | |
1746 | :hook (gnus-group-mode . gnus-agent-mode)) | |
1747 | ||
1748 | (use-feature gnus-group | |
1749 | :config | |
1750 | (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)")) | |
1751 | ||
082360a8 AB |
1752 | (comment |
1753 | ;; problematic with ebdb's popup, *EBDB-Gnus* | |
1754 | (use-feature gnus-win | |
1755 | :config | |
1756 | (setq gnus-use-full-window nil))) | |
f485f78e | 1757 | |
348511ef AB |
1758 | (use-feature gnus-dired |
1759 | :commands gnus-dired-mode | |
1760 | :init | |
1761 | (add-hook 'dired-mode-hook 'gnus-dired-mode)) | |
1762 | ||
41d290a2 AB |
1763 | (use-feature mm-decode |
1764 | :config | |
1765 | (setq mm-discouraged-alternatives '("text/html" "text/richtext"))) | |
1766 | ||
1767 | (use-feature sendmail | |
1768 | :config | |
1769 | (setq sendmail-program "/usr/bin/msmtp" | |
1770 | ;; message-sendmail-extra-arguments '("-v" "-d") | |
1771 | mail-specify-envelope-from t | |
1772 | mail-envelope-from 'header)) | |
1773 | ||
1774 | (use-feature message | |
1775 | :config | |
1776 | ;; redefine for a simplified In-Reply-To header | |
1777 | ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67) | |
1778 | (defun message-make-in-reply-to () | |
1779 | "Return the In-Reply-To header for this message." | |
1780 | (when message-reply-headers | |
1781 | (let ((from (mail-header-from message-reply-headers)) | |
1782 | (msg-id (mail-header-id message-reply-headers))) | |
1783 | (when from | |
1784 | msg-id)))) | |
1785 | ||
1786 | (defconst a/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:") | |
1787 | (defconst message-cite-style-bandali | |
1788 | '((message-cite-function 'message-cite-original) | |
1789 | (message-citation-line-function 'message-insert-formatted-citation-line) | |
1790 | (message-cite-reply-position 'traditional) | |
1791 | (message-yank-prefix "> ") | |
1792 | (message-yank-cited-prefix ">") | |
1793 | (message-yank-empty-prefix ">") | |
1794 | (message-citation-line-format | |
1795 | (if a/message-cite-say-hi | |
1796 | (concat "Hi %F,\n\n" a/message-cite-style-format) | |
1797 | a/message-cite-style-format))) | |
1798 | "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.") | |
1799 | (setq ;; message-cite-style 'message-cite-style-bandali | |
1800 | message-kill-buffer-on-exit t | |
1801 | message-send-mail-function 'message-send-mail-with-sendmail | |
1802 | message-sendmail-envelope-from 'header | |
1803 | message-subscribed-address-functions | |
1804 | '(gnus-find-subscribed-addresses) | |
1805 | message-dont-reply-to-names | |
1806 | "\\(\\(amin@bndl\\.org\\)\\|\\(.*@\\(aminb\\|amin\\.bndl\\)\\.org\\)\\|\\(\\(bandali\\|aminb?\\|mab\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)") | |
1807 | (require 'company-ebdb) | |
1808 | :hook (;; (message-setup . mml-secure-message-sign-pgpmime) | |
1809 | (message-mode . flyspell-mode) | |
1810 | (message-mode . (lambda () | |
1811 | ;; (setq fill-column 65 | |
1812 | ;; message-fill-column 65) | |
1813 | (make-local-variable 'company-idle-delay) | |
1814 | (setq company-idle-delay 0.2)))) | |
1815 | ;; :custom-face | |
1816 | ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold)))) | |
1817 | ;; (message-header-to ((t (:foreground "#111" :weight normal)))) | |
1818 | ;; (message-header-cc ((t (:foreground "#333" :weight normal)))) | |
1819 | ) | |
1820 | ||
1821 | (with-eval-after-load 'mml-sec | |
1822 | (setq mml-secure-openpgp-encrypt-to-self t | |
1823 | mml-secure-openpgp-sign-with-sender t)) | |
1824 | ||
1825 | (use-feature footnote | |
1826 | :after message | |
1827 | ;; :config | |
1828 | ;; (setq footnote-start-tag "" | |
1829 | ;; footnote-end-tag "" | |
1830 | ;; footnote-style 'unicode) | |
1831 | :bind | |
1832 | (:map message-mode-map | |
1833 | :prefix-map a/footnote-prefix-map | |
1834 | :prefix "C-c f" | |
1835 | ("a" . footnote-add-footnote) | |
1836 | ("b" . footnote-back-to-message) | |
1837 | ("c" . footnote-cycle-style) | |
1838 | ("d" . footnote-delete-footnote) | |
1839 | ("g" . footnote-goto-footnote) | |
1840 | ("r" . footnote-renumber-footnotes) | |
1841 | ("s" . footnote-set-style))) | |
1842 | ||
1843 | (use-package ebdb | |
1844 | :straight (:host github :repo "girzel/ebdb") | |
1845 | :after gnus | |
1846 | :bind (:map gnus-group-mode-map ("e" . ebdb)) | |
1847 | :config | |
1848 | (setq ebdb-sources (no-littering-expand-var-file-name "ebdb")) | |
1849 | (with-eval-after-load 'swiper | |
1850 | (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t))) | |
1851 | ||
1852 | (use-feature ebdb-com | |
1853 | :after ebdb) | |
1854 | ||
1855 | ;; (use-package ebdb-complete | |
1856 | ;; :after ebdb | |
1857 | ;; :config | |
1858 | ;; (ebdb-complete-enable)) | |
1859 | ||
1860 | (use-package company-ebdb | |
1861 | :config | |
1862 | (defun company-ebdb--post-complete (_) nil)) | |
1863 | ||
1864 | (use-feature ebdb-gnus | |
1865 | :after ebdb | |
1866 | :custom | |
1867 | (ebdb-gnus-window-configuration | |
1868 | '(article | |
1869 | (vertical 1.0 | |
1870 | (summary 0.25 point) | |
1871 | (horizontal 1.0 | |
1872 | (article 1.0) | |
1873 | (ebdb-gnus 0.3)))))) | |
1874 | ||
1875 | (use-feature ebdb-mua | |
1876 | :after ebdb | |
1877 | ;; :custom (ebdb-mua-pop-up nil) | |
1878 | ) | |
1879 | ||
1880 | ;; (use-package ebdb-message | |
1881 | ;; :after ebdb) | |
1882 | ||
1883 | ||
1884 | ;; (use-package ebdb-vcard | |
1885 | ;; :after ebdb) | |
1886 | ||
1887 | (use-package message-x) | |
1888 | ||
b57457b2 AB |
1889 | (comment |
1890 | (use-package message-x | |
1891 | :custom | |
1892 | (message-x-completion-alist | |
1893 | (quote | |
1894 | (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address) | |
1895 | ((if | |
1896 | (boundp | |
1897 | (quote message-newgroups-header-regexp)) | |
1898 | message-newgroups-header-regexp message-newsgroups-header-regexp) | |
1899 | . message-expand-group)))))) | |
1900 | ||
1901 | (comment | |
1902 | (use-package gnus-harvest | |
1903 | :commands gnus-harvest-install | |
1904 | :demand t | |
1905 | :config | |
1906 | (if (featurep 'message-x) | |
1907 | (gnus-harvest-install 'message-x) | |
1908 | (gnus-harvest-install)))) | |
1909 | ||
1910 | \f | |
1911 | ;;; IRC | |
1912 | ||
41d290a2 AB |
1913 | (use-package znc |
1914 | :straight (:host nil :repo "https://git.bndl.org/amin/znc.el") | |
1915 | :bind (("C-c a e e" . znc-erc) | |
1916 | ("C-c a e a" . znc-all)) | |
1917 | :config | |
1918 | (let ((pwd (let ((auth (auth-source-search :host "znca"))) | |
1919 | (cond | |
1920 | ((null auth) (error "Couldn't find znca's authinfo")) | |
1921 | (t (funcall (plist-get (car auth) :secret))))))) | |
1922 | (setq znc-servers | |
1923 | `(("znc.bndl.org" 1337 t | |
1924 | ((freenode "amin/freenode" ,pwd))) | |
1925 | ("znc.bndl.org" 1337 t | |
1926 | ((moznet "amin/moznet" ,pwd))))))) | |
1927 | ||
b57457b2 AB |
1928 | \f |
1929 | ;;; Post initialization | |
1930 | ||
41d290a2 AB |
1931 | (message "Loading %s...done (%.3fs)" user-init-file |
1932 | (float-time (time-subtract (current-time) | |
1933 | a/before-user-init-time))) | |
1934 | ||
1935 | ;;; init.el ends here |