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