1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org>
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.
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.
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/>.
20 ;; GNU Emacs configuration of Amin Bandali, computer scientist,
21 ;; Free Software activist, and GNU maintainer & webmaster. Packages
22 ;; are installed through using Borg for a fully reproducible setup.
24 ;; Over the years, I've taken inspiration from configurations of many
25 ;; great people. Some that I can remember off the top of my head are:
27 ;; - https://github.com/dieggsy/dotfiles
28 ;; - https://github.com/dakra/dmacs
29 ;; - http://pages.sachachua.com/.emacs.d/Sacha.html
30 ;; - https://github.com/dakrone/eos
31 ;; - http://doc.rix.si/cce/cce.html
32 ;; - https://github.com/jwiegley/dot-emacs
33 ;; - https://github.com/wasamasa/dotemacs
34 ;; - https://github.com/hlissner/doom-emacs
38 ;;; Emacs initialization
40 (defvar b
/before-user-init-time
(current-time)
41 "Value of `current-time' when Emacs begins loading `user-init-file'.")
42 (defvar b
/emacs-initialized nil
43 "Whether Emacs has been initialized.")
44 (defvar b
/exwm-p
(string= (system-name) "chaman")
45 "Whether or not we will be using `exwm'.")
47 (when (not (bound-and-true-p b
/emacs-initialized
))
48 (message "Loading Emacs...done (%.3fs)"
49 (float-time (time-subtract b
/before-user-init-time
52 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
53 ;; during startup to reduce garbage collection frequency. clearing
54 ;; `file-name-handler-alist' seems to help reduce startup time too.
55 (defvar b
/gc-cons-threshold gc-cons-threshold
)
56 (defvar b
/gc-cons-percentage gc-cons-percentage
)
57 (defvar b
/file-name-handler-alist file-name-handler-alist
)
58 (setq gc-cons-threshold
(* 30 1024 1024) ; 30 MiB
59 gc-cons-percentage
0.6
60 file-name-handler-alist nil
61 ;; sidesteps a bug when profiling with esup
62 esup-child-profile-require-level
0)
64 ;; set them back to their defaults once we're done initializing
66 "My post-initialize function, run after loading `user-init-file'."
67 (setq b
/emacs-initialized t
68 gc-cons-threshold b
/gc-cons-threshold
69 gc-cons-percentage b
/gc-cons-percentage
70 file-name-handler-alist b
/file-name-handler-alist
)
72 (with-eval-after-load 'exwm-workspace
79 "[%s]" (number-to-string
80 exwm-workspace-current-index
)))))))))
81 (add-hook 'after-init-hook
#'b
/post-init
)
83 ;; increase number of lines kept in *Messages* log
84 (setq message-log-max
20000)
86 ;; optionally, uncomment to supress some byte-compiler warnings
87 ;; (see C-h v byte-compile-warnings RET for more info)
88 ;; (setq byte-compile-warnings
89 ;; '(not free-vars unresolved noruntime lexical make-local))
94 (setq user-full-name
"Amin Bandali"
95 user-mail-address
"bandali@gnu.org")
100 ;; useful for commenting out multiple sexps at a time
101 (defmacro comment
(&rest _
)
102 "Comment out one or more s-expressions."
103 (declare (indent defun
))
107 ;;; Package management
110 (add-to-list 'load-path
111 (expand-file-name "lib/borg" user-emacs-directory
))
114 (setq borg-rewrite-urls-alist
115 '(("git@github.com:" .
"https://github.com/")
116 ("git@gitlab.com:" .
"https://gitlab.com/"))))
119 (if nil
; set to t when need to debug init
121 (setq use-package-verbose t
122 use-package-expand-minimally nil
123 use-package-compute-statistics t
125 (require 'use-package
))
126 (setq use-package-verbose nil
127 use-package-expand-minimally t
))
129 (setq use-package-always-defer t
)
135 ;; keep ~/.emacs.d clean
136 (use-package no-littering
139 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
140 (defalias 'b
/var
'no-littering-expand-var-file-name
))
142 (use-package auto-compile
145 (auto-compile-on-load-mode)
146 (auto-compile-on-save-mode)
147 (setq auto-compile-display-buffer nil
)
148 (setq auto-compile-mode-line-counter t
)
149 (setq auto-compile-source-recreate-deletes-dest t
)
150 (setq auto-compile-toggle-deletes-nonlib-dest t
)
151 (setq auto-compile-update-autoloads t
))
153 ;; separate custom file (don't want it mixing with init.el)
157 (setq custom-file
(b/etc
"custom.el"))
158 (when (file-exists-p custom-file
)
160 ;; while at it, treat themes as safe
161 (setf custom-safe-themes t
)
162 ;; only one custom theme at a time
164 (defadvice load-theme
(before clear-previous-themes activate
)
165 "Clear existing theme settings instead of layering them"
166 (mapc #'disable-theme custom-enabled-themes
))))
168 ;; load the secrets file if it exists, otherwise show a warning
171 (load (b/etc
"secrets"))))
173 ;; start up emacs server. see
174 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
177 :config
(or (server-running-p) (server-mode)))
182 (defmacro b
/setq-every
(value &rest vars
)
183 "Set all the variables from VARS to value VALUE."
184 (declare (indent defun
) (debug t
))
185 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
187 (defun b/start-process
(program &rest args
)
188 "Same as `start-process', but doesn't bother about name and buffer."
189 (let ((process-name (concat program
"_process"))
190 (buffer-name (generate-new-buffer-name
191 (concat program
"_output"))))
192 (apply #'start-process
193 process-name buffer-name program args
)))
195 (defun b/dired-start-process
(program &optional args
)
196 "Open current file with a PROGRAM."
197 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
198 ;; be nil, so remove it).
199 (apply #'b
/start-process
201 (remove nil
(list args
(dired-get-file-for-visit)))))
203 (defun b/add-elisp-section
()
207 (insert "\n\f\n;;; "))
209 ;; (defvar b/fill-column 47
210 ;; "My custom `fill-column'.")
212 (defconst b
/asterism
"* * *")
214 (defun b/insert-asterism
()
215 "Insert a centred asterism."
220 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
225 (defun b/no-mouse-autoselect-window
()
226 "Conveniently disable `focus-follows-mouse'.
227 For disabling the behaviour for certain buffers and/or modes."
228 (make-local-variable 'mouse-autoselect-window
)
229 (setq mouse-autoselect-window nil
))
231 (defun b/kill-current-buffer
()
232 "Kill the current buffer."
233 ;; also see https://redd.it/64xb3q
235 (kill-buffer (current-buffer)))
240 ;;;; C-level customizations
244 enable-recursive-minibuffers t
245 resize-mini-windows t
246 ;; more useful frame titles
247 frame-title-format
'("" invocation-name
" - "
249 (if (buffer-file-name)
250 (abbreviate-file-name (buffer-file-name))
252 ;; i don't feel like jumping out of my chair every now and again; so
253 ;; don't BEEP! at me, emacs
254 ring-bell-function
'ignore
257 ;; scroll-conservatively 10000
259 scroll-conservatively
10
260 scroll-preserve-screen-position
1
261 ;; focus follows mouse
262 mouse-autoselect-window t
)
265 ;; always use space for indentation
273 (dolist (ft (fontset-list))
277 (font-spec :name
"Source Code Pro" :size
14))
281 (font-spec :name
"DejaVu Sans Mono")
288 ;; :name "Symbola monospacified for DejaVu Sans Mono")
294 ;; (font-spec :name "DejaVu Sans Mono")
300 (font-spec :name
"DejaVu Sans Mono" :size
14)
304 ;;;; Elisp-level customizations
310 ;; don't need to see the startup echo area message
311 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
313 ;; i want *scratch* as my startup buffer
314 (initial-buffer-choice t
)
315 ;; i don't need the default hint
316 (initial-scratch-message nil
)
317 ;; use customizable text-mode as major mode for *scratch*
318 ;; (initial-major-mode 'text-mode)
319 ;; inhibit buffer list when more than 2 files are loaded
320 (inhibit-startup-buffer-menu t
)
321 ;; don't need to see the startup screen or echo area message
322 (inhibit-startup-screen t
)
323 (inhibit-startup-echo-area-message user-login-name
))
329 ;; backups (C-h v make-backup-files RET)
330 (backup-by-copying t
)
332 (delete-old-versions t
)
335 (auto-save-file-name-transforms
336 `((".*" ,(b/var
"auto-save/") t
)))
338 ;; insert newline at the end of files
339 (require-final-newline t
)
341 ;; open read-only file buffers in view-mode
342 ;; (enables niceties like `q' for quit)
345 ;; disable disabled commands
346 (setq disabled-command-function nil
)
348 ;; lazy-person-friendly yes/no prompts
349 (defalias 'yes-or-no-p
#'y-or-n-p
)
351 ;; enable automatic reloading of changed buffers and files
352 (use-package autorevert
355 (global-auto-revert-mode 1)
357 (auto-revert-verbose nil
)
358 (global-auto-revert-non-file-buffers nil
))
360 ;; time and battery in mode-line
366 (display-time-default-load-average nil
)
367 (display-time-format " %a %b %-e %-l:%M%P")
368 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
369 (display-time-use-mail-icon t
))
374 (display-battery-mode)
376 (battery-mode-line-format "%p%% %t"))
382 ;; (fringe-mode '(3 . 1))
388 ;; enable winner-mode (C-h f winner-mode RET)
393 ;; don't display *compilation* buffer on success. based on
394 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
395 ;; instead of the now obsolete `flet'.
396 (defun b/compilation-finish-function
(buffer outstr
)
397 (unless (string-match "finished" outstr
)
398 (switch-to-buffer-other-window buffer
))
401 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
405 (defadvice compilation-start
406 (around inhibit-display
407 (command &optional mode name-function highlight-regexp
))
408 (if (not (string-match "^\\(find\\|grep\\)" command
))
409 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
410 (save-window-excursion ad-do-it
))
412 (ad-activate 'compilation-start
))
416 ;; allow scrolling in Isearch
417 (isearch-allow-scroll t
)
418 ;; search for non-ASCII characters: i’d like non-ASCII characters such
419 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
420 ;; counterpart. shoutout to
421 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
422 (search-default-mode #'char-fold-to-regexp
))
424 ;; uncomment to extend the above behaviour to query-replace
428 (replace-char-fold t
)))
431 :bind
("C-x v C-=" . vc-ediff
))
436 (vc-git-print-log-follow t
))
439 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
440 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
441 (ediff-split-window-function 'split-window-horizontally
)))
443 (use-package face-remap
445 ;; gentler font resizing
446 (text-scale-mode-step 1.05))
451 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
452 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
453 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
455 (use-package pixel-scroll
457 :config
(pixel-scroll-mode 1))
459 (use-package epg-config
461 ;; ask for GPG passphrase in minibuffer
462 ;; this will fail if gpg>=2.1 is not available
463 (setq epg-pinentry-mode
'loopback
)
465 (epg-gpg-program (executable-find "gpg")))
470 (use-package pinentry
473 :after
(epa epg server
)
475 ;; workaround for systemd-based distros:
476 ;; (setq pinentry--socket-dir server-socket-dir)
479 (use-package auth-source
481 (auth-sources '("~/.authinfo.gpg"))
482 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
490 ("C-c e b" . eval-buffer
)
491 ("C-c e e" . eval-last-sexp
)
492 ("C-c e r" . eval-region
)
494 ("C-c e i" . emacs-init-time
)
495 ("C-c e u" . emacs-uptime
)
496 ("C-c e v" . emacs-version
)
498 ("C-c f ." . find-file
)
499 ("C-c f d" . find-name-dired
)
500 ("C-c f l" . find-library
)
502 ("C-c F m" . make-frame-command
)
503 ("C-c F d" . delete-frame
)
504 ("C-c F D" . server-edit
)
506 ("C-S-h C" . describe-char
)
507 ("C-S-h F" . describe-face
)
509 ("C-c x" . execute-extended-command
)
511 ("C-x k" . b
/kill-current-buffer
)
512 ("C-x K" . kill-buffer
)
513 ("C-x s" . save-buffer
)
514 ("C-x S" . save-some-buffers
)
516 :map emacs-lisp-mode-map
517 ("<C-return>" . b
/add-elisp-section
))
519 (when (display-graphic-p)
520 (unbind-key "C-z" global-map
))
523 ;; for back and forward mouse keys
524 ("<XF86Back>" . previous-buffer
)
525 ("<mouse-8>" . previous-buffer
)
526 ;; ("<drag-mouse-8>" . previous-buffer)
527 ("<XF86Forward>" . next-buffer
)
528 ("<mouse-9>" . next-buffer
)
529 ;; ("<drag-mouse-9>" . next-buffer)
530 ;; ("<drag-mouse-2>" . kill-this-buffer)
531 ;; ("<drag-mouse-3>" . switch-to-buffer)
535 ;;; Essential packages
540 (convert-standard-filename "lisp") user-emacs-directory
))
543 (require 'bandali-exwm
))
545 (require 'bandali-org
)
547 ;; *the* right way to do git
549 :bind
(("C-x g" . magit-status
)
550 ("C-c g g" . magit-status
)
551 ("C-c g b" . magit-blame-addition
)
552 ("C-c g l" . magit-log-buffer-file
))
554 (magit-add-section-hook 'magit-status-sections-hook
555 'magit-insert-modules
556 'magit-insert-stashes
558 ;; (magit-add-section-hook 'magit-status-sections-hook
559 ;; 'magit-insert-ignored-files
560 ;; 'magit-insert-untracked-files
562 (setq magit-repository-directories
'(("~/.emacs.d/" .
0)
564 (nconc magit-section-initial-visibility-alist
565 '(([unpulled status
] . show
)
566 ([unpushed status
] . show
)))
568 (magit-diff-refine-hunk t
)
569 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
570 ;; (magit-completing-read-function 'magit-ido-completing-read)
571 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
573 ;; recently opened files
577 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
581 (recentf-max-saved-items 2000))
583 ;; needed for history for counsel
589 ;; (require 'bandali-ido)
590 (require 'bandali-ivy
)
592 (require 'bandali-eshell
)
594 (require 'bandali-ibuffer
)
598 :hook
(prog-mode . outline-minor-mode
)
601 outline-minor-mode-map
602 ("<s-tab>" . outline-toggle-children
)
603 ("M-p" . outline-previous-visible-heading
)
604 ("M-n" . outline-next-visible-heading
)
605 :prefix-map b
/outline-prefix-map
607 ("TAB" . outline-toggle-children
)
608 ("a" . outline-hide-body
)
609 ("H" . outline-hide-body
)
610 ("S" . outline-show-all
)
611 ("h" . outline-hide-subtree
)
612 ("s" . outline-show-subtree
)))
616 :custom
(ls-lisp-dirs-first t
))
618 (require 'bandali-dired
)
622 (temp-buffer-resize-mode)
623 (setq help-window-select t
))
627 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
628 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
629 (add-to-list 'tramp-default-proxies-alist
630 (list (regexp-quote (system-name)) nil nil
)))
632 (use-package doc-view
633 :bind
(:map doc-view-mode-map
634 ("M-RET" . image-previous-line
)))
639 ;; highlight uncommitted changes in the left fringe
643 (setq diff-hl-draw-borders nil
)
644 (global-diff-hl-mode)
645 :hook
(magit-post-refresh . diff-hl-magit-post-refresh
))
647 ;; display Lisp objects at point in the echo area
649 :when
(version< "25" emacs-version
)
650 :config
(global-eldoc-mode))
652 ;; highlight matching parens
655 :config
(show-paren-mode))
657 (use-package elec-pair
659 :config
(electric-pair-mode))
662 :config
(column-number-mode)
664 ;; Save what I copy into clipboard from other applications into Emacs'
665 ;; kill-ring, which would allow me to still be able to easily access
666 ;; it in case I kill (cut or copy) something else inside Emacs before
667 ;; yanking (pasting) what I'd originally intended to.
668 (save-interprogram-paste-before-kill t
))
670 ;; save minibuffer history
671 (use-package savehist
675 (add-to-list 'savehist-additional-variables
'kill-ring
))
677 ;; automatically save place in files
678 (use-package saveplace
679 :when
(version< "25" emacs-version
)
680 :config
(save-place-mode))
682 (use-package prog-mode
683 :config
(global-prettify-symbols-mode)
684 (defun indicate-buffer-boundaries-left ()
685 (setq indicate-buffer-boundaries
'left
))
686 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
688 (use-package text-mode
689 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
690 :hook
((text-mode . indicate-buffer-boundaries-left
)
691 (text-mode . flyspell-mode
)))
693 (use-package conf-mode
702 (:map company-active-map
703 ([tab] . company-complete-common-or-cycle)
704 ([escape] . company-abort)
705 ("C-p" . company-select-previous-or-abort)
706 ("C-n" . company-select-next-or-abort))
708 (company-minimum-prefix-length 1)
709 (company-selection-wrap-around t)
710 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
711 (company-dabbrev-downcase nil)
712 (company-dabbrev-ignore-case nil)
714 ;; (global-company-mode t)
717 (use-package flycheck
719 :hook (prog-mode . flycheck-mode)
721 (:map flycheck-mode-map
722 ("M-P" . flycheck-previous-error)
723 ("M-N" . flycheck-next-error))
725 ;; Use the load-path from running Emacs when checking elisp files
726 (setq flycheck-emacs-lisp-load-path 'inherit)
728 ;; Only flycheck when I actually save the buffer
729 (setq flycheck-check-syntax-automatically '(mode-enabled save))
730 :custom (flycheck-mode-line-prefix "flyc"))
732 (use-package flyspell)
734 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
738 ;; ’ can be part of a word
739 (setq ispell-local-dictionary-alist
740 `((nil "[[:alpha:]]" "[^[:alpha:]]"
741 "['\x2019]" nil ("-B") nil utf-8))
742 ispell-program-name (executable-find "hunspell"))
743 ;; don't send ’ to the subprocess
744 (defun endless/replace-apostrophe (args)
745 (cons (replace-regexp-in-string
748 (advice-add #'ispell-send-string :filter-args
749 #'endless/replace-apostrophe)
751 ;; convert ' back to ’ from the subprocess
752 (defun endless/replace-quote (args)
753 (if (not (derived-mode-p 'org-mode))
755 (cons (replace-regexp-in-string
758 (advice-add #'ispell-parse-output :filter-args
759 #'endless/replace-quote))
762 :hook (text-mode . abbrev-mode))
765 ;;; Programming modes
767 (use-package lisp-mode
769 (defun indent-spaces-mode ()
770 (setq indent-tabs-mode nil))
771 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
774 :hook (emacs-lisp-mode . reveal-mode))
776 (use-package elisp-mode)
778 ;; (use-package alloy-mode
779 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
780 ;; :mode "\\.\\(als\\|dsh\\)\\'"
782 ;; (setq alloy-basic-offset 2)
783 ;; ;; (defun b/alloy-simple-indent (start end)
784 ;; ;; (interactive "r")
785 ;; ;; ;; (if (region-active-p)
786 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
788 ;; ;; ;; (indent-rigidly (line-beginning-position)
789 ;; ;; ;; (line-end-position)
790 ;; ;; ;; alloy-basic-offset)))
791 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
792 ;; :bind (:map alloy-mode-map
793 ;; ("RET" . electric-newline-and-maybe-indent)
794 ;; ;; ("TAB" . b/alloy-simple-indent)
795 ;; ("TAB" . indent-for-tab-command))
796 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
798 (eval-when-compile (defvar lean-mode-map))
799 (use-package lean-mode
801 :bind (:map lean-mode-map
802 ("S-SPC" . company-complete))
804 (require 'lean-input)
805 (setq default-input-method "Lean"
806 lean-input-tweak-all '(lean-input-compose
807 (lean-input-prepend "/")
808 (lean-input-nonempty))
809 lean-input-user-translations '(("/" "/")))
812 (use-package mhtml-mode)
814 (use-package sgml-mode
816 (setq sgml-basic-offset 0))
818 (use-package css-mode
820 (setq css-indent-offset 2))
822 (use-package emmet-mode
823 :after (:any mhtml-mode css-mode sgml-mode)
824 :bind* (("C-)" . emmet-next-edit-point)
825 ("C-(" . emmet-prev-edit-point))
827 (unbind-key "C-j" emmet-mode-keymap)
828 (setq emmet-move-cursor-between-quotes t)
829 :hook (css-mode html-mode sgml-mode))
833 (use-package geiser-guile
835 (setq geiser-guile-load-path "~/src/git/guix"))
842 (font-latex-fontify-sectioning 'color)))
849 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
851 (use-package tex-mode
854 (lambda (p) (string-match "^---?" (car p)))
855 tex--prettify-symbols-alist)
856 :hook ((tex-mode . auto-fill-mode)
857 (tex-mode . flyspell-mode)))
859 ;; (use-package george-mode
860 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
861 ;; :mode "\\.grg\\'")
866 (add-to-list 'custom-theme-load-path
868 (convert-standard-filename "lisp") user-emacs-directory))
869 (load-theme 'tangomod t)
871 (use-package smart-mode-line
872 :commands (sml/apply-theme)
875 ;; thanks, but no thnaks; don't make fixed-width fills.
876 (defun sml/fill-for-buffer-identification () "")
877 (setq sml/theme 'tangomod)
879 (smart-mode-line-enable))
881 (use-package doom-modeline
884 :hook (after-init . doom-modeline-init)
886 (doom-modeline-buffer-file-name-style 'relative-to-project))
888 (use-package doom-themes)
894 (setq x-underline-at-descent-line t)
895 (let ((line (face-attribute 'mode-line :underline)))
896 (set-face-attribute 'mode-line nil :overline line)
897 (set-face-attribute 'mode-line-inactive nil :overline line)
898 (set-face-attribute 'mode-line-inactive nil :underline line)
899 (set-face-attribute 'mode-line nil :box nil)
900 (set-face-attribute 'mode-line-inactive nil :box nil)
901 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
902 (moody-replace-mode-line-buffer-identification)
903 (moody-replace-vc-mode))
905 (use-package mini-modeline
908 :config (mini-modeline-mode))
910 (defvar b/org-mode-font-lock-keywords
911 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
912 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
913 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
914 (4 '(:foreground "#c5c8c6") t))) ; title
915 "For use with the `doom-tomorrow-night' theme.")
917 (defun b/lights-on ()
918 "Enable my favourite light theme."
920 (mapc #'disable-theme custom-enabled-themes)
921 (load-theme 'tangomod t)
922 (when (featurep 'smart-mode-line)
923 (sml/apply-theme 'tangomod))
924 (font-lock-remove-keywords
925 'org-mode b/org-mode-font-lock-keywords)
926 (when (featurep 'erc-hl-nicks)
927 (erc-hl-nicks-reset-face-table))
928 (when (featurep 'exwm-systemtray)
929 (exwm-systemtray--refresh)))
931 (defun b/lights-off ()
934 (mapc #'disable-theme custom-enabled-themes)
935 (load-theme 'doom-one t)
936 (when (featurep 'smart-mode-line)
937 (sml/apply-theme 'automatic))
938 (font-lock-add-keywords
939 'org-mode b/org-mode-font-lock-keywords t)
940 (when (featurep 'erc-hl-nicks)
941 (erc-hl-nicks-reset-face-table))
942 (when (featurep 'exwm-systemtray)
943 (exwm-systemtray--refresh)))
946 ("C-c t d" . b/lights-off)
947 ("C-c t l" . b/lights-on))
950 ;;; Emacs enhancements & auxiliary packages
953 :config (setq Man-width 80))
955 (use-package which-key
958 (which-key-add-key-based-replacements
959 ;; prefixes for global prefixes and minor modes
962 "C-x RET" "coding system"
964 "C-x @" "event modifiers"
965 "C-x a" "abbrev/expand"
966 "C-x r" "rectangle/register/bookmark"
968 "C-x v" "version control"
972 ;; prefixes for my personal bindings
974 "C-c a" "applications"
979 "C-c c" "compile-and-comments"
985 "C-c m" "multiple-cursors"
987 "C-c p s" "projectile/search"
988 "C-c p x" "projectile/execute"
989 "C-c p 4" "projectile/other-window"
995 ;; prefixes for major modes
996 (which-key-add-major-mode-key-based-replacements 'message-mode
997 "C-c f n" "footnote")
998 (which-key-add-major-mode-key-based-replacements 'org-mode
999 "C-c C-v" "org-babel")
1003 (which-key-add-column-padding 5)
1004 (which-key-max-description-length 32))
1006 (use-package crux ; results in Waiting for git... [2 times]
1008 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1009 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1010 ("C-c f C" . crux-copy-file-preserve-attributes)
1011 ("C-c f D" . crux-delete-file-and-buffer)
1012 ("C-c f R" . crux-rename-file-and-buffer)
1013 ("C-c j" . crux-top-join-line)
1014 ("C-S-j" . crux-top-join-line)))
1017 :bind (("C-a" . mwim-beginning-of-code-or-line)
1018 ("C-e" . mwim-end-of-code-or-line)
1019 ("<home>" . mwim-beginning-of-line-or-code)
1020 ("<end>" . mwim-end-of-line-or-code)))
1022 (use-package projectile
1025 :bind-keymap ("C-c p" . projectile-command-map)
1029 (defun b/projectile-mode-line-fun ()
1030 "Report project name and type in the modeline."
1031 (let ((project-name (projectile-project-name))
1032 (project-type (projectile-project-type)))
1034 projectile-mode-line-prefix
1036 (format ":%s" project-type)
1038 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1040 (defun my-projectile-invalidate-cache (&rest _args)
1041 ;; ignore the args to `magit-checkout'
1042 (projectile-invalidate-cache nil))
1044 (eval-after-load 'magit-branch
1046 (advice-add 'magit-checkout
1047 :after #'my-projectile-invalidate-cache)
1048 (advice-add 'magit-branch-and-checkout
1049 :after #'my-projectile-invalidate-cache)))
1051 (projectile-completion-system 'ivy)
1052 (projectile-mode-line-prefix " proj"))
1054 (use-package helpful
1057 (("C-S-h c" . helpful-command)
1058 ("C-S-h f" . helpful-callable) ; helpful-function
1059 ("C-S-h v" . helpful-variable)
1060 ("C-S-h k" . helpful-key)
1061 ("C-S-h p" . helpful-at-point)))
1063 (use-package unkillable-scratch
1066 (unkillable-scratch 1)
1068 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1071 ;; | make pretty boxed quotes like this
1073 (use-package boxquote
1076 (:prefix-map b/boxquote-prefix-map
1078 ("b" . boxquote-buffer)
1079 ("B" . boxquote-insert-buffer)
1080 ("d" . boxquote-defun)
1081 ("F" . boxquote-insert-file)
1082 ("hf" . boxquote-describe-function)
1083 ("hk" . boxquote-describe-key)
1084 ("hv" . boxquote-describe-variable)
1085 ("hw" . boxquote-where-is)
1086 ("k" . boxquote-kill)
1087 ("p" . boxquote-paragraph)
1088 ("q" . boxquote-boxquote)
1089 ("r" . boxquote-region)
1090 ("s" . boxquote-shell-command)
1091 ("t" . boxquote-text)
1092 ("T" . boxquote-title)
1093 ("u" . boxquote-unbox)
1094 ("U" . boxquote-unbox-region)
1095 ("y" . boxquote-yank)
1096 ("M-q" . boxquote-fill-paragraph)
1097 ("M-w" . boxquote-kill-ring-save)))
1099 (use-package orgalist
1100 ;; breaks auto-fill-mode, showing this error:
1101 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1104 :hook (message-mode . orgalist-mode))
1106 ;; highlight TODOs in buffers
1107 (use-package hl-todo
1110 (global-hl-todo-mode))
1112 (use-package multi-term
1115 :bind (("C-c a s m m" . multi-term)
1116 ("C-c a s m d" . multi-term-dedicated-toggle)
1117 ("C-c a s m p" . multi-term-prev)
1118 ("C-c a s m n" . multi-term-next)
1120 ("C-c C-j" . term-char-mode))
1122 (setq multi-term-program "screen"
1123 multi-term-program-switches (concat "-c"
1124 (getenv "XDG_CONFIG_HOME")
1126 ;; TODO: add separate bindings for connecting to existing
1127 ;; session vs. always creating a new one
1128 multi-term-dedicated-select-after-open-p t
1129 multi-term-dedicated-window-height 20
1130 multi-term-dedicated-max-window-height 30
1132 '(("C-c C-c" . term-interrupt-subjob)
1133 ("C-c C-e" . term-send-esc)
1134 ("C-c C-j" . term-line-mode)
1136 ;; ("C-y" . term-paste)
1137 ("C-y" . term-send-raw)
1138 ("M-f" . term-send-forward-word)
1139 ("M-b" . term-send-backward-word)
1140 ("M-p" . term-send-up)
1141 ("M-n" . term-send-down)
1142 ("M-j" . term-send-raw-meta)
1143 ("M-y" . term-send-raw-meta)
1144 ("M-/" . term-send-raw-meta)
1145 ("M-0" . term-send-raw-meta)
1146 ("M-1" . term-send-raw-meta)
1147 ("M-2" . term-send-raw-meta)
1148 ("M-3" . term-send-raw-meta)
1149 ("M-4" . term-send-raw-meta)
1150 ("M-5" . term-send-raw-meta)
1151 ("M-6" . term-send-raw-meta)
1152 ("M-7" . term-send-raw-meta)
1153 ("M-8" . term-send-raw-meta)
1154 ("M-9" . term-send-raw-meta)
1155 ("<C-backspace>" . term-send-backward-kill-word)
1156 ("<M-DEL>" . term-send-backward-kill-word)
1157 ("M-d" . term-send-delete-word)
1158 ("M-," . term-send-raw)
1159 ("M-." . comint-dynamic-complete))
1160 term-unbind-key-alist
1161 '("C-z" "C-x" "C-c" "C-h"
1165 (use-package page-break-lines
1168 (page-break-lines-max-width fill-column)
1170 (global-page-break-lines-mode))
1172 (use-package expand-region
1173 :bind ("C-=" . er/expand-region))
1175 (use-package multiple-cursors
1177 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1178 (:prefix-map b/mc-prefix-map
1180 ("c" . mc/edit-lines)
1181 ("n" . mc/mark-next-like-this)
1182 ("p" . mc/mark-previous-like-this)
1183 ("a" . mc/mark-all-like-this))))
1185 (use-package yasnippet
1188 (defconst yas-verbosity-cur yas-verbosity)
1189 (setq yas-verbosity 2)
1190 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1192 (setq yas-verbosity yas-verbosity-cur)
1194 (defun b/yas--maybe-expand-key-filter (cmd)
1195 (when (and (yas--maybe-expand-key-filter cmd)
1196 (not (bound-and-true-p git-commit-mode)))
1198 (defconst b/yas-maybe-expand
1199 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1200 (define-key yas-minor-mode-map
1201 (kbd "SPC") b/yas-maybe-expand)
1205 (use-package debbugs
1207 (("C-c D d" . debbugs-gnu)
1208 ("C-c D b" . debbugs-gnu-bugs)
1211 (interactive) ; bug-gnu-emacs
1212 (setq debbugs-gnu-current-suppress t)
1213 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1214 ("C-c D g" . ; bug-gnuzilla
1217 (setq debbugs-gnu-current-suppress t)
1218 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1219 ("C-c D G b" . ; bug-guix
1222 (setq debbugs-gnu-current-suppress t)
1223 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1224 ("C-c D G p" . ; guix-patches
1227 (setq debbugs-gnu-current-suppress t)
1228 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1230 (use-package org-ref
1232 (b/setq-every '("~/usr/org/references.bib")
1233 reftex-default-bibliography
1234 org-ref-default-bibliography)
1236 org-ref-bibliography-notes "~/usr/org/notes.org"
1237 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1239 ;; (use-package fill-column-indicator)
1243 (("C-c w e" . (lambda ()
1245 (split-window-right)
1247 (erc-switch-to-buffer)))
1248 ("C-c w s l" . (lambda ()
1250 (split-window-right)
1252 ("C-c w s j" . (lambda ()
1254 (split-window-below)
1256 ("C-c w q" . quit-window))
1258 (split-width-threshold 150))
1260 (use-package windmove
1263 (("C-c w h" . windmove-left)
1264 ("C-c w j" . windmove-down)
1265 ("C-c w k" . windmove-up)
1266 ("C-c w l" . windmove-right)
1267 ("C-c w H" . windmove-swap-states-left)
1268 ("C-c w J" . windmove-swap-states-down)
1269 ("C-c w K" . windmove-swap-states-up)
1270 ("C-c w L" . windmove-swap-states-right)))
1274 :bind ("C-c a p" . pass)
1275 :hook (pass-mode . View-exit))
1277 (use-package pdf-tools
1279 :bind (:map pdf-view-mode-map
1280 ("<C-XF86Back>" . pdf-history-backward)
1281 ("<mouse-8>" . pdf-history-backward)
1282 ("<drag-mouse-8>" . pdf-history-backward)
1283 ("<C-XF86Forward>" . pdf-history-forward)
1284 ("<mouse-9>" . pdf-history-forward)
1285 ("<drag-mouse-9>" . pdf-history-forward)
1286 ("M-RET" . image-previous-line)
1287 ("C-s" . isearch-forward)
1288 ("s s" . isearch-forward))
1289 :config (pdf-tools-install nil t)
1290 :custom (pdf-view-resize-factor 1.05))
1292 (use-package org-pdftools
1294 :straight (:host github :repo "fuxialexander/org-pdftools")
1298 (with-eval-after-load 'org
1299 (require 'org-pdftools)))
1301 (use-package biblio)
1304 :hook (latex-mode . reftex-mode))
1306 (use-package reftex-cite
1308 :disabled ; enable to disable
1309 ; reftex-cite's default choice
1312 (defun reftex-get-bibkey-default ()
1313 "If the cursor is in a citation macro, return the word before the macro."
1314 (let* ((macro (reftex-what-macro 1)))
1316 (when (and macro (string-match "cite" (car macro)))
1317 (goto-char (cdr macro)))
1318 (reftex-this-word)))))
1320 (use-package minions
1322 :config (minions-mode))
1326 (dmenu-prompt-string "run: ")
1327 (dmenu-save-file (b/var "dmenu-items")))
1330 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1331 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1333 :straight (:host github :repo "clarete/eosd")
1339 (use-package scpaste
1342 (setq scpaste-http-destination "https://p.bndl.org"
1343 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1346 :bind ("C-c a e w" . eww)
1348 (eww-download-directory (file-name-as-directory
1349 (getenv "XDG_DOWNLOAD_DIR"))))
1352 ;;; Email (with Gnus)
1354 (defvar b/maildir (expand-file-name "~/mail/"))
1355 (with-eval-after-load 'recentf
1356 (add-to-list 'recentf-exclude b/maildir))
1359 b/gnus-init-file (b/etc "gnus")
1360 mail-user-agent 'gnus-user-agent
1361 read-mail-command 'gnus)
1364 :bind (("s-m" . gnus-plugged)
1365 ("s-M" . gnus-unplugged)
1366 ("C-c a m" . gnus-plugged)
1367 ("C-c a M" . gnus-unplugged))
1370 gnus-select-method '(nnnil "")
1371 gnus-secondary-select-methods
1372 '((nnimap "shemshak"
1373 (nnimap-stream plain)
1374 (nnimap-address "127.0.0.1")
1375 (nnimap-server-port 143)
1376 (nnimap-authenticator plain)
1377 (nnimap-user "amin@shemshak.local"))
1379 (nnimap-stream plain)
1380 (nnimap-address "127.0.0.1")
1381 (nnimap-server-port 143)
1382 (nnimap-authenticator plain)
1383 (nnimap-user "bandali@gnu.local")
1384 (nnimap-inbox "INBOX")
1385 (nnimap-split-methods 'nnimap-split-fancy)
1386 (nnimap-split-fancy (|
1387 ;; (: gnus-registry-split-fancy-with-parent)
1388 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1390 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1392 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
1394 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
1395 ;; *.lists.sr.ht, omitting one dot if present
1396 ;; add more \\.?\\([^.]*\\) if needed
1397 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
1399 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1401 (list ".*atreus.freelists.org" "l.atreus")
1402 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1403 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1404 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1405 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1406 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1407 ;; ----------------------------------
1408 ;; legend: (u)nsubscribed | (d)ead
1409 ;; ----------------------------------
1410 ;; otherwise, leave mail in INBOX
1413 (nnimap-stream plain)
1414 (nnimap-address "127.0.0.1")
1415 (nnimap-server-port 143)
1416 (nnimap-authenticator plain)
1417 (nnimap-user "abandali@uw.local")
1418 (nnimap-inbox "INBOX")
1419 (nnimap-split-methods 'nnimap-split-fancy)
1420 (nnimap-split-fancy (|
1421 ;; (: gnus-registry-split-fancy-with-parent)
1423 ("subject" "SE\\s-?212" "course.se212-f19")
1424 (from "SE\\s-?212" "course.se212-f19")
1428 (nnimap-stream plain)
1429 (nnimap-address "127.0.0.1")
1430 (nnimap-server-port 143)
1431 (nnimap-authenticator plain)
1432 (nnimap-user "abandali@csc.uw.local")))
1433 gnus-message-archive-group "nnimap+gnu:INBOX"
1436 (to-address . "atreus@freelists.org")
1437 (to-list . "atreus@freelists.org"))
1439 (to-address . "deepspec@lists.cs.princeton.edu")
1440 (to-list . "deepspec@lists.cs.princeton.edu")
1441 (list-identifier . "\\[deepspec\\]"))
1443 (to-address . "emacs-devel@gnu.org")
1444 (to-list . "emacs-devel@gnu.org"))
1445 ("l\\.help-gnu-emacs"
1446 (to-address . "help-gnu-emacs@gnu.org")
1447 (to-list . "help-gnu-emacs@gnu.org"))
1448 ("l\\.info-gnu-emacs"
1449 (to-address . "info-gnu-emacs@gnu.org")
1450 (to-list . "info-gnu-emacs@gnu.org"))
1451 ("l\\.emacs-orgmode"
1452 (to-address . "emacs-orgmode@gnu.org")
1453 (to-list . "emacs-orgmode@gnu.org")
1454 (list-identifier . "\\[O\\]"))
1455 ("l\\.emacs-tangents"
1456 (to-address . "emacs-tangents@gnu.org")
1457 (to-list . "emacs-tangents@gnu.org"))
1458 ("l\\.emacsconf-committee"
1459 (to-address . "emacsconf-committee@gnu.org")
1460 (to-list . "emacsconf-committee@gnu.org"))
1461 ("l\\.emacsconf-discuss"
1462 (to-address . "emacsconf-discuss@gnu.org")
1463 (to-list . "emacsconf-discuss@gnu.org"))
1464 ("l\\.emacsconf-register"
1465 (to-address . "emacsconf-register@gnu.org")
1466 (to-list . "emacsconf-register@gnu.org"))
1467 ("l\\.emacsconf-submit"
1468 (to-address . "emacsconf-submit@gnu.org")
1469 (to-list . "emacsconf-submit@gnu.org"))
1470 ("l\\.fencepost-users"
1471 (to-address . "fencepost-users@gnu.org")
1472 (to-list . "fencepost-users@gnu.org")
1473 (list-identifier . "\\[Fencepost-users\\]"))
1474 ("l\\.gnewsense-art"
1475 (to-address . "gnewsense-art@nongnu.org")
1476 (to-list . "gnewsense-art@nongnu.org")
1477 (list-identifier . "\\[gNewSense-art\\]"))
1478 ("l\\.gnewsense-dev"
1479 (to-address . "gnewsense-dev@nongnu.org")
1480 (to-list . "gnewsense-dev@nongnu.org")
1481 (list-identifier . "\\[Gnewsense-dev\\]"))
1482 ("l\\.gnewsense-users"
1483 (to-address . "gnewsense-users@nongnu.org")
1484 (to-list . "gnewsense-users@nongnu.org")
1485 (list-identifier . "\\[gNewSense-users\\]"))
1486 ("l\\.gnunet-developers"
1487 (to-address . "gnunet-developers@gnu.org")
1488 (to-list . "gnunet-developers@gnu.org")
1489 (list-identifier . "\\[GNUnet-developers\\]"))
1491 (to-address . "help-gnunet@gnu.org")
1492 (to-list . "help-gnunet@gnu.org")
1493 (list-identifier . "\\[Help-gnunet\\]"))
1495 (to-address . "bug-gnuzilla@gnu.org")
1496 (to-list . "bug-gnuzilla@gnu.org")
1497 (list-identifier . "\\[Bug-gnuzilla\\]"))
1499 (to-address . "gnuzilla-dev@gnu.org")
1500 (to-list . "gnuzilla-dev@gnu.org")
1501 (list-identifier . "\\[Gnuzilla-dev\\]"))
1503 (to-address . "guile-devel@gnu.org")
1504 (to-list . "guile-devel@gnu.org"))
1506 (to-address . "guile-user@gnu.org")
1507 (to-list . "guile-user@gnu.org"))
1509 (to-address . "guix-devel@gnu.org")
1510 (to-list . "guix-devel@gnu.org"))
1512 (to-address . "help-guix@gnu.org")
1513 (to-list . "help-guix@gnu.org"))
1515 (to-address . "info-guix@gnu.org")
1516 (to-list . "info-guix@gnu.org"))
1517 ("l\\.savannah-hackers-public"
1518 (to-address . "savannah-hackers-public@gnu.org")
1519 (to-list . "savannah-hackers-public@gnu.org"))
1520 ("l\\.savannah-users"
1521 (to-address . "savannah-users@gnu.org")
1522 (to-list . "savannah-users@gnu.org"))
1524 (to-address . "www-commits@gnu.org")
1525 (to-list . "www-commits@gnu.org"))
1527 (to-address . "www-discuss@gnu.org")
1528 (to-list . "www-discuss@gnu.org"))
1530 (to-address . "haskell-art@we.lurk.org")
1531 (to-list . "haskell-art@we.lurk.org")
1532 (list-identifier . "\\[haskell-art\\]"))
1534 (to-address . "haskell-cafe@haskell.org")
1535 (to-list . "haskell-cafe@haskell.org")
1536 (list-identifier . "\\[Haskell-cafe\\]"))
1538 (to-address . "notmuch@notmuchmail.org")
1539 (to-list . "notmuch@notmuchmail.org"))
1541 (to-address . "dev@lists.parabola.nu")
1542 (to-list . "dev@lists.parabola.nu")
1543 (list-identifier . "\\[Dev\\]"))
1544 ("l\\.~bandali\\.public-inbox"
1545 (to-address . "~bandali/public-inbox@lists.sr.ht")
1546 (to-list . "~bandali/public-inbox@lists.sr.ht"))
1547 ("l\\.~sircmpwn\\.free-writers-club"
1548 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
1549 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
1550 ("l\\.~sircmpwn\\.srht-admins"
1551 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
1552 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
1553 ("l\\.~sircmpwn\\.srht-announce"
1554 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
1555 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
1556 ("l\\.~sircmpwn\\.srht-dev"
1557 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
1558 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
1559 ("l\\.~sircmpwn\\.srht-discuss"
1560 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
1561 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1563 (to-address . "webmasters@gnu.org")
1564 (to-list . "webmasters@gnu.org"))
1571 gnus-large-newsgroup 50
1572 gnus-home-directory (b/var "gnus/")
1573 gnus-directory (concat gnus-home-directory "news/")
1574 message-directory (concat gnus-home-directory "mail/")
1575 nndraft-directory (concat gnus-home-directory "drafts/")
1576 gnus-save-newsrc-file nil
1577 gnus-read-newsrc-file nil
1578 gnus-interactive-exit nil
1579 gnus-gcc-mark-as-read t)
1581 (when (version< emacs-version "27")
1582 (with-eval-after-load 'nnmail
1584 'nnmail-split-abbrev-alist
1585 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1588 ;; (gnus-registry-initialize)
1590 (with-eval-after-load 'recentf
1591 (add-to-list 'recentf-exclude gnus-home-directory)))
1593 (use-package gnus-art
1596 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
1597 gnus-sorted-header-list '("^From:"
1613 "^Mail-Followup-To:"
1617 "^X-detected-operating-system:"
1622 gnus-visible-headers (mapconcat 'identity
1623 gnus-sorted-header-list
1625 ;; local-lapsed article dates
1626 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1627 gnus-article-date-headers '(user-defined)
1628 gnus-article-time-format
1630 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1631 (local (article-make-date-line date 'local))
1632 (combined-lapsed (article-make-date-line date
1635 (string-match " (.+" combined-lapsed)
1636 (match-string 0 combined-lapsed))))
1637 (concat local lapsed))))
1639 :map gnus-article-mode-map
1640 ("M-L" . org-store-link)))
1642 (use-package gnus-sum
1643 :bind (:map gnus-summary-mode-map
1644 :prefix-map b/gnus-summary-prefix-map
1646 ("r" . gnus-summary-reply)
1647 ("w" . gnus-summary-wide-reply)
1648 ("v" . gnus-summary-show-raw-article))
1651 :map gnus-summary-mode-map
1652 ("M-L" . org-store-link))
1653 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
1655 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
1656 gnus-thread-sort-by-subject
1657 gnus-thread-sort-by-date)))
1659 (use-package gnus-msg
1661 (defvar b/shemshak-signature "Amin Bandali
1662 https://shemshak.org/~amin")
1663 (defvar b/uw-signature "Amin Bandali, MMath Student
1664 Cheriton School of Computer Science
1665 University of Waterloo
1666 https://bandali.eu.org")
1667 (defvar b/csc-signature "Amin Bandali
1668 System Administrator, Systems Committee
1669 Computer Science Club, University of Waterloo
1670 https://csclub.uwaterloo.ca/~abandali")
1671 (setq gnus-message-replysign t
1674 (address "bandali@gnu.org"))
1675 ("nnimap\\+gnu:l\\..*"
1678 (organization "GNU"))
1679 ((header "subject" "ThankCRM")
1680 (to "webmasters-comment@gnu.org")
1682 (eval (setq b/message-cite-say-hi nil)))
1683 ("nnimap\\+shemshak:.*"
1684 (address "amin@shemshak.org")
1686 (signature b/shemshak-signature)
1687 (gcc "nnimap+shemshak:Sent")
1688 (eval (setq b/message-cite-say-hi t)))
1690 (address "bandali@uwaterloo.ca")
1692 (signature b/uw-signature))
1693 ("nnimap\\+uw:INBOX"
1694 (gcc "\"nnimap+uw:Sent Items\""))
1696 (address "bandali@csclub.uwaterloo.ca")
1697 (signature b/csc-signature)
1698 (gcc "nnimap+csc:Sent"))))
1699 :hook (gnus-message-setup . (lambda ()
1700 (unless (mml-secure-is-encrypted-p)
1701 (mml-secure-message-sign)))))
1703 (use-package gnus-topic
1704 :hook (gnus-group-mode . gnus-topic-mode)
1705 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
1707 (use-package gnus-agent
1709 (setq gnus-agent-synchronize-flags 'ask)
1710 :hook (gnus-group-mode . gnus-agent-mode))
1712 (use-package gnus-group
1714 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
1717 ;; problematic with ebdb's popup, *EBDB-Gnus*
1718 (use-package gnus-win
1720 (setq gnus-use-full-window nil)))
1722 (use-package gnus-dired
1723 :commands gnus-dired-mode
1725 (add-hook 'dired-mode-hook 'gnus-dired-mode))
1728 (use-package gnus-utils
1730 (gnus-completing-read-function 'gnus-ido-completing-read)))
1732 (use-package mm-decode
1734 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
1735 mm-decrypt-option 'known
1736 mm-verify-option 'known))
1740 (when (version< "27" emacs-version)
1741 (set-face-attribute 'mm-uu-extract nil :extend t))
1743 (mm-uu-diff-groups-regexp
1744 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
1746 (use-package sendmail
1748 (setq sendmail-program (executable-find "msmtp")
1749 ;; message-sendmail-extra-arguments '("-v" "-d")
1750 mail-specify-envelope-from t
1751 mail-envelope-from 'header))
1753 (use-package message
1754 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
1756 ;; redefine for a simplified In-Reply-To header
1757 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
1758 (defun message-make-in-reply-to ()
1759 "Return the In-Reply-To header for this message."
1760 (when message-reply-headers
1761 (let ((from (mail-header-from message-reply-headers))
1762 (msg-id (mail-header-id message-reply-headers)))
1766 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
1767 (defconst message-cite-style-bandali
1768 '((message-cite-function 'message-cite-original)
1769 (message-citation-line-function 'message-insert-formatted-citation-line)
1770 (message-cite-reply-position 'traditional)
1771 (message-yank-prefix "> ")
1772 (message-yank-cited-prefix ">")
1773 (message-yank-empty-prefix ">")
1774 (message-citation-line-format
1775 (if b/message-cite-say-hi
1776 (concat "Hi %F,\n\n" b/message-cite-style-format)
1777 b/message-cite-style-format)))
1778 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
1779 (setq ;; message-cite-style 'message-cite-style-bandali
1780 message-kill-buffer-on-exit t
1781 message-send-mail-function 'message-send-mail-with-sendmail
1782 message-sendmail-envelope-from 'header
1783 message-subscribed-address-functions
1784 '(gnus-find-subscribed-addresses)
1785 message-dont-reply-to-names
1786 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
1787 ;; (require 'company-ebdb)
1788 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
1789 (message-mode . flyspell-mode)
1790 (message-mode . (lambda ()
1791 ;; (setq-local fill-column b/fill-column
1792 ;; message-fill-column b/fill-column)
1793 (make-local-variable 'company-idle-delay)
1794 (setq company-idle-delay 0.2))))
1796 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
1797 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
1798 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
1800 (message-elide-ellipsis "[...]\n"))
1804 (use-package mml-sec
1806 (mml-secure-openpgp-encrypt-to-self t)
1807 (mml-secure-openpgp-sign-with-sender t))
1809 (use-package footnote
1812 ;; (setq footnote-start-tag ""
1813 ;; footnote-end-tag ""
1814 ;; footnote-style 'unicode)
1816 (:map message-mode-map
1817 :prefix-map b/footnote-prefix-map
1819 ("a" . footnote-add-footnote)
1820 ("b" . footnote-back-to-message)
1821 ("c" . footnote-cycle-style)
1822 ("d" . footnote-delete-footnote)
1823 ("g" . footnote-goto-footnote)
1824 ("r" . footnote-renumber-footnotes)
1825 ("s" . footnote-set-style)))
1830 :bind (:map gnus-group-mode-map ("e" . ebdb))
1832 (setq ebdb-sources (b/var "ebdb"))
1833 (with-eval-after-load 'swiper
1834 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
1836 (use-package ebdb-com
1839 (use-package ebdb-complete
1842 ;; (setq ebdb-complete-mail 'capf)
1843 (ebdb-complete-enable))
1845 (use-package ebdb-message
1849 ;; (use-package company-ebdb
1851 ;; (defun company-ebdb--post-complete (_) nil))
1853 (use-package ebdb-gnus
1856 (ebdb-gnus-window-size 0.3))
1858 (use-package ebdb-mua
1861 :custom (ebdb-mua-pop-up t))
1863 ;; (use-package ebdb-message
1866 ;; (use-package ebdb-vcard
1869 (use-package message-x)
1872 (use-package message-x
1874 (message-x-completion-alist
1876 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
1879 (quote message-newgroups-header-regexp))
1880 message-newgroups-header-regexp message-newsgroups-header-regexp)
1881 . message-expand-group))))))
1884 (use-package gnus-harvest
1885 :commands gnus-harvest-install
1888 (if (featurep 'message-x)
1889 (gnus-harvest-install 'message-x)
1890 (gnus-harvest-install))))
1892 (use-package gnus-article-treat-patch
1897 ;; note: be sure to customize faces with `:foreground "white"' when
1898 ;; using a theme with a white/light background :)
1899 (setq ft/gnus-article-patch-conditions
1900 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
1903 ;;; IRC (with ERC and ZNC)
1906 :bind (("C-c b b" . erc-switch-to-buffer)
1908 ("M-a" . erc-track-switch-buffer))
1910 (erc-join-buffer 'bury)
1911 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
1912 (erc-nick "bandali")
1914 (erc-rename-buffers t)
1915 (erc-server-reconnect-attempts 5)
1916 (erc-server-reconnect-timeout 3)
1918 (defun erc-cmd-OPME ()
1919 "Request chanserv to op me."
1920 (erc-message "PRIVMSG"
1921 (format "chanserv op %s %s"
1922 (erc-default-target)
1923 (erc-current-nick)) nil))
1924 (defun erc-cmd-DEOPME ()
1925 "Deop myself from current channel."
1926 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
1927 (add-to-list 'erc-modules 'keep-place)
1928 (add-to-list 'erc-modules 'notifications)
1929 (add-to-list 'erc-modules 'smiley)
1930 (add-to-list 'erc-modules 'spelling)
1931 (add-to-list 'erc-modules 'scrolltoplace)
1932 (erc-update-modules))
1934 (use-package erc-fill
1937 (erc-fill-column 77)
1938 (erc-fill-function 'erc-fill-static)
1939 (erc-fill-static-center 18))
1941 (use-package erc-pcomplete
1944 (erc-pcomplete-nick-postfix ", "))
1946 (use-package erc-track
1948 :bind (("C-c a e t d" . erc-track-disable)
1949 ("C-c a e t e" . erc-track-enable))
1951 (erc-track-enable-keybindings nil)
1952 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
1953 "324" "329" "332" "333" "353" "477"))
1954 (erc-track-position-in-mode-line t)
1955 (erc-track-priority-faces-only 'all)
1956 (erc-track-shorten-function nil))
1958 (use-package erc-hl-nicks
1961 (use-package erc-scrolltoplace
1965 :bind (("C-c a e e" . znc-erc)
1966 ("C-c a e a" . znc-all))
1968 (let ((pwd (let ((auth (auth-source-search :host "znca")))
1970 ((null auth) (error "Couldn't find znca's authinfo"))
1971 (t (funcall (plist-get (car auth) :secret)))))))
1973 `(("znc.shemshak.org" 1337 t
1974 ((freenode "amin/freenode" ,pwd)))
1975 ("znc.shemshak.org" 1337 t
1976 ((oftc "amin/oftc" ,pwd)))))))
1979 ;;; Post initialization
1982 (message "Loading %s...done (%.3fs)" user-init-file
1983 (float-time (time-subtract (current-time)
1984 b/before-user-init-time)))
1986 ;;; init.el ends here