emacs: slight init.el tweaks
[~bandali/configs] / .emacs.d / init.el
CommitLineData
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
21;; programmer, and free software advocate.
22
23;; THIS FILE IS AUTO-GENERATED FROM `init.org'.
24
49e9503b
AB
25;;; Code:
26
41d290a2
AB
27(defvar a/byte-compiled-init nil
28 "If non-nil, byte-(re)compile init.el on successful tangles.")
29
30(defvar a/before-user-init-time (current-time)
31 "Value of `current-time' when Emacs begins loading `user-init-file'.")
32(message "Loading Emacs...done (%.3fs)"
33 (float-time (time-subtract a/before-user-init-time
34 before-init-time)))
35
36(defvar a/gc-cons-threshold gc-cons-threshold)
37(defvar a/gc-cons-percentage gc-cons-percentage)
38(defvar a/file-name-handler-alist file-name-handler-alist)
39(setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB
40 gc-cons-percentage 0.6
41 file-name-handler-alist nil
42 ;; sidesteps a bug when profiling with esup
43 esup-child-profile-require-level 0)
44
45(add-hook
46 'after-init-hook
47 (lambda ()
48 (setq gc-cons-threshold a/gc-cons-threshold
49 gc-cons-percentage a/gc-cons-percentage
50 file-name-handler-alist a/file-name-handler-alist)))
51
52(setq message-log-max 20000)
53
54;; (setq byte-compile-warnings
55;; '(not free-vars unresolved noruntime lexical make-local))
56
57(setq user-full-name "Amin Bandali"
58 user-mail-address "amin@bndl.org")
59
60;; Main engine start...
61
62(setq straight-repository-branch "develop"
63 straight-check-for-modifications '(check-on-save find-when-checking))
64
65(defun a/bootstrap-straight ()
66 (defvar bootstrap-version)
67 (let ((bootstrap-file
68 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
69 (bootstrap-version 5))
70 (unless (file-exists-p bootstrap-file)
71 (with-current-buffer
72 (url-retrieve-synchronously
73 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
74 'silent 'inhibit-cookies)
75 (goto-char (point-max))
76 (eval-print-last-sexp)))
77 (load bootstrap-file nil 'nomessage)))
78
79;; Solid rocket booster ignition...
80
81(defun a/build-init ()
82 (a/bootstrap-straight)
83 (byte-compile-file "init.el"))
84
85(a/bootstrap-straight)
86
87;; We have lift off!
88
89(setq straight-use-package-by-default t)
90
91(defmacro use-feature (name &rest args)
92 "Like `use-package', but with `straight-use-package-by-default' disabled."
93 (declare (indent defun))
94 `(use-package ,name
95 :straight nil
96 ,@args))
97
98(with-eval-after-load 'recentf
99 (add-to-list 'recentf-exclude
100 (expand-file-name "~/.emacs.d/straight/build/")))
101
102(defun a/reload-init ()
103 "Reload init.el."
104 (interactive)
105 (straight-transaction
106 (straight-mark-transaction-as-init)
107 (load (if a/byte-compiled-init
108 (concat (file-name-sans-extension user-init-file) ".elc")
109 user-init-file))))
110
111(straight-use-package 'use-package)
112(if nil ; set to t when need to debug init
113 (progn
114 (setq use-package-verbose t
115 use-package-expand-minimally nil
116 use-package-compute-statistics t
117 debug-on-error t)
118 (require 'use-package))
119 (setq use-package-verbose nil
120 use-package-expand-minimally t))
121
122(setq use-package-always-defer t)
123(require 'bind-key)
124
125(use-package no-littering
126 :demand t
127 :config
128 (savehist-mode 1)
129 (add-to-list 'savehist-additional-variables 'kill-ring)
130 (save-place-mode 1)
131 (setq auto-save-file-name-transforms
132 `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
133
134(use-feature custom
135 :no-require t
136 :config
137 (setq custom-file (no-littering-expand-etc-file-name "custom.el"))
138 (when (file-exists-p custom-file)
139 (load custom-file))
140 (setf custom-safe-themes t))
141
142(with-demoted-errors
143 (load (no-littering-expand-etc-file-name "secrets")))
144
145(use-package exec-path-from-shell
146 :defer 0.4
147 :init
148 (setq exec-path-from-shell-arguments nil
149 exec-path-from-shell-check-startup-files nil)
150 :config
151 (exec-path-from-shell-initialize)
152 ;; while we're at it, let's fix access to our running ssh-agent
153 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
154 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
155
156(use-feature server
157 :defer 0.4
158 :config (or (server-running-p) (server-mode)))
159
160(setq text-scale-mode-step 1.05)
161
162(setq mouse-autoselect-window t)
163
164(defun a/no-mouse-autoselect-window ()
165 (make-local-variable 'mouse-autoselect-window)
166 (setq mouse-autoselect-window nil))
167
168(setq ;; scroll-margin 1
169 ;; scroll-conservatively 10000
170 scroll-step 1
171 scroll-conservatively 10
172 scroll-preserve-screen-position 1)
173
174(use-feature mwheel
175 :defer 0.4
176 :config
177 (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time
178 mouse-wheel-progressive-speed nil ; don't accelerate scrolling
179 mouse-wheel-follow-mouse t)) ; scroll window under mouse
180
181(use-feature pixel-scroll
182 :defer 0.4
183 :config (pixel-scroll-mode 1))
184
185(setq epg-pinentry-mode 'loopback)
186
187(require 'cl-lib)
188(require 'subr-x)
189
190(defmacro a/setq-every (value &rest vars)
191 "Set all the variables from VARS to value VALUE."
192 (declare (indent defun) (debug t))
193 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
194
195(defun a/start-process (program &rest args)
196 "Same as `start-process', but doesn't bother about name and buffer."
197 (let ((process-name (concat program "_process"))
198 (buffer-name (generate-new-buffer-name
199 (concat program "_output"))))
200 (apply #'start-process
201 process-name buffer-name program args)))
202
203(defun a/dired-start-process (program &optional args)
204 "Open current file with a PROGRAM."
205 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
206 ;; be nil, so remove it).
207 (apply #'a/start-process
208 program
209 (remove nil (list args (dired-get-file-for-visit)))))
210
211;; (fringe-mode '(3 . 1))
212(fringe-mode nil)
213
214(setq disabled-command-function nil)
215
216(setq save-interprogram-paste-before-kill t)
217
218(setq enable-recursive-minibuffers t
219 resize-mini-windows t)
220
221(defalias 'yes-or-no-p #'y-or-n-p)
222
223(setq initial-buffer-choice t)
224
225(setq initial-scratch-message nil)
226
227(setq initial-major-mode 'text-mode)
228
229(setq inhibit-startup-buffer-menu t)
230
231(advice-add #'display-startup-echo-area-message :override #'ignore)
232(setq inhibit-startup-screen t
233 inhibit-startup-echo-area-message user-login-name)
234
235(setq frame-title-format
236 '("" invocation-name " - "
237 (:eval (if (buffer-file-name)
238 (abbreviate-file-name (buffer-file-name))
239 "%b"))))
240
241(setq backup-by-copying t
242 version-control t
243 delete-old-versions t)
244
245(global-auto-revert-mode 1)
246(setq auto-revert-verbose nil
247 global-auto-revert-non-file-buffers nil)
248
249(setq-default
250 indent-tabs-mode nil
251 require-final-newline t
252 tab-width 4)
253
254(winner-mode 1)
255
256(with-eval-after-load 'compile
257 (defun a/compilation-finish-function (buffer outstr)
258 (unless (string-match "finished" outstr)
259 (switch-to-buffer-other-window buffer))
260 t)
261
262 (setq compilation-finish-functions #'a/compilation-finish-function)
263
264 (require 'cl-macs)
265
266 (defadvice compilation-start
267 (around inhibit-display
268 (command &optional mode name-function highlight-regexp))
269 (if (not (string-match "^\\(find\\|grep\\)" command))
270 (cl-letf (((symbol-function 'display-buffer) #'ignore))
271 (save-window-excursion ad-do-it))
272 ad-do-it))
273 (ad-activate 'compilation-start))
274
275(setq search-default-mode #'char-fold-to-regexp)
276
277;; uncomment to extend this behaviour to query-replace
278;; (setq replace-char-fold t)
279
280(setq-default cursor-type 'bar)
281
282(setq isearch-allow-scroll t)
283
284(bind-keys
285 ("C-c a i" . ielm)
286
287 ("C-c e b" . eval-buffer)
288 ("C-c e r" . eval-region)
289
290 ("C-c e i" . emacs-init-time)
291 ("C-c e u" . emacs-uptime)
292
293 ("C-c F m" . make-frame-command)
294 ("C-c F d" . delete-frame)
295 ("C-c F D" . delete-other-frames)
296
297 ("C-c o" . other-window)
298
299 ("C-S-h C" . describe-char)
300 ("C-S-h F" . describe-face)
301
302 ("C-x k" . kill-this-buffer)
303 ("C-x K" . kill-buffer)
304
305 ("s-p" . beginning-of-buffer)
306 ("s-n" . end-of-buffer))
307
308(when (display-graphic-p)
309 (unbind-key "C-z" global-map))
310
311(bind-keys
312 :prefix-map a/straight-prefix-map
313 :prefix "C-c p s"
314 ("u" . straight-use-package)
315 ("f" . straight-freeze-versions)
316 ("t" . straight-thaw-versions)
317 ("P" . straight-prune-build)
318 ("g" . straight-get-recipe)
319 ("r" . a/reload-init)
320 ;; M-x ^straight-.*-all$
321 ("a c" . straight-check-all)
322 ("a f" . straight-fetch-all)
323 ("a m" . straight-merge-all)
324 ("a n" . straight-normalize-all)
325 ("a F" . straight-pull-all)
326 ("a P" . straight-push-all)
327 ("a r" . straight-rebuild-all)
328 ;; M-x ^straight-.*-package$
329 ("p c" . straight-check-package)
330 ("p f" . straight-fetch-package)
331 ("p m" . straight-merge-package)
332 ("p n" . straight-normalize-package)
333 ("p F" . straight-pull-package)
334 ("p P" . straight-push-package)
335 ("p r" . straight-rebuild-package))
336
337(use-package auto-compile
338 :demand t
339 :config
340 (auto-compile-on-load-mode)
341 (auto-compile-on-save-mode)
342 (setq auto-compile-display-buffer nil
343 auto-compile-mode-line-counter t
344 auto-compile-source-recreate-deletes-dest t
345 auto-compile-toggle-deletes-nonlib-dest t
346 auto-compile-update-autoloads t)
347 (add-hook 'auto-compile-inhibit-compile-hook
348 'auto-compile-inhibit-compile-detached-git-head))
349
350(straight-use-package 'org-plus-contrib)
351
352(use-feature org
353 :defer 0.5
354 :config
355 (setq org-src-tab-acts-natively t
356 org-src-preserve-indentation nil
357 org-edit-src-content-indentation 0
358 org-link-email-description-format "Email %c: %s" ; %.30s
359 org-highlight-latex-and-related '(entities)
360 org-use-speed-commands t
361 org-startup-folded 'content
362 org-catch-invisible-edits 'show-and-error
363 org-log-done 'time)
364 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
365 :bind
366 (("C-c a o a" . org-agenda)
367 :map org-mode-map
368 ("M-L" . org-insert-last-stored-link)
369 ("s-T" . org-todo))
370 :hook ((org-mode . org-indent-mode)
371 (org-mode . auto-fill-mode)
372 (org-mode . flyspell-mode))
373 :custom
374 (org-agenda-files '("~/usr/org/todos/personal.org"
375 "~/usr/org/todos/masters.org"))
376 (org-agenda-start-on-weekday 0)
377 (org-latex-packages-alist '(("" "listings") ("" "color")))
378 :custom-face
379 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
380 '(org-block ((t (:background "#1d1f21"))))
381 '(org-latex-and-related ((t (:foreground "#b294bb")))))
382
383(use-feature ox-latex
384 :after ox
385 :config
386 (setq org-latex-listings 'listings
387 ;; org-latex-prefer-user-labels t
388 )
389 (add-to-list 'org-latex-classes
390 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
391 ("\\section{%s}" . "\\section*{%s}")
392 ("\\subsection{%s}" . "\\subsection*{%s}")
393 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
394 ("\\paragraph{%s}" . "\\paragraph*{%s}")
395 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
396 t)
397 (require 'ox-beamer))
398
399(use-feature ox-extra
400 :config
401 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
402
403(with-eval-after-load 'org
404 (defvar a/show-async-tangle-results nil
405 "Keep *emacs* async buffers around for later inspection.")
406
407 (defvar a/show-async-tangle-time nil
408 "Show the time spent tangling the file.")
409
410 (defvar a/async-tangle-post-compile
411 (when a/byte-compiled-init "make build-init")
412 "If non-nil, pass to `compile' after successful tangle.")
413
414 ;; TODO: look into why directly byte-compiling init.el causes a
415 ;; number of problems, including magit-status not loading (busy
416 ;; waiting).
417 (defvar a/async-tangle-byte-recompile nil
418 "If non-nil, byte-recompile the file on successful tangle.")
419
420 (defun a/async-babel-tangle ()
421 "Tangle org file asynchronously."
422 (interactive)
423 (let* ((file-tangle-start-time (current-time))
424 (file (buffer-file-name))
425 (file-nodir (file-name-nondirectory file))
426 ;; (async-quiet-switch "-q")
427 (file-noext (file-name-sans-extension file)))
428 (async-start
429 `(lambda ()
430 (require 'org)
431 (org-babel-tangle-file ,file))
432 (unless a/show-async-tangle-results
433 `(lambda (result)
434 (if result
435 (progn
436 ;; (setq byte-compile-warnings '(not noruntime unresolved))
437 (message "Tangled %s%s"
438 ,file-nodir
439 (if a/show-async-tangle-time
440 (format " (%.3fs)"
441 (float-time (time-subtract (current-time)
442 ',file-tangle-start-time)))
443 ""))
444 (when a/async-tangle-post-compile
445 (compile a/async-tangle-post-compile))
446 (when a/async-tangle-byte-recompile
447 (byte-recompile-file (concat ,file-noext ".el"))))
448 (message "Tangling %s failed" ,file-nodir))))))))
449
450(add-to-list
451 'safe-local-variable-values
452 '(eval add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local))
453
454(use-package magit
455 :defer 0.5
456 :bind (("C-x g" . magit-status)
457 ("s-g s" . magit-status)
458 ("s-g l" . magit-log-buffer-file))
459 :config
460 (magit-add-section-hook 'magit-status-sections-hook
461 'magit-insert-modules
462 'magit-insert-stashes
463 'append)
464 (setq magit-repository-directories '(("~/" . 0)
465 ("~/src/git/" . 1)))
466 (nconc magit-section-initial-visibility-alist
467 '(([unpulled status] . show)
468 ([unpushed status] . show)))
469 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
470
471(use-feature recentf
472 :defer 0.2
473 :config
474 (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
475 (setq recentf-max-saved-items 40))
476
477(use-package smex)
478
479(use-package ivy
480 :defer 0.3
481 :bind
482 (:map ivy-minibuffer-map
483 ([escape] . keyboard-escape-quit)
484 ([S-up] . ivy-previous-history-element)
485 ([S-down] . ivy-next-history-element)
486 ("DEL" . ivy-backward-delete-char))
487 :config
488 (setq ivy-wrap t
489 ivy-height 14
490 ivy-use-virtual-buffers t
491 ivy-virtual-abbreviate 'abbreviate
492 ivy-count-format "%d/%d ")
493 (ivy-mode 1)
494 ;; :custom-face
495 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
496 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
497 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
498)
499
500(use-package swiper
501 :after ivy
502 :bind (("C-s" . swiper-isearch)
503 ("C-r" . swiper)
504 ("C-S-s" . isearch-forward)))
505
506(use-package counsel
507 :after ivy
508 :bind (([remap execute-extended-command] . counsel-M-x)
509 ([remap find-file] . counsel-find-file)
510 ("C-c x" . counsel-M-x)
511 ("C-c f ." . counsel-find-file)
512 ("C-c f l" . counsel-find-library)
513 :map minibuffer-local-map
514 ("C-r" . counsel-minibuffer-history))
515 :config
516 (counsel-mode 1)
517 (defalias 'locate #'counsel-locate))
518
519(use-feature eshell
520 :defer 0.5
521 :commands eshell
522 :bind ("C-c a s e" . eshell)
523 :config
524 (eval-when-compile (defvar eshell-prompt-regexp))
525 (defun a/eshell-quit-or-delete-char (arg)
526 (interactive "p")
527 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
528 (eshell-life-is-too-much)
529 (delete-char arg)))
530
531 (defun a/eshell-clear ()
532 (interactive)
533 (let ((inhibit-read-only t))
534 (erase-buffer))
535 (eshell-send-input))
536
537 (defun a/eshell-setup ()
538 (make-local-variable 'company-idle-delay)
539 (defvar company-idle-delay)
540 (setq company-idle-delay nil)
541 (bind-keys :map eshell-mode-map
542 ("C-d" . a/eshell-quit-or-delete-char)
543 ("C-S-l" . a/eshell-clear)
544 ("M-r" . counsel-esh-history)
545 ([tab] . company-complete)))
546
547 :hook (eshell-mode . a/eshell-setup)
548 :custom
549 (eshell-hist-ignoredups t)
550 (eshell-input-filter 'eshell-input-filter-initial-space))
551
552(use-feature ibuffer
553 :bind
554 (("C-x C-b" . ibuffer-other-window)
555 :map ibuffer-mode-map
556 ("P" . ibuffer-backward-filter-group)
557 ("N" . ibuffer-forward-filter-group)
558 ("M-p" . ibuffer-do-print)
559 ("M-n" . ibuffer-do-shell-command-pipe-replace))
560 :config
561 ;; Use human readable Size column instead of original one
562 (define-ibuffer-column size-h
563 (:name "Size" :inline t)
564 (cond
565 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
566 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
567 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
568 (t (format "%8d" (buffer-size)))))
569 :custom
570 (ibuffer-saved-filter-groups
571 '(("default"
572 ("dired" (mode . dired-mode))
573 ("org" (mode . org-mode))
574 ("gnus"
575 (or
576 (mode . gnus-group-mode)
577 (mode . gnus-summary-mode)
578 (mode . gnus-article-mode)
579 ;; not really, but...
580 (mode . message-mode)))
581 ("web"
582 (or
583 (mode . web-mode)
584 (mode . css-mode)
585 (mode . scss-mode)
586 (mode . js2-mode)))
587 ("shell"
588 (or
589 (mode . eshell-mode)
590 (mode . shell-mode)
591 (mode . term-mode)))
592 ("programming"
593 (or
594 (mode . python-mode)
595 (mode . c-mode)
596 (mode . c++-mode)
597 (mode . java-mode)
598 (mode . emacs-lisp-mode)
599 (mode . scheme-mode)
600 (mode . haskell-mode)
601 (mode . lean-mode)
602 (mode . alloy-mode)))
603 ("tex"
604 (or
605 (mode . bibtex-mode)
606 (mode . latex-mode)))
607 ("emacs"
608 (or
609 (name . "^\\*scratch\\*$")
610 (name . "^\\*Messages\\*$")))
611 ("erc" (mode . erc-mode)))))
612 (ibuffer-formats
613 '((mark modified read-only locked " "
614 (name 18 18 :left :elide)
615 " "
616 (size-h 9 -1 :right)
617 " "
618 (mode 16 16 :left :elide)
619 " " filename-and-process)
620 (mark " "
621 (name 16 -1)
622 " " filename)))
623 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
624
625(use-feature outline
626 :hook (prog-mode . outline-minor-mode)
627 :bind
628 (:map
629 outline-minor-mode-map
630 ("<s-tab>" . outline-toggle-children)
631 ("M-p" . outline-previous-visible-heading)
632 ("M-n" . outline-next-visible-heading)
633 :prefix-map a/outline-prefix-map
634 :prefix "s-o"
635 ("TAB" . outline-toggle-children)
636 ("a" . outline-hide-body)
637 ("H" . outline-hide-body)
638 ("S" . outline-show-all)
639 ("h" . outline-hide-subtree)
640 ("s" . outline-show-subtree)))
641
642(use-feature ls-lisp
643 :custom (ls-lisp-dirs-first t))
644
645(use-feature dired
646 :config
647 (setq dired-listing-switches "-alh"
648 ls-lisp-use-insert-directory-program nil)
649
650 ;; easily diff 2 marked files
651 ;; https://oremacs.com/2017/03/18/dired-ediff/
652 (defun dired-ediff-files ()
653 (interactive)
654 (require 'dired-aux)
655 (defvar ediff-after-quit-hook-internal)
656 (let ((files (dired-get-marked-files))
657 (wnd (current-window-configuration)))
658 (if (<= (length files) 2)
659 (let ((file1 (car files))
660 (file2 (if (cdr files)
661 (cadr files)
662 (read-file-name
663 "file: "
664 (dired-dwim-target-directory)))))
665 (if (file-newer-than-file-p file1 file2)
666 (ediff-files file2 file1)
667 (ediff-files file1 file2))
668 (add-hook 'ediff-after-quit-hook-internal
669 (lambda ()
670 (setq ediff-after-quit-hook-internal nil)
671 (set-window-configuration wnd))))
672 (error "no more than 2 files should be marked"))))
673 :bind (:map dired-mode-map
674 ("b" . dired-up-directory)
675 ("e" . dired-ediff-files)
676 ("E" . dired-toggle-read-only)
677 ("\\" . dired-hide-details-mode)
678 ("z" . (lambda ()
679 (interactive)
680 (a/dired-start-process "zathura"))))
681 :hook (dired-mode . dired-hide-details-mode))
682
683(use-feature help
684 :config
685 (temp-buffer-resize-mode)
686 (setq help-window-select t))
687
688(use-feature tramp
689 :config
690 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
691 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
692 (add-to-list 'tramp-default-proxies-alist
693 (list (regexp-quote (system-name)) nil nil)))
694
695(use-package dash
696 :config (dash-enable-font-lock))
697
698(use-package doc-view
699 :bind (:map doc-view-mode-map
700 ("M-RET" . image-previous-line)))
701
702(use-package diff-hl
703 :config
704 (setq diff-hl-draw-borders nil)
705 (global-diff-hl-mode)
706 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
707
708(use-feature eldoc
709 :when (version< "25" emacs-version)
710 :config (global-eldoc-mode))
711
712(use-feature paren
713 :demand
714 :config (show-paren-mode))
715
716(use-feature simple
717 :config (column-number-mode))
718
719(use-feature savehist
720 :config (savehist-mode))
721
722(use-feature saveplace
723 :when (version< "25" emacs-version)
724 :config (save-place-mode))
725
726(use-feature prog-mode
727 :config (global-prettify-symbols-mode)
728 (defun indicate-buffer-boundaries-left ()
729 (setq indicate-buffer-boundaries 'left))
730 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
731
732(use-feature text-mode
733 :hook ((text-mode . indicate-buffer-boundaries-left)
734 (text-mode . abbrev-mode)))
735
736(use-package company
737 :defer 0.6
738 :bind
739 (:map company-active-map
740 ([tab] . company-complete-common-or-cycle)
741 ([escape] . company-abort))
742 :custom
743 (company-minimum-prefix-length 1)
744 (company-selection-wrap-around t)
745 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
746 (company-dabbrev-downcase nil)
747 (company-dabbrev-ignore-case nil)
748 :config
749 (global-company-mode t))
750
751(use-package flycheck
752 :defer 0.6
753 :hook (prog-mode . flycheck-mode)
754 :bind
755 (:map flycheck-mode-map
756 ("M-P" . flycheck-previous-error)
757 ("M-N" . flycheck-next-error))
758 :config
759 ;; Use the load-path from running Emacs when checking elisp files
760 (setq flycheck-emacs-lisp-load-path 'inherit)
761
762 ;; Only flycheck when I actually save the buffer
763 (setq flycheck-check-syntax-automatically '(mode-enabled save)))
764
765;; http://endlessparentheses.com/ispell-and-apostrophes.html
766(use-package ispell
767 :defer 0.6
768 :config
769 ;; ’ can be part of a word
770 (setq ispell-local-dictionary-alist
771 `((nil "[[:alpha:]]" "[^[:alpha:]]"
772 "['\x2019]" nil ("-B") nil utf-8)))
773 ;; don't send ’ to the subprocess
774 (defun endless/replace-apostrophe (args)
775 (cons (replace-regexp-in-string
776 "’" "'" (car args))
777 (cdr args)))
778 (advice-add #'ispell-send-string :filter-args
779 #'endless/replace-apostrophe)
780
781 ;; convert ' back to ’ from the subprocess
782 (defun endless/replace-quote (args)
783 (if (not (derived-mode-p 'org-mode))
784 args
785 (cons (replace-regexp-in-string
786 "'" "’" (car args))
787 (cdr args))))
788 (advice-add #'ispell-parse-output :filter-args
789 #'endless/replace-quote))
790
791(use-feature lisp-mode
792 :config
793 (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
794 (add-hook 'emacs-lisp-mode-hook 'reveal-mode)
795 (defun indent-spaces-mode ()
796 (setq indent-tabs-mode nil))
797 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
798
799(use-package alloy-mode
800 :straight (:host github :repo "dwwmmn/alloy-mode")
801 :mode "\\.als\\'"
802 :config (setq alloy-basic-offset 2))
803
804(use-package proof-site ; Proof General
805 :straight proof-general)
806
807(eval-when-compile (defvar lean-mode-map))
808(use-package lean-mode
809 :defer 0.4
810 :bind (:map lean-mode-map
811 ("S-SPC" . company-complete))
812 :config
813 (require 'lean-input)
814 (setq default-input-method "Lean"
815 lean-input-tweak-all '(lean-input-compose
816 (lean-input-prepend "/")
817 (lean-input-nonempty))
818 lean-input-user-translations '(("/" "/")))
819 (lean-input-setup))
820
821(use-package haskell-mode
822 :config
823 (setq haskell-indentation-layout-offset 4
824 haskell-indentation-left-offset 4
825 flycheck-checker 'haskell-hlint
826 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
827
828(use-package dante
829 :after haskell-mode
830 :commands dante-mode
831 :hook (haskell-mode . dante-mode))
832
833(use-package hlint-refactor
834 :after haskell-mode
835 :bind (:map hlint-refactor-mode-map
836 ("C-c l b" . hlint-refactor-refactor-buffer)
837 ("C-c l r" . hlint-refactor-refactor-at-point))
838 :hook (haskell-mode . hlint-refactor-mode))
839
840(use-package flycheck-haskell
841 :after haskell-mode)
842
843(use-package sgml-mode
844 :config
845 (setq sgml-basic-offset 2))
846
847(use-package css-mode
848 :config
849 (setq css-indent-offset 2))
850
851(use-package web-mode
852 :mode "\\.html\\'"
853 :config
854 (a/setq-every 2
855 web-mode-code-indent-offset
856 web-mode-css-indent-offset
857 web-mode-markup-indent-offset))
858
859(use-package emmet-mode
860 :after (:any web-mode css-mode sgml-mode)
861 :bind* (("C-)" . emmet-next-edit-point)
862 ("C-(" . emmet-prev-edit-point))
863 :config
864 (unbind-key "C-j" emmet-mode-keymap)
865 (setq emmet-move-cursor-between-quotes t)
866 :hook (web-mode css-mode html-mode sgml-mode))
867
868(use-package geiser)
869
870(use-feature geiser-guile
871 :config
872 (setq geiser-guile-load-path "~/src/git/guix"))
873
874(use-package guix)
875
876(use-feature man
877 :config (setq Man-width 80))
878
879(use-package which-key
880 :defer 0.4
881 :config
882 (which-key-add-key-based-replacements
883 ;; prefixes for global prefixes and minor modes
884 "C-c @" "outline"
885 "C-c !" "flycheck"
886 "C-c 8" "typo"
887 "C-c 8 -" "typo/dashes"
888 "C-c 8 <" "typo/left-brackets"
889 "C-c 8 >" "typo/right-brackets"
890 "C-x 8" "unicode"
891 "C-x a" "abbrev/expand"
892 "C-x r" "rectangle/register/bookmark"
893 "C-x v" "version control"
894 ;; prefixes for my personal bindings
895 "C-c a" "applications"
896 "C-c a e" "erc"
897 "C-c a o" "org"
898 "C-c a s" "shells"
899 "C-c p" "package-management"
900 ;; "C-c p e" "package-management/epkg"
901 "C-c p s" "straight.el"
902 "C-c psa" "all"
903 "C-c psp" "package"
904 "C-c c" "compile-and-comments"
905 "C-c e" "eval"
906 "C-c f" "files"
907 "C-c F" "frames"
908 "C-S-h" "help(ful)"
909 "C-c m" "multiple-cursors"
910 "C-c P" "projectile"
911 "C-c P s" "projectile/search"
912 "C-c P x" "projectile/execute"
913 "C-c P 4" "projectile/other-window"
914 "C-c q" "boxquote"
915 "s-g" "magit"
916 "s-o" "outline"
917 "s-t" "themes")
918
919 ;; prefixes for major modes
920 (which-key-add-major-mode-key-based-replacements 'message-mode
921 "C-c f" "footnote")
922 (which-key-add-major-mode-key-based-replacements 'org-mode
923 "C-c C-v" "org-babel")
924 (which-key-add-major-mode-key-based-replacements 'web-mode
925 "C-c C-a" "web/attributes"
926 "C-c C-b" "web/blocks"
927 "C-c C-d" "web/dom"
928 "C-c C-e" "web/element"
929 "C-c C-t" "web/tags")
930
931 (which-key-mode)
932 :custom
933 (which-key-add-column-padding 5)
934 (which-key-max-description-length 32))
935
936(add-to-list 'custom-theme-load-path "~/.emacs.d/lisp")
937(load-theme 'tangomod t)
938
939(use-package smart-mode-line
940 :commands (sml/apply-theme)
941 :demand
942 :config
943 (sml/setup))
944
945(use-package doom-themes)
946
947(defvar a/org-mode-font-lock-keywords
948 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
949 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
950 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
951 (4 '(:foreground "#c5c8c6") t)))) ; title
952
953(defun a/lights-on ()
954 "Enable my favourite light theme."
955 (interactive)
956 (mapc #'disable-theme custom-enabled-themes)
957 (load-theme 'tangomod t)
958 (sml/apply-theme 'automatic)
959 (font-lock-remove-keywords
960 'org-mode a/org-mode-font-lock-keywords))
961
962(defun a/lights-off ()
963 "Go dark."
964 (interactive)
965 (mapc #'disable-theme custom-enabled-themes)
966 (load-theme 'doom-tomorrow-night t)
967 (sml/apply-theme 'automatic)
968 (font-lock-add-keywords
969 'org-mode a/org-mode-font-lock-keywords t))
970
971(bind-keys
972 ("s-t d" . a/lights-off)
973 ("s-t l" . a/lights-on))
974
975(use-package crux ; results in Waiting for git... [2 times]
976 :defer 0.4
977 :bind (("C-c b k" . crux-kill-other-buffers)
978 ("C-c d" . crux-duplicate-current-line-or-region)
979 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
980 ("C-c f c" . crux-copy-file-preserve-attributes)
981 ("C-c f d" . crux-delete-file-and-buffer)
982 ("C-c f r" . crux-rename-file-and-buffer)
983 ("C-c j" . crux-top-join-line)
984 ("C-S-j" . crux-top-join-line)))
985
986(use-package mwim
987 :bind (("C-a" . mwim-beginning-of-code-or-line)
988 ("C-e" . mwim-end-of-code-or-line)
989 ("<home>" . mwim-beginning-of-line-or-code)
990 ("<end>" . mwim-end-of-line-or-code)))
991
992(use-package projectile
993 :bind-keymap ("C-c P" . projectile-command-map)
994 :config
995 (projectile-mode)
996
997 (defun my-projectile-invalidate-cache (&rest _args)
998 ;; ignore the args to `magit-checkout'
999 (projectile-invalidate-cache nil))
1000
1001 (eval-after-load 'magit-branch
1002 '(progn
1003 (advice-add 'magit-checkout
1004 :after #'my-projectile-invalidate-cache)
1005 (advice-add 'magit-branch-and-checkout
1006 :after #'my-projectile-invalidate-cache)))
1007 :custom (projectile-completion-system 'ivy))
1008
1009(use-package helpful
1010 :defer 0.6
1011 :bind
1012 (("C-S-h c" . helpful-command)
1013 ("C-S-h f" . helpful-callable) ; helpful-function
1014 ("C-S-h v" . helpful-variable)
1015 ("C-S-h k" . helpful-key)
1016 ("C-S-h p" . helpful-at-point)))
1017
1018(use-package unkillable-scratch
1019 :defer 0.6
1020 :config
1021 (unkillable-scratch 1)
1022 :custom
1023 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1024
1025(use-package boxquote
1026 :defer 0.6
1027 :bind
1028 (:prefix-map a/boxquote-prefix-map
1029 :prefix "C-c q"
1030 ("b" . boxquote-buffer)
1031 ("B" . boxquote-insert-buffer)
1032 ("d" . boxquote-defun)
1033 ("F" . boxquote-insert-file)
1034 ("hf" . boxquote-describe-function)
1035 ("hk" . boxquote-describe-key)
1036 ("hv" . boxquote-describe-variable)
1037 ("hw" . boxquote-where-is)
1038 ("k" . boxquote-kill)
1039 ("p" . boxquote-paragraph)
1040 ("q" . boxquote-boxquote)
1041 ("r" . boxquote-region)
1042 ("s" . boxquote-shell-command)
1043 ("t" . boxquote-text)
1044 ("T" . boxquote-title)
1045 ("u" . boxquote-unbox)
1046 ("U" . boxquote-unbox-region)
1047 ("y" . boxquote-yank)
1048 ("M-q" . boxquote-fill-paragraph)
1049 ("M-w" . boxquote-kill-ring-save)))
1050
1051(use-package orgalist
1052 :disabled t
1053 :after message
1054 :hook (message-mode . orgalist-mode))
1055
1056(use-package typo
1057 :defer 0.5
1058 :config
1059 (typo-global-mode 1)
1060 :hook (text-mode . typo-mode))
1061
1062(use-package hl-todo
1063 :defer 0.5
1064 :config
1065 (global-hl-todo-mode))
1066
1067(use-package shrink-path
1068 :defer 0.5
1069 :after eshell
1070 :config
1071 (defvar user-@-host (concat (user-login-name) "@" (system-name) " "))
1072 (defun +eshell/prompt ()
1073 (let ((base/dir (shrink-path-prompt default-directory)))
1074 (concat (propertize user-@-host 'face 'default)
1075 (propertize (car base/dir)
1076 'face 'font-lock-comment-face)
1077 (propertize (cdr base/dir)
1078 'face 'font-lock-constant-face)
1079 (propertize "> " 'face 'default))))
1080 (setq eshell-prompt-regexp (concat user-@-host ".*> ")
1081 eshell-prompt-function #'+eshell/prompt))
1082
1083(use-package eshell-up
1084 :after eshell
1085 :commands eshell-up)
1086
1087(use-package multi-term
1088 :defer 0.6
1089 :bind (("C-c a s m" . multi-term-dedicated-toggle)
1090 :map term-mode-map
1091 ("C-c C-j" . term-char-mode)
1092 :map term-raw-map
1093 ("C-c C-j" . term-line-mode))
1094 :config
1095 (setq multi-term-program "/bin/screen"
1096 ;; TODO: add separate bindings for connecting to existing
1097 ;; session vs. always creating a new one
1098 multi-term-dedicated-select-after-open-p t
1099 multi-term-dedicated-window-height 20
1100 multi-term-dedicated-max-window-height 30
1101 term-bind-key-alist
1102 '(("C-c C-c" . term-interrupt-subjob)
1103 ("C-c C-e" . term-send-esc)
1104 ("C-k" . kill-line)
1105 ("C-y" . term-paste)
1106 ("M-f" . term-send-forward-word)
1107 ("M-b" . term-send-backward-word)
1108 ("M-p" . term-send-up)
1109 ("M-n" . term-send-down)
1110 ("<C-backspace>" . term-send-backward-kill-word)
1111 ("<M-DEL>" . term-send-backward-kill-word)
1112 ("M-d" . term-send-delete-word)
1113 ("M-," . term-send-raw)
1114 ("M-." . comint-dynamic-complete))
1115 term-unbind-key-alist
1116 '("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>")))
1117
1118(use-package page-break-lines
1119 :config
1120 (global-page-break-lines-mode))
1121
1122(use-package expand-region
1123 :bind ("C-=" . er/expand-region))
1124
1125(use-package multiple-cursors
1126 :bind
1127 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1128 (:prefix-map a/mc-prefix-map
1129 :prefix "C-c m"
1130 ("c" . mc/edit-lines)
1131 ("n" . mc/mark-next-like-this)
1132 ("p" . mc/mark-previous-like-this)
1133 ("a" . mc/mark-all-like-this))))
1134
1135(use-package forge
1136 :after magit
1137 :demand)
1138
1139(use-package yasnippet
1140 :defer 0.6
1141 :config
1142 (defconst yas-verbosity-cur yas-verbosity)
1143 (setq yas-verbosity 2)
1144 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets")
1145 (yas-reload-all)
1146 (setq yas-verbosity yas-verbosity-cur)
1147 :hook
1148 (text-mode . yas-minor-mode))
1149
1150(use-package debbugs
1151 :straight (debbugs
1152 :host github
1153 :repo "emacs-straight/debbugs"
1154 :files (:defaults "Debbugs.wsdl")))
1155
1156(use-package org-ref
1157 :init
1158 (a/setq-every '("~/usr/org/references.bib")
1159 reftex-default-bibliography
1160 org-ref-default-bibliography)
1161 (setq
1162 org-ref-bibliography-notes "~/usr/org/notes.org"
1163 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1164
1165(use-package slack
1166 :commands (slack-start)
1167 :init
1168 (eval-when-compile ; silence the byte-compiler
1169 (defvar url-http-data nil)
1170 (defvar url-http-extra-headers nil)
1171 (defvar url-http-method nil)
1172 (defvar url-callback-function nil)
1173 (defvar url-callback-arguments nil)
1174 (defvar oauth--token-data nil))
1175 (setq slack-buffer-emojify t
1176 slack-prefer-current-team t)
1177 :config
1178 (slack-register-team
1179 :name "nday-students"
1180 :default t
1181 :token nday-students-token
1182 :subscribed-channels '(general)
1183 :full-and-display-names t)
1184 (add-to-list 'swiper-font-lock-exclude 'slack-message-buffer-mode t)
1185 (setq lui-time-stamp-format "[%Y-%m-%d %H:%M:%S]"
1186 lui-time-stamp-only-when-changed-p t
1187 lui-time-stamp-position 'right)
1188 :bind
1189 (("C-c s s" . slack-start)
1190 ("C-c s u" . slack-select-unread-rooms)
1191 ("C-c s b" . slack-select-rooms)
1192 ("C-c s t" . slack-change-current-team)
1193 ("C-c s c" . slack-ws-close)
1194 :map slack-mode-map
1195 ("M-p" . slack-buffer-goto-prev-message)
1196 ("M-n" . slack-buffer-goto-next-message)
1197 ("C-c e" . slack-message-edit)
1198 ("C-c k" . slack-message-delete)
1199 ("C-c C-k" . slack-channel-leave)
1200 ("C-c r a" . slack-message-add-reaction)
1201 ("C-c r r" . slack-message-remove-reaction)
1202 ("C-c r s" . slack-message-show-reaction-users)
1203 ("C-c p l" . slack-room-pins-list)
1204 ("C-c p a" . slack-message-pins-add)
1205 ("C-c p r" . slack-message-pins-remove)
1206 ("@" . slack-message-embed-mention)
1207 ("#" . slack-message-embed-channel)))
1208
1209(use-package alert
1210 :commands (alert)
1211 :init
1212 (setq alert-default-style 'notifier))
1213
1214(defvar a/maildir (expand-file-name "~/mail/"))
1215(with-eval-after-load 'recentf
1216 (add-to-list 'recentf-exclude a/maildir))
1217
1218(setq
1219 a/gnus-init-file (no-littering-expand-etc-file-name "gnus")
1220 mail-user-agent 'gnus-user-agent
1221 read-mail-command 'gnus)
1222
1223(use-feature gnus
1224 :bind (("s-m" . gnus)
1225 ("s-M" . gnus-unplugged))
1226 :init
1227 (setq
1228 gnus-select-method '(nnnil "")
1229 gnus-secondary-select-methods
1230 '((nnimap "amin"
1231 (nnimap-stream plain)
1232 (nnimap-address "127.0.0.1")
1233 (nnimap-server-port 143)
1234 (nnimap-authenticator plain)
1235 (nnimap-user "amin@bndl.org"))
1236 (nnimap "uwaterloo"
1237 (nnimap-stream plain)
1238 (nnimap-address "127.0.0.1")
1239 (nnimap-server-port 143)
1240 (nnimap-authenticator plain)
1241 (nnimap-user "abandali@uwaterloo.ca"))
1242 (nnimap "csclub"
1243 (nnimap-stream plain)
1244 (nnimap-address "127.0.0.1")
1245 (nnimap-server-port 143)
1246 (nnimap-authenticator plain)
1247 (nnimap-user "abandali@csclub.uw")))
1248 gnus-message-archive-group "nnimap+amin:Sent"
1249 gnus-parameters
1250 '(("gnu\\.deepspec"
1251 (to-address . "deepspec@lists.cs.princeton.edu")
1252 (to-list . "deepspec@lists.cs.princeton.edu"))
1253 ("gnu\\.emacs-devel"
1254 (to-address . "emacs-devel@gnu.org")
1255 (to-list . "emacs-devel@gnu.org"))
1256 ("gnu\\.emacs-orgmode"
1257 (to-address . "emacs-orgmode@gnu.org")
1258 (to-list . "emacs-orgmode@gnu.org"))
1259 ("gnu\\.emacsconf-discuss"
1260 (to-address . "emacsconf-discuss@gnu.org")
1261 (to-list . "emacsconf-discuss@gnu.org"))
1262 ("gnu\\.fencepost-users"
1263 (to-address . "fencepost-users@gnu.org")
1264 (to-list . "fencepost-users@gnu.org"))
1265 ("gnu\\.gnunet-developers"
1266 (to-address . "gnunet-developers@gnu.org")
1267 (to-list . "gnunet-developers@gnu.org"))
1268 ("gnu\\.guile-devel"
1269 (to-address . "guile-devel@gnu.org")
1270 (to-list . "guile-devel@gnu.org"))
1271 ("gnu\\.guix-devel"
1272 (to-address . "guix-devel@gnu.org")
1273 (to-list . "guix-devel@gnu.org"))
1274 ("gnu\\.haskell-art"
1275 (to-address . "haskell-art@we.lurk.org")
1276 (to-list . "haskell-art@we.lurk.org"))
1277 ("gnu\\.haskell-cafe"
1278 (to-address . "haskell-cafe@haskell.org")
1279 (to-list . "haskell-cafe@haskell.org"))
1280 ("gnu\\.help-gnu-emacs"
1281 (to-address . "help-gnu-emacs@gnu.org")
1282 (to-list . "help-gnu-emacs@gnu.org"))
1283 ("gnu\\.info-gnu-emacs"
1284 (to-address . "info-gnu-emacs@gnu.org")
1285 (to-list . "info-gnu-emacs@gnu.org"))
1286 ("gnu\\.info-guix"
1287 (to-address . "info-guix@gnu.org")
1288 (to-list . "info-guix@gnu.org"))
1289 ("gnu\\.notmuch"
1290 (to-address . "notmuch@notmuchmail.org")
1291 (to-list . "notmuch@notmuchmail.org"))
1292 ("gnu\\.parabola-dev"
1293 (to-address . "dev@lists.parabola.nu")
1294 (to-list . "dev@lists.parabola.nu"))
1295 ("gnu\\.webmasters"
1296 (to-address . "webmasters@gnu.org")
1297 (to-list . "webmasters@gnu.org"))
1298 ("gnu\\.www-commits"
1299 (to-address . "www-commits@gnu.org")
1300 (to-list . "www-commits@gnu.org"))
1301 ("gnu\\.www-discuss"
1302 (to-address . "www-discuss@gnu.org")
1303 (to-list . "www-discuss@gnu.org"))
1304 ("gnu\\.~bandali\\.public-inbox"
1305 (to-address . "~bandali/public-inbox@lists.sr.ht")
1306 (to-list . "~bandali/public-inbox@lists.sr.ht"))
1307 ("gnu\\.~sircmpwn\\.srht-admins"
1308 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
1309 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
1310 ("gnu\\.~sircmpwn\\.srht-announce"
1311 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
1312 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
1313 ("gnu\\.~sircmpwn\\.srht-dev"
1314 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
1315 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
1316 ("gnu\\.~sircmpwn\\.srht-discuss"
1317 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
1318 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1319 ("gnu.*"
1320 (gcc-self . t))
1321 ("gnu\\."
1322 (subscribed . t)))
1323 gnus-large-newsgroup 50
1324 gnus-home-directory (no-littering-expand-var-file-name "gnus/")
1325 gnus-directory (concat gnus-home-directory "news/")
1326 message-directory (concat gnus-home-directory "mail/")
1327 nndraft-directory (concat gnus-home-directory "drafts/")
1328 gnus-save-newsrc-file nil
1329 gnus-read-newsrc-file nil
1330 gnus-interactive-exit nil
1331 gnus-gcc-mark-as-read t)
1332 :config
1333 (require 'ebdb)
1334 (require 'ebdb-mua)
1335 (require 'ebdb-gnus)
1336
1337 (with-eval-after-load 'recentf
1338 (add-to-list 'recentf-exclude gnus-home-directory)))
1339
1340(use-feature gnus-art
1341 :config
1342 (setq
1343 gnus-visible-headers
1344 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1345 gnus-sorted-header-list
1346 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1347 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1348 "^Newsgroups:" "List-Id:" "^Organization:"
1349 "^User-Agent:" "^Date:")
1350 ;; local-lapsed article dates
1351 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1352 gnus-article-date-headers '(user-defined)
1353 gnus-article-time-format
1354 (lambda (time)
1355 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1356 (local (article-make-date-line date 'local))
1357 (combined-lapsed (article-make-date-line date
1358 'combined-lapsed))
1359 (lapsed (progn
1360 (string-match " (.+" combined-lapsed)
1361 (match-string 0 combined-lapsed))))
1362 (concat local lapsed))))
1363 (bind-keys
1364 :map gnus-article-mode-map
1365 ("M-L" . org-store-link)))
1366
1367(use-feature gnus-sum
1368 :bind (:map gnus-summary-mode-map
1369 :prefix-map a/gnus-summary-prefix-map
1370 :prefix "v"
1371 ("r" . gnus-summary-reply)
1372 ("w" . gnus-summary-wide-reply)
1373 ("v" . gnus-summary-show-raw-article))
1374 :config
1375 (bind-keys
1376 :map gnus-summary-mode-map
1377 ("M-L" . org-store-link))
1378 :hook (gnus-summary-mode . a/no-mouse-autoselect-window))
1379
1380(use-feature gnus-msg
1381 :config
1382 (setq gnus-posting-styles
1383 '((".*"
1384 (address "amin@bndl.org")
1385 (body "\nBest,\n")
1386 (eval (setq a/message-cite-say-hi t)))
1387 ("gnu.*"
1388 (address "bandali@gnu.org")
1389 (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org")))
1390 ((header "subject" "ThankCRM")
1391 (to "webmasters-comment@gnu.org")
1392 (body "Added to 2019supporters.html.\n\nMoving to campaigns.\n\n-amin\n")
1393 (eval (setq a/message-cite-say-hi nil)))
1394 ("nnimap\\+uwaterloo:.*"
1395 (address "abandali@uwaterloo.ca")
1396 (gcc "\"nnimap+uwaterloo:Sent Items\""))
1397 ("nnimap\\+csclub:.*"
1398 (address "abandali@csclub.uwaterloo.ca")
1399 (gcc "nnimap+csclub:Sent")))))
1400
1401(use-feature gnus-topic
1402 :hook (gnus-group-mode . gnus-topic-mode)
1403 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
1404
1405(use-feature gnus-agent
1406 :config
1407 (setq gnus-agent-synchronize-flags 'ask)
1408 :hook (gnus-group-mode . gnus-agent-mode))
1409
1410(use-feature gnus-group
1411 :config
1412 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
1413
1414(use-feature mm-decode
1415 :config
1416 (setq mm-discouraged-alternatives '("text/html" "text/richtext")))
1417
1418(use-feature sendmail
1419 :config
1420 (setq sendmail-program "/usr/bin/msmtp"
1421 ;; message-sendmail-extra-arguments '("-v" "-d")
1422 mail-specify-envelope-from t
1423 mail-envelope-from 'header))
1424
1425(use-feature message
1426 :config
1427 ;; redefine for a simplified In-Reply-To header
1428 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
1429 (defun message-make-in-reply-to ()
1430 "Return the In-Reply-To header for this message."
1431 (when message-reply-headers
1432 (let ((from (mail-header-from message-reply-headers))
1433 (msg-id (mail-header-id message-reply-headers)))
1434 (when from
1435 msg-id))))
1436
1437 (defconst a/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
1438 (defconst message-cite-style-bandali
1439 '((message-cite-function 'message-cite-original)
1440 (message-citation-line-function 'message-insert-formatted-citation-line)
1441 (message-cite-reply-position 'traditional)
1442 (message-yank-prefix "> ")
1443 (message-yank-cited-prefix ">")
1444 (message-yank-empty-prefix ">")
1445 (message-citation-line-format
1446 (if a/message-cite-say-hi
1447 (concat "Hi %F,\n\n" a/message-cite-style-format)
1448 a/message-cite-style-format)))
1449 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
1450 (setq ;; message-cite-style 'message-cite-style-bandali
1451 message-kill-buffer-on-exit t
1452 message-send-mail-function 'message-send-mail-with-sendmail
1453 message-sendmail-envelope-from 'header
1454 message-subscribed-address-functions
1455 '(gnus-find-subscribed-addresses)
1456 message-dont-reply-to-names
1457 "\\(\\(amin@bndl\\.org\\)\\|\\(.*@\\(aminb\\|amin\\.bndl\\)\\.org\\)\\|\\(\\(bandali\\|aminb?\\|mab\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
1458 (require 'company-ebdb)
1459 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
1460 (message-mode . flyspell-mode)
1461 (message-mode . (lambda ()
1462 ;; (setq fill-column 65
1463 ;; message-fill-column 65)
1464 (make-local-variable 'company-idle-delay)
1465 (setq company-idle-delay 0.2))))
1466 ;; :custom-face
1467 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
1468 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
1469 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
1470 )
1471
1472(with-eval-after-load 'mml-sec
1473 (setq mml-secure-openpgp-encrypt-to-self t
1474 mml-secure-openpgp-sign-with-sender t))
1475
1476(use-feature footnote
1477 :after message
1478 ;; :config
1479 ;; (setq footnote-start-tag ""
1480 ;; footnote-end-tag ""
1481 ;; footnote-style 'unicode)
1482 :bind
1483 (:map message-mode-map
1484 :prefix-map a/footnote-prefix-map
1485 :prefix "C-c f"
1486 ("a" . footnote-add-footnote)
1487 ("b" . footnote-back-to-message)
1488 ("c" . footnote-cycle-style)
1489 ("d" . footnote-delete-footnote)
1490 ("g" . footnote-goto-footnote)
1491 ("r" . footnote-renumber-footnotes)
1492 ("s" . footnote-set-style)))
1493
1494(use-package ebdb
1495 :straight (:host github :repo "girzel/ebdb")
1496 :after gnus
1497 :bind (:map gnus-group-mode-map ("e" . ebdb))
1498 :config
1499 (setq ebdb-sources (no-littering-expand-var-file-name "ebdb"))
1500 (with-eval-after-load 'swiper
1501 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
1502
1503(use-feature ebdb-com
1504 :after ebdb)
1505
1506;; (use-package ebdb-complete
1507;; :after ebdb
1508;; :config
1509;; (ebdb-complete-enable))
1510
1511(use-package company-ebdb
1512 :config
1513 (defun company-ebdb--post-complete (_) nil))
1514
1515(use-feature ebdb-gnus
1516 :after ebdb
1517 :custom
1518 (ebdb-gnus-window-configuration
1519 '(article
1520 (vertical 1.0
1521 (summary 0.25 point)
1522 (horizontal 1.0
1523 (article 1.0)
1524 (ebdb-gnus 0.3))))))
1525
1526(use-feature ebdb-mua
1527 :after ebdb
1528 ;; :custom (ebdb-mua-pop-up nil)
1529 )
1530
1531;; (use-package ebdb-message
1532;; :after ebdb)
1533
1534
1535;; (use-package ebdb-vcard
1536;; :after ebdb)
1537
1538(use-package message-x)
1539
1540(use-package znc
1541 :straight (:host nil :repo "https://git.bndl.org/amin/znc.el")
1542 :bind (("C-c a e e" . znc-erc)
1543 ("C-c a e a" . znc-all))
1544 :config
1545 (let ((pwd (let ((auth (auth-source-search :host "znca")))
1546 (cond
1547 ((null auth) (error "Couldn't find znca's authinfo"))
1548 (t (funcall (plist-get (car auth) :secret)))))))
1549 (setq znc-servers
1550 `(("znc.bndl.org" 1337 t
1551 ((freenode "amin/freenode" ,pwd)))
1552 ("znc.bndl.org" 1337 t
1553 ((moznet "amin/moznet" ,pwd)))))))
1554
1555(message "Loading %s...done (%.3fs)" user-init-file
1556 (float-time (time-subtract (current-time)
1557 a/before-user-init-time)))
1558
1559;;; init.el ends here