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