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))
587 (:map ido-common-completion-map
588 ([escape] . minibuffer-keyboard-quit)
589 ("DEL" . b/ido-backspace))
592 (defun b/ido-backspace ()
593 "Forward to `backward-delete-char'. On error (read-only), quit."
596 (backward-delete-char 1)
598 (minibuffer-keyboard-quit))))
602 (ido-enable-flex-matching t)
603 ;; (ido-enable-regexp t)
604 ;; (ido-enable-prefix t)
605 (ido-max-window-height 10)
606 (ido-use-virtual-buffers t))
608 (use-package ido-vertical-mode
611 (ido-vertical-mode 1)
613 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
614 (ido-vertical-show-count t))
616 (use-package ido-completing-read+
620 (ido-ubiquitous-mode 1))
622 (use-package crm-custom
627 (use-package icomplete
640 (:map ivy-minibuffer-map
641 ([escape] . keyboard-escape-quit
)
642 ([S-up
] . ivy-previous-history-element
)
643 ([S-down
] . ivy-next-history-element
)
644 ("DEL" . ivy-backward-delete-char
))
648 ivy-use-virtual-buffers t
649 ivy-virtual-abbreviate
'abbreviate
650 ivy-count-format
"%d/%d ")
652 (defvar b
/ivy-ignore-buffer-modes
'(magit-mode erc-mode dired-mode
))
653 (defun b/ivy-ignore-buffer-p
(str)
654 "Return non-nil if str names a buffer with a major mode
655 derived from one of `b/ivy-ignore-buffer-modes'.
657 This function is intended for use with `ivy-ignore-buffers'."
658 (let* ((buf (get-buffer str
))
659 (mode (and buf
(buffer-local-value 'major-mode buf
))))
661 (apply #'provided-mode-derived-p mode b
/ivy-ignore-buffer-modes
))))
662 (add-to-list 'ivy-ignore-buffers
'b
/ivy-ignore-buffer-p
)
666 (ivy-minibuffer-match-face-1 ((t (:background
"#eeeeee"))))
667 (ivy-minibuffer-match-face-2 ((t (:background
"#e7e7e7" :weight bold
))))
668 (ivy-minibuffer-match-face-3 ((t (:background
"light goldenrod" :weight semi-bold
))))
669 (ivy-minibuffer-match-face-4 ((t (:background
"misty rose" :weight semi-bold
))))
670 (ivy-current-match ((((class color
) (background light
))
671 :background
"#d7d7d7" :foreground
"black")
672 (((class color
) (background dark
))
673 :background
"#65a7e2" :foreground
"black"))))
678 :bind
(("C-S-s" . swiper-isearch
)))
683 :bind
(("C-c f r" . counsel-recentf
)
684 :map minibuffer-local-map
685 ("C-r" . counsel-minibuffer-history
))
688 (defalias 'locate
#'counsel-locate
))
694 :bind
("C-c a s e" . eshell
)
696 (eval-when-compile (defvar eshell-prompt-regexp
))
697 (defun b/eshell-quit-or-delete-char
(arg)
699 (if (and (eolp) (looking-back eshell-prompt-regexp nil
))
700 (eshell-life-is-too-much)
703 (defun b/eshell-clear
()
705 (let ((inhibit-read-only t
))
709 (defun b/eshell-setup
()
710 (make-local-variable 'company-idle-delay
)
711 (defvar company-idle-delay
)
712 (setq company-idle-delay nil
)
713 (bind-keys :map eshell-mode-map
714 ("C-d" . b
/eshell-quit-or-delete-char
)
715 ("C-S-l" . b
/eshell-clear
)
716 ("M-r" . counsel-esh-history
)
717 ;; ([tab] . company-complete)
719 (if (version< "27" emacs-version
)
720 (bind-keys :map eshell-hist-mode-map
721 ("M-r" . counsel-esh-history
))
722 (bind-keys :map eshell-mode-map
723 ("M-r" . counsel-esh-history
))))
726 eshell-prompt-regexp
"\\(.*\n\\)*[$#] "
727 eshell-prompt-function
730 (propertize (format "%s@%s:" (user-login-name) (system-name))
732 (propertize (abbreviate-file-name default-directory
)
733 'face
'font-lock-comment-face
)
734 (propertize "\n" 'face
'default
)
736 (propertize "#" 'face
'red
)
737 (propertize "$" 'face
'default
))
738 (propertize " " 'face
'default
))))
740 :hook
(eshell-mode . b
/eshell-setup
)
742 (eshell-hist-ignoredups t
)
743 (eshell-input-filter 'eshell-input-filter-initial-space
))
747 (("C-x C-b" . ibuffer
)
748 :map ibuffer-mode-map
749 ("P" . ibuffer-backward-filter-group
)
750 ("N" . ibuffer-forward-filter-group
)
751 ("M-p" . ibuffer-do-print
)
752 ("M-n" . ibuffer-do-shell-command-pipe-replace
))
754 ;; Use human readable Size column instead of original one
755 (define-ibuffer-column size-h
756 (:name
"Size" :inline t
)
758 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
759 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
760 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
761 (t (format "%8d" (buffer-size)))))
763 (ibuffer-saved-filter-groups
765 ("dired" (mode . dired-mode
))
766 ("org" (mode . org-mode
))
769 (mode . gnus-group-mode
)
770 (mode . gnus-summary-mode
)
771 (mode . gnus-article-mode
)
772 ;; not really, but...
773 (mode . message-mode
)))
792 (mode . emacs-lisp-mode
)
794 (mode . haskell-mode
)
797 (mode . alloy-mode
)))
801 (mode . latex-mode
)))
804 (name .
"^\\*scratch\\*$")
805 (name .
"^\\*Messages\\*$")))
806 ("exwm" (mode . exwm-mode
))
807 ("erc" (mode . erc-mode
)))))
809 '((mark modified read-only locked
" "
810 (name 72 72 :left
:elide
)
814 (mode 16 16 :left
:elide
)
815 " " filename-and-process
)
819 :hook
(ibuffer .
(lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
823 :hook
(prog-mode . outline-minor-mode
)
826 outline-minor-mode-map
827 ("<s-tab>" . outline-toggle-children
)
828 ("M-p" . outline-previous-visible-heading
)
829 ("M-n" . outline-next-visible-heading
)
830 :prefix-map b
/outline-prefix-map
832 ("TAB" . outline-toggle-children
)
833 ("a" . outline-hide-body
)
834 ("H" . outline-hide-body
)
835 ("S" . outline-show-all
)
836 ("h" . outline-hide-subtree
)
837 ("s" . outline-show-subtree
)))
840 :custom
(ls-lisp-dirs-first t
))
844 (setq dired-dwim-target t
845 dired-listing-switches
"-alh"
846 ls-lisp-use-insert-directory-program nil
)
848 ;; easily diff 2 marked files
849 ;; https://oremacs.com/2017/03/18/dired-ediff/
850 (defun dired-ediff-files ()
853 (defvar ediff-after-quit-hook-internal
)
854 (let ((files (dired-get-marked-files))
855 (wnd (current-window-configuration)))
856 (if (<= (length files
) 2)
857 (let ((file1 (car files
))
858 (file2 (if (cdr files
)
862 (dired-dwim-target-directory)))))
863 (if (file-newer-than-file-p file1 file2
)
864 (ediff-files file2 file1
)
865 (ediff-files file1 file2
))
866 (add-hook 'ediff-after-quit-hook-internal
868 (setq ediff-after-quit-hook-internal nil
)
869 (set-window-configuration wnd
))))
870 (error "no more than 2 files should be marked"))))
873 (setq dired-guess-shell-alist-user
874 '(("\\.pdf\\'" "evince" "zathura" "okular")
875 ("\\.doc\\'" "libreoffice")
876 ("\\.docx\\'" "libreoffice")
877 ("\\.ppt\\'" "libreoffice")
878 ("\\.pptx\\'" "libreoffice")
879 ("\\.xls\\'" "libreoffice")
880 ("\\.xlsx\\'" "libreoffice")
881 ("\\.flac\\'" "mpv")))
882 :bind
(:map dired-mode-map
883 ("b" . dired-up-directory
)
884 ("E" . dired-ediff-files
)
885 ("e" . dired-toggle-read-only
)
886 ("\\" . dired-hide-details-mode
)
889 (b/dired-start-process
"zathura"))))
890 :hook
(dired-mode . dired-hide-details-mode
))
894 (temp-buffer-resize-mode)
895 (setq help-window-select t
))
899 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
900 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
901 (add-to-list 'tramp-default-proxies-alist
902 (list (regexp-quote (system-name)) nil nil
)))
904 (use-package doc-view
905 :bind
(:map doc-view-mode-map
906 ("M-RET" . image-previous-line
)))
911 ;; highlight uncommitted changes in the left fringe
915 (setq diff-hl-draw-borders nil
)
916 (global-diff-hl-mode)
917 :hook
(magit-post-refresh . diff-hl-magit-post-refresh
))
919 ;; display Lisp objects at point in the echo area
921 :when
(version< "25" emacs-version
)
922 :config
(global-eldoc-mode))
924 ;; highlight matching parens
927 :config
(show-paren-mode))
929 (use-package elec-pair
931 :config
(electric-pair-mode))
934 :config
(column-number-mode)
936 ;; Save what I copy into clipboard from other applications into Emacs'
937 ;; kill-ring, which would allow me to still be able to easily access
938 ;; it in case I kill (cut or copy) something else inside Emacs before
939 ;; yanking (pasting) what I'd originally intended to.
940 (save-interprogram-paste-before-kill t
))
942 ;; save minibuffer history
943 (use-package savehist
947 (add-to-list 'savehist-additional-variables
'kill-ring
))
949 ;; automatically save place in files
950 (use-package saveplace
951 :when
(version< "25" emacs-version
)
952 :config
(save-place-mode))
954 (use-package prog-mode
955 :config
(global-prettify-symbols-mode)
956 (defun indicate-buffer-boundaries-left ()
957 (setq indicate-buffer-boundaries
'left
))
958 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
960 (use-package text-mode
961 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
962 :hook
((text-mode . indicate-buffer-boundaries-left
)
963 (text-mode . flyspell-mode
)))
965 (use-package conf-mode
974 (:map company-active-map
975 ([tab] . company-complete-common-or-cycle)
976 ([escape] . company-abort)
977 ("C-p" . company-select-previous-or-abort)
978 ("C-n" . company-select-next-or-abort))
980 (company-minimum-prefix-length 1)
981 (company-selection-wrap-around t)
982 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
983 (company-dabbrev-downcase nil)
984 (company-dabbrev-ignore-case nil)
986 ;; (global-company-mode t)
989 (use-package flycheck
991 :hook (prog-mode . flycheck-mode)
993 (:map flycheck-mode-map
994 ("M-P" . flycheck-previous-error)
995 ("M-N" . flycheck-next-error))
997 ;; Use the load-path from running Emacs when checking elisp files
998 (setq flycheck-emacs-lisp-load-path 'inherit)
1000 ;; Only flycheck when I actually save the buffer
1001 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1002 :custom (flycheck-mode-line-prefix "flyc"))
1004 (use-package flyspell)
1006 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1010 ;; ’ can be part of a word
1011 (setq ispell-local-dictionary-alist
1012 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1013 "['\x2019]" nil ("-B") nil utf-8))
1014 ispell-program-name (executable-find "hunspell"))
1015 ;; don't send ’ to the subprocess
1016 (defun endless/replace-apostrophe (args)
1017 (cons (replace-regexp-in-string
1020 (advice-add #'ispell-send-string :filter-args
1021 #'endless/replace-apostrophe)
1023 ;; convert ' back to ’ from the subprocess
1024 (defun endless/replace-quote (args)
1025 (if (not (derived-mode-p 'org-mode))
1027 (cons (replace-regexp-in-string
1030 (advice-add #'ispell-parse-output :filter-args
1031 #'endless/replace-quote))
1034 :hook (text-mode . abbrev-mode))
1037 ;;; Programming modes
1039 (use-package lisp-mode
1041 (defun indent-spaces-mode ()
1042 (setq indent-tabs-mode nil))
1043 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1046 :hook (emacs-lisp-mode . reveal-mode))
1048 (use-package elisp-mode)
1050 ;; (use-package alloy-mode
1051 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1052 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1054 ;; (setq alloy-basic-offset 2)
1055 ;; ;; (defun b/alloy-simple-indent (start end)
1056 ;; ;; (interactive "r")
1057 ;; ;; ;; (if (region-active-p)
1058 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1060 ;; ;; ;; (indent-rigidly (line-beginning-position)
1061 ;; ;; ;; (line-end-position)
1062 ;; ;; ;; alloy-basic-offset)))
1063 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1064 ;; :bind (:map alloy-mode-map
1065 ;; ("RET" . electric-newline-and-maybe-indent)
1066 ;; ;; ("TAB" . b/alloy-simple-indent)
1067 ;; ("TAB" . indent-for-tab-command))
1068 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1070 (eval-when-compile (defvar lean-mode-map))
1071 (use-package lean-mode
1073 :bind (:map lean-mode-map
1074 ("S-SPC" . company-complete))
1076 (require 'lean-input)
1077 (setq default-input-method "Lean"
1078 lean-input-tweak-all '(lean-input-compose
1079 (lean-input-prepend "/")
1080 (lean-input-nonempty))
1081 lean-input-user-translations '(("/" "/")))
1084 (use-package mhtml-mode)
1086 (use-package sgml-mode
1088 (setq sgml-basic-offset 0))
1090 (use-package css-mode
1092 (setq css-indent-offset 2))
1094 (use-package emmet-mode
1095 :after (:any mhtml-mode css-mode sgml-mode)
1096 :bind* (("C-)" . emmet-next-edit-point)
1097 ("C-(" . emmet-prev-edit-point))
1099 (unbind-key "C-j" emmet-mode-keymap)
1100 (setq emmet-move-cursor-between-quotes t)
1101 :hook (css-mode html-mode sgml-mode))
1103 (use-package geiser)
1105 (use-package geiser-guile
1107 (setq geiser-guile-load-path "~/src/git/guix"))
1114 (font-latex-fontify-sectioning 'color)))
1116 (use-package go-mode
1119 (use-package po-mode
1121 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1123 (use-package tex-mode
1126 (lambda (p) (string-match "^---?" (car p)))
1127 tex--prettify-symbols-alist)
1128 :hook ((tex-mode . auto-fill-mode)
1129 (tex-mode . flyspell-mode)))
1131 ;; (use-package george-mode
1132 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1133 ;; :mode "\\.grg\\'")
1138 (add-to-list 'custom-theme-load-path
1140 (convert-standard-filename "lisp") user-emacs-directory))
1141 (load-theme 'tangomod t)
1143 (use-package smart-mode-line
1144 :commands (sml/apply-theme)
1147 ;; thanks, but no thnaks; don't make fixed-width fills.
1148 (defun sml/fill-for-buffer-identification () "")
1149 (setq sml/theme 'tangomod)
1151 (smart-mode-line-enable))
1153 (use-package doom-modeline
1156 :hook (after-init . doom-modeline-init)
1158 (doom-modeline-buffer-file-name-style 'relative-to-project))
1160 (use-package doom-themes)
1166 (setq x-underline-at-descent-line t)
1167 (let ((line (face-attribute 'mode-line :underline)))
1168 (set-face-attribute 'mode-line nil :overline line)
1169 (set-face-attribute 'mode-line-inactive nil :overline line)
1170 (set-face-attribute 'mode-line-inactive nil :underline line)
1171 (set-face-attribute 'mode-line nil :box nil)
1172 (set-face-attribute 'mode-line-inactive nil :box nil)
1173 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1174 (moody-replace-mode-line-buffer-identification)
1175 (moody-replace-vc-mode))
1177 (use-package mini-modeline
1180 :config (mini-modeline-mode))
1182 (defvar b/org-mode-font-lock-keywords
1183 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1184 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1185 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1186 (4 '(:foreground "#c5c8c6") t))) ; title
1187 "For use with the `doom-tomorrow-night' theme.")
1189 (defun b/lights-on ()
1190 "Enable my favourite light theme."
1192 (mapc #'disable-theme custom-enabled-themes)
1193 (load-theme 'tangomod t)
1194 (when (featurep 'smart-mode-line)
1195 (sml/apply-theme 'tangomod))
1196 (font-lock-remove-keywords
1197 'org-mode b/org-mode-font-lock-keywords)
1198 (when (featurep 'erc-hl-nicks)
1199 (erc-hl-nicks-reset-face-table))
1200 (when (featurep 'exwm-systemtray)
1201 (exwm-systemtray--refresh)))
1203 (defun b/lights-off ()
1206 (mapc #'disable-theme custom-enabled-themes)
1207 (load-theme 'doom-one t)
1208 (when (featurep 'smart-mode-line)
1209 (sml/apply-theme 'automatic))
1210 (font-lock-add-keywords
1211 'org-mode b/org-mode-font-lock-keywords t)
1212 (when (featurep 'erc-hl-nicks)
1213 (erc-hl-nicks-reset-face-table))
1214 (when (featurep 'exwm-systemtray)
1215 (exwm-systemtray--refresh)))
1218 ("C-c t d" . b/lights-off)
1219 ("C-c t l" . b/lights-on))
1222 ;;; Emacs enhancements & auxiliary packages
1225 :config (setq Man-width 80))
1227 (use-package which-key
1230 (which-key-add-key-based-replacements
1231 ;; prefixes for global prefixes and minor modes
1234 "C-x RET" "coding system"
1236 "C-x @" "event modifiers"
1237 "C-x a" "abbrev/expand"
1238 "C-x r" "rectangle/register/bookmark"
1240 "C-x v" "version control"
1244 ;; prefixes for my personal bindings
1246 "C-c a" "applications"
1251 "C-c c" "compile-and-comments"
1257 "C-c m" "multiple-cursors"
1258 "C-c p" "projectile"
1259 "C-c p s" "projectile/search"
1260 "C-c p x" "projectile/execute"
1261 "C-c p 4" "projectile/other-window"
1267 ;; prefixes for major modes
1268 (which-key-add-major-mode-key-based-replacements 'message-mode
1269 "C-c f n" "footnote")
1270 (which-key-add-major-mode-key-based-replacements 'org-mode
1271 "C-c C-v" "org-babel")
1275 (which-key-add-column-padding 5)
1276 (which-key-max-description-length 32))
1278 (use-package crux ; results in Waiting for git... [2 times]
1280 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1281 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1282 ("C-c f C" . crux-copy-file-preserve-attributes)
1283 ("C-c f D" . crux-delete-file-and-buffer)
1284 ("C-c f R" . crux-rename-file-and-buffer)
1285 ("C-c j" . crux-top-join-line)
1286 ("C-S-j" . crux-top-join-line)))
1289 :bind (("C-a" . mwim-beginning-of-code-or-line)
1290 ("C-e" . mwim-end-of-code-or-line)
1291 ("<home>" . mwim-beginning-of-line-or-code)
1292 ("<end>" . mwim-end-of-line-or-code)))
1294 (use-package projectile
1297 :bind-keymap ("C-c p" . projectile-command-map)
1301 (defun b/projectile-mode-line-fun ()
1302 "Report project name and type in the modeline."
1303 (let ((project-name (projectile-project-name))
1304 (project-type (projectile-project-type)))
1306 projectile-mode-line-prefix
1308 (format ":%s" project-type)
1310 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1312 (defun my-projectile-invalidate-cache (&rest _args)
1313 ;; ignore the args to `magit-checkout'
1314 (projectile-invalidate-cache nil))
1316 (eval-after-load 'magit-branch
1318 (advice-add 'magit-checkout
1319 :after #'my-projectile-invalidate-cache)
1320 (advice-add 'magit-branch-and-checkout
1321 :after #'my-projectile-invalidate-cache)))
1323 (projectile-completion-system 'ivy)
1324 (projectile-mode-line-prefix " proj"))
1326 (use-package helpful
1329 (("C-S-h c" . helpful-command)
1330 ("C-S-h f" . helpful-callable) ; helpful-function
1331 ("C-S-h v" . helpful-variable)
1332 ("C-S-h k" . helpful-key)
1333 ("C-S-h p" . helpful-at-point)))
1335 (use-package unkillable-scratch
1338 (unkillable-scratch 1)
1340 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1343 ;; | make pretty boxed quotes like this
1345 (use-package boxquote
1348 (:prefix-map b/boxquote-prefix-map
1350 ("b" . boxquote-buffer)
1351 ("B" . boxquote-insert-buffer)
1352 ("d" . boxquote-defun)
1353 ("F" . boxquote-insert-file)
1354 ("hf" . boxquote-describe-function)
1355 ("hk" . boxquote-describe-key)
1356 ("hv" . boxquote-describe-variable)
1357 ("hw" . boxquote-where-is)
1358 ("k" . boxquote-kill)
1359 ("p" . boxquote-paragraph)
1360 ("q" . boxquote-boxquote)
1361 ("r" . boxquote-region)
1362 ("s" . boxquote-shell-command)
1363 ("t" . boxquote-text)
1364 ("T" . boxquote-title)
1365 ("u" . boxquote-unbox)
1366 ("U" . boxquote-unbox-region)
1367 ("y" . boxquote-yank)
1368 ("M-q" . boxquote-fill-paragraph)
1369 ("M-w" . boxquote-kill-ring-save)))
1371 (use-package orgalist
1372 ;; breaks auto-fill-mode, showing this error:
1373 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1376 :hook (message-mode . orgalist-mode))
1378 ;; highlight TODOs in buffers
1379 (use-package hl-todo
1382 (global-hl-todo-mode))
1384 (use-package multi-term
1387 :bind (("C-c a s m m" . multi-term)
1388 ("C-c a s m d" . multi-term-dedicated-toggle)
1389 ("C-c a s m p" . multi-term-prev)
1390 ("C-c a s m n" . multi-term-next)
1392 ("C-c C-j" . term-char-mode))
1394 (setq multi-term-program "screen"
1395 multi-term-program-switches (concat "-c"
1396 (getenv "XDG_CONFIG_HOME")
1398 ;; TODO: add separate bindings for connecting to existing
1399 ;; session vs. always creating a new one
1400 multi-term-dedicated-select-after-open-p t
1401 multi-term-dedicated-window-height 20
1402 multi-term-dedicated-max-window-height 30
1404 '(("C-c C-c" . term-interrupt-subjob)
1405 ("C-c C-e" . term-send-esc)
1406 ("C-c C-j" . term-line-mode)
1408 ;; ("C-y" . term-paste)
1409 ("C-y" . term-send-raw)
1410 ("M-f" . term-send-forward-word)
1411 ("M-b" . term-send-backward-word)
1412 ("M-p" . term-send-up)
1413 ("M-n" . term-send-down)
1414 ("M-j" . term-send-raw-meta)
1415 ("M-y" . term-send-raw-meta)
1416 ("M-/" . term-send-raw-meta)
1417 ("M-0" . term-send-raw-meta)
1418 ("M-1" . term-send-raw-meta)
1419 ("M-2" . term-send-raw-meta)
1420 ("M-3" . term-send-raw-meta)
1421 ("M-4" . term-send-raw-meta)
1422 ("M-5" . term-send-raw-meta)
1423 ("M-6" . term-send-raw-meta)
1424 ("M-7" . term-send-raw-meta)
1425 ("M-8" . term-send-raw-meta)
1426 ("M-9" . term-send-raw-meta)
1427 ("<C-backspace>" . term-send-backward-kill-word)
1428 ("<M-DEL>" . term-send-backward-kill-word)
1429 ("M-d" . term-send-delete-word)
1430 ("M-," . term-send-raw)
1431 ("M-." . comint-dynamic-complete))
1432 term-unbind-key-alist
1433 '("C-z" "C-x" "C-c" "C-h"
1437 (use-package page-break-lines
1440 (page-break-lines-max-width fill-column)
1442 (global-page-break-lines-mode))
1444 (use-package expand-region
1445 :bind ("C-=" . er/expand-region))
1447 (use-package multiple-cursors
1449 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1450 (:prefix-map b/mc-prefix-map
1452 ("c" . mc/edit-lines)
1453 ("n" . mc/mark-next-like-this)
1454 ("p" . mc/mark-previous-like-this)
1455 ("a" . mc/mark-all-like-this))))
1457 (use-package yasnippet
1460 (defconst yas-verbosity-cur yas-verbosity)
1461 (setq yas-verbosity 2)
1462 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1464 (setq yas-verbosity yas-verbosity-cur)
1466 (defun b/yas--maybe-expand-key-filter (cmd)
1467 (when (and (yas--maybe-expand-key-filter cmd)
1468 (not (bound-and-true-p git-commit-mode)))
1470 (defconst b/yas-maybe-expand
1471 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1472 (define-key yas-minor-mode-map
1473 (kbd "SPC") b/yas-maybe-expand)
1477 (use-package debbugs
1479 (("C-c D d" . debbugs-gnu)
1480 ("C-c D b" . debbugs-gnu-bugs)
1483 (interactive) ; bug-gnu-emacs
1484 (setq debbugs-gnu-current-suppress t)
1485 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1486 ("C-c D g" . ; bug-gnuzilla
1489 (setq debbugs-gnu-current-suppress t)
1490 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1491 ("C-c D G b" . ; bug-guix
1494 (setq debbugs-gnu-current-suppress t)
1495 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1496 ("C-c D G p" . ; guix-patches
1499 (setq debbugs-gnu-current-suppress t)
1500 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1502 (use-package org-ref
1504 (b/setq-every '("~/usr/org/references.bib")
1505 reftex-default-bibliography
1506 org-ref-default-bibliography)
1508 org-ref-bibliography-notes "~/usr/org/notes.org"
1509 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1511 ;; (use-package fill-column-indicator)
1515 (("C-c w e" . (lambda ()
1517 (split-window-right)
1519 (erc-switch-to-buffer)))
1520 ("C-c w s l" . (lambda ()
1522 (split-window-right)
1524 ("C-c w s j" . (lambda ()
1526 (split-window-below)
1528 ("C-c w q" . quit-window))
1530 (split-width-threshold 150))
1532 (use-package windmove
1535 (("C-c w h" . windmove-left)
1536 ("C-c w j" . windmove-down)
1537 ("C-c w k" . windmove-up)
1538 ("C-c w l" . windmove-right)
1539 ("C-c w H" . windmove-swap-states-left)
1540 ("C-c w J" . windmove-swap-states-down)
1541 ("C-c w K" . windmove-swap-states-up)
1542 ("C-c w L" . windmove-swap-states-right)))
1546 :bind ("C-c a p" . pass)
1547 :hook (pass-mode . View-exit))
1549 (use-package pdf-tools
1551 :bind (:map pdf-view-mode-map
1552 ("<C-XF86Back>" . pdf-history-backward)
1553 ("<mouse-8>" . pdf-history-backward)
1554 ("<drag-mouse-8>" . pdf-history-backward)
1555 ("<C-XF86Forward>" . pdf-history-forward)
1556 ("<mouse-9>" . pdf-history-forward)
1557 ("<drag-mouse-9>" . pdf-history-forward)
1558 ("M-RET" . image-previous-line)
1559 ("C-s" . isearch-forward)
1560 ("s s" . isearch-forward))
1561 :config (pdf-tools-install nil t)
1562 :custom (pdf-view-resize-factor 1.05))
1564 (use-package org-pdftools
1566 :straight (:host github :repo "fuxialexander/org-pdftools")
1570 (with-eval-after-load 'org
1571 (require 'org-pdftools)))
1573 (use-package biblio)
1576 :hook (latex-mode . reftex-mode))
1578 (use-package reftex-cite
1580 :disabled ; enable to disable
1581 ; reftex-cite's default choice
1584 (defun reftex-get-bibkey-default ()
1585 "If the cursor is in a citation macro, return the word before the macro."
1586 (let* ((macro (reftex-what-macro 1)))
1588 (when (and macro (string-match "cite" (car macro)))
1589 (goto-char (cdr macro)))
1590 (reftex-this-word)))))
1592 (use-package minions
1594 :config (minions-mode))
1598 (dmenu-prompt-string "run: ")
1599 (dmenu-save-file (b/var "dmenu-items")))
1602 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1603 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1605 :straight (:host github :repo "clarete/eosd")
1611 (use-package scpaste
1614 (setq scpaste-http-destination "https://p.bndl.org"
1615 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1618 :bind ("C-c a e w" . eww)
1620 (eww-download-directory (file-name-as-directory
1621 (getenv "XDG_DOWNLOAD_DIR"))))
1624 ;;; Email (with Gnus)
1626 (defvar b/maildir (expand-file-name "~/mail/"))
1627 (with-eval-after-load 'recentf
1628 (add-to-list 'recentf-exclude b/maildir))
1631 b/gnus-init-file (b/etc "gnus")
1632 mail-user-agent 'gnus-user-agent
1633 read-mail-command 'gnus)
1636 :bind (("s-m" . gnus-plugged)
1637 ("s-M" . gnus-unplugged)
1638 ("C-c a m" . gnus-plugged)
1639 ("C-c a M" . gnus-unplugged))
1642 gnus-select-method '(nnnil "")
1643 gnus-secondary-select-methods
1644 '((nnimap "shemshak"
1645 (nnimap-stream plain)
1646 (nnimap-address "127.0.0.1")
1647 (nnimap-server-port 143)
1648 (nnimap-authenticator plain)
1649 (nnimap-user "amin@shemshak.local"))
1651 (nnimap-stream plain)
1652 (nnimap-address "127.0.0.1")
1653 (nnimap-server-port 143)
1654 (nnimap-authenticator plain)
1655 (nnimap-user "bandali@gnu.local")
1656 (nnimap-inbox "INBOX")
1657 (nnimap-split-methods 'nnimap-split-fancy)
1658 (nnimap-split-fancy (|
1659 ;; (: gnus-registry-split-fancy-with-parent)
1660 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1662 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1664 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
1666 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
1667 ;; *.lists.sr.ht, omitting one dot if present
1668 ;; add more \\.?\\([^.]*\\) if needed
1669 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
1671 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1673 (list ".*atreus.freelists.org" "l.atreus")
1674 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1675 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1676 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1677 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1678 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1679 ;; ----------------------------------
1680 ;; legend: (u)nsubscribed | (d)ead
1681 ;; ----------------------------------
1682 ;; otherwise, leave mail in INBOX
1685 (nnimap-stream plain)
1686 (nnimap-address "127.0.0.1")
1687 (nnimap-server-port 143)
1688 (nnimap-authenticator plain)
1689 (nnimap-user "abandali@uw.local")
1690 (nnimap-inbox "INBOX")
1691 (nnimap-split-methods 'nnimap-split-fancy)
1692 (nnimap-split-fancy (|
1693 ;; (: gnus-registry-split-fancy-with-parent)
1695 ("subject" "SE\\s-?212" "course.se212-f19")
1696 (from "SE\\s-?212" "course.se212-f19")
1700 (nnimap-stream plain)
1701 (nnimap-address "127.0.0.1")
1702 (nnimap-server-port 143)
1703 (nnimap-authenticator plain)
1704 (nnimap-user "abandali@csc.uw.local")))
1705 gnus-message-archive-group "nnimap+gnu:INBOX"
1708 (to-address . "atreus@freelists.org")
1709 (to-list . "atreus@freelists.org"))
1711 (to-address . "deepspec@lists.cs.princeton.edu")
1712 (to-list . "deepspec@lists.cs.princeton.edu")
1713 (list-identifier . "\\[deepspec\\]"))
1715 (to-address . "emacs-devel@gnu.org")
1716 (to-list . "emacs-devel@gnu.org"))
1717 ("l\\.help-gnu-emacs"
1718 (to-address . "help-gnu-emacs@gnu.org")
1719 (to-list . "help-gnu-emacs@gnu.org"))
1720 ("l\\.info-gnu-emacs"
1721 (to-address . "info-gnu-emacs@gnu.org")
1722 (to-list . "info-gnu-emacs@gnu.org"))
1723 ("l\\.emacs-orgmode"
1724 (to-address . "emacs-orgmode@gnu.org")
1725 (to-list . "emacs-orgmode@gnu.org")
1726 (list-identifier . "\\[O\\]"))
1727 ("l\\.emacs-tangents"
1728 (to-address . "emacs-tangents@gnu.org")
1729 (to-list . "emacs-tangents@gnu.org"))
1730 ("l\\.emacsconf-committee"
1731 (to-address . "emacsconf-committee@gnu.org")
1732 (to-list . "emacsconf-committee@gnu.org"))
1733 ("l\\.emacsconf-discuss"
1734 (to-address . "emacsconf-discuss@gnu.org")
1735 (to-list . "emacsconf-discuss@gnu.org"))
1736 ("l\\.emacsconf-register"
1737 (to-address . "emacsconf-register@gnu.org")
1738 (to-list . "emacsconf-register@gnu.org"))
1739 ("l\\.emacsconf-submit"
1740 (to-address . "emacsconf-submit@gnu.org")
1741 (to-list . "emacsconf-submit@gnu.org"))
1742 ("l\\.fencepost-users"
1743 (to-address . "fencepost-users@gnu.org")
1744 (to-list . "fencepost-users@gnu.org")
1745 (list-identifier . "\\[Fencepost-users\\]"))
1746 ("l\\.gnewsense-art"
1747 (to-address . "gnewsense-art@nongnu.org")
1748 (to-list . "gnewsense-art@nongnu.org")
1749 (list-identifier . "\\[gNewSense-art\\]"))
1750 ("l\\.gnewsense-dev"
1751 (to-address . "gnewsense-dev@nongnu.org")
1752 (to-list . "gnewsense-dev@nongnu.org")
1753 (list-identifier . "\\[Gnewsense-dev\\]"))
1754 ("l\\.gnewsense-users"
1755 (to-address . "gnewsense-users@nongnu.org")
1756 (to-list . "gnewsense-users@nongnu.org")
1757 (list-identifier . "\\[gNewSense-users\\]"))
1758 ("l\\.gnunet-developers"
1759 (to-address . "gnunet-developers@gnu.org")
1760 (to-list . "gnunet-developers@gnu.org")
1761 (list-identifier . "\\[GNUnet-developers\\]"))
1763 (to-address . "help-gnunet@gnu.org")
1764 (to-list . "help-gnunet@gnu.org")
1765 (list-identifier . "\\[Help-gnunet\\]"))
1767 (to-address . "bug-gnuzilla@gnu.org")
1768 (to-list . "bug-gnuzilla@gnu.org")
1769 (list-identifier . "\\[Bug-gnuzilla\\]"))
1771 (to-address . "gnuzilla-dev@gnu.org")
1772 (to-list . "gnuzilla-dev@gnu.org")
1773 (list-identifier . "\\[Gnuzilla-dev\\]"))
1775 (to-address . "guile-devel@gnu.org")
1776 (to-list . "guile-devel@gnu.org"))
1778 (to-address . "guile-user@gnu.org")
1779 (to-list . "guile-user@gnu.org"))
1781 (to-address . "guix-devel@gnu.org")
1782 (to-list . "guix-devel@gnu.org"))
1784 (to-address . "help-guix@gnu.org")
1785 (to-list . "help-guix@gnu.org"))
1787 (to-address . "info-guix@gnu.org")
1788 (to-list . "info-guix@gnu.org"))
1789 ("l\\.savannah-hackers-public"
1790 (to-address . "savannah-hackers-public@gnu.org")
1791 (to-list . "savannah-hackers-public@gnu.org"))
1792 ("l\\.savannah-users"
1793 (to-address . "savannah-users@gnu.org")
1794 (to-list . "savannah-users@gnu.org"))
1796 (to-address . "www-commits@gnu.org")
1797 (to-list . "www-commits@gnu.org"))
1799 (to-address . "www-discuss@gnu.org")
1800 (to-list . "www-discuss@gnu.org"))
1802 (to-address . "haskell-art@we.lurk.org")
1803 (to-list . "haskell-art@we.lurk.org")
1804 (list-identifier . "\\[haskell-art\\]"))
1806 (to-address . "haskell-cafe@haskell.org")
1807 (to-list . "haskell-cafe@haskell.org")
1808 (list-identifier . "\\[Haskell-cafe\\]"))
1810 (to-address . "notmuch@notmuchmail.org")
1811 (to-list . "notmuch@notmuchmail.org"))
1813 (to-address . "dev@lists.parabola.nu")
1814 (to-list . "dev@lists.parabola.nu")
1815 (list-identifier . "\\[Dev\\]"))
1816 ("l\\.~bandali\\.public-inbox"
1817 (to-address . "~bandali/public-inbox@lists.sr.ht")
1818 (to-list . "~bandali/public-inbox@lists.sr.ht"))
1819 ("l\\.~sircmpwn\\.free-writers-club"
1820 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
1821 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
1822 ("l\\.~sircmpwn\\.srht-admins"
1823 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
1824 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
1825 ("l\\.~sircmpwn\\.srht-announce"
1826 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
1827 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
1828 ("l\\.~sircmpwn\\.srht-dev"
1829 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
1830 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
1831 ("l\\.~sircmpwn\\.srht-discuss"
1832 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
1833 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1835 (to-address . "webmasters@gnu.org")
1836 (to-list . "webmasters@gnu.org"))
1843 gnus-large-newsgroup 50
1844 gnus-home-directory (b/var "gnus/")
1845 gnus-directory (concat gnus-home-directory "news/")
1846 message-directory (concat gnus-home-directory "mail/")
1847 nndraft-directory (concat gnus-home-directory "drafts/")
1848 gnus-save-newsrc-file nil
1849 gnus-read-newsrc-file nil
1850 gnus-interactive-exit nil
1851 gnus-gcc-mark-as-read t)
1853 (when (version< emacs-version "27")
1854 (with-eval-after-load 'nnmail
1856 'nnmail-split-abbrev-alist
1857 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1860 ;; (gnus-registry-initialize)
1862 (with-eval-after-load 'recentf
1863 (add-to-list 'recentf-exclude gnus-home-directory)))
1865 (use-package gnus-art
1868 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
1869 gnus-sorted-header-list '("^From:"
1885 "^Mail-Followup-To:"
1889 "^X-detected-operating-system:"
1894 gnus-visible-headers (mapconcat 'identity
1895 gnus-sorted-header-list
1897 ;; local-lapsed article dates
1898 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1899 gnus-article-date-headers '(user-defined)
1900 gnus-article-time-format
1902 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1903 (local (article-make-date-line date 'local))
1904 (combined-lapsed (article-make-date-line date
1907 (string-match " (.+" combined-lapsed)
1908 (match-string 0 combined-lapsed))))
1909 (concat local lapsed))))
1911 :map gnus-article-mode-map
1912 ("M-L" . org-store-link)))
1914 (use-package gnus-sum
1915 :bind (:map gnus-summary-mode-map
1916 :prefix-map b/gnus-summary-prefix-map
1918 ("r" . gnus-summary-reply)
1919 ("w" . gnus-summary-wide-reply)
1920 ("v" . gnus-summary-show-raw-article))
1923 :map gnus-summary-mode-map
1924 ("M-L" . org-store-link))
1925 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
1927 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
1928 gnus-thread-sort-by-subject
1929 gnus-thread-sort-by-date)))
1931 (use-package gnus-msg
1933 (defvar b/shemshak-signature "Amin Bandali
1934 https://shemshak.org/~amin")
1935 (defvar b/uw-signature "Amin Bandali, MMath Student
1936 Cheriton School of Computer Science
1937 University of Waterloo
1938 https://bandali.eu.org")
1939 (defvar b/csc-signature "Amin Bandali
1940 System Administrator, Systems Committee
1941 Computer Science Club, University of Waterloo
1942 https://csclub.uwaterloo.ca/~abandali")
1943 (setq gnus-message-replysign t
1946 (address "bandali@gnu.org"))
1947 ("nnimap\\+gnu:l\\..*"
1950 (organization "GNU"))
1951 ((header "subject" "ThankCRM")
1952 (to "webmasters-comment@gnu.org")
1954 (eval (setq b/message-cite-say-hi nil)))
1955 ("nnimap\\+shemshak:.*"
1956 (address "amin@shemshak.org")
1958 (signature b/shemshak-signature)
1959 (gcc "nnimap+shemshak:Sent")
1960 (eval (setq b/message-cite-say-hi t)))
1962 (address "bandali@uwaterloo.ca")
1964 (signature b/uw-signature))
1965 ("nnimap\\+uw:INBOX"
1966 (gcc "\"nnimap+uw:Sent Items\""))
1968 (address "bandali@csclub.uwaterloo.ca")
1969 (signature b/csc-signature)
1970 (gcc "nnimap+csc:Sent"))))
1971 :hook (gnus-message-setup . (lambda ()
1972 (unless (mml-secure-is-encrypted-p)
1973 (mml-secure-message-sign)))))
1975 (use-package gnus-topic
1976 :hook (gnus-group-mode . gnus-topic-mode)
1977 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
1979 (use-package gnus-agent
1981 (setq gnus-agent-synchronize-flags 'ask)
1982 :hook (gnus-group-mode . gnus-agent-mode))
1984 (use-package gnus-group
1986 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
1989 ;; problematic with ebdb's popup, *EBDB-Gnus*
1990 (use-package gnus-win
1992 (setq gnus-use-full-window nil)))
1994 (use-package gnus-dired
1995 :commands gnus-dired-mode
1997 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2000 (use-package gnus-utils
2002 (gnus-completing-read-function 'gnus-ido-completing-read)))
2004 (use-package mm-decode
2006 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2007 mm-decrypt-option 'known
2008 mm-verify-option 'known))
2012 (when (version< "27" emacs-version)
2013 (set-face-attribute 'mm-uu-extract nil :extend t))
2015 (mm-uu-diff-groups-regexp
2016 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2018 (use-package sendmail
2020 (setq sendmail-program (executable-find "msmtp")
2021 ;; message-sendmail-extra-arguments '("-v" "-d")
2022 mail-specify-envelope-from t
2023 mail-envelope-from 'header))
2025 (use-package message
2026 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2028 ;; redefine for a simplified In-Reply-To header
2029 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2030 (defun message-make-in-reply-to ()
2031 "Return the In-Reply-To header for this message."
2032 (when message-reply-headers
2033 (let ((from (mail-header-from message-reply-headers))
2034 (msg-id (mail-header-id message-reply-headers)))
2038 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2039 (defconst message-cite-style-bandali
2040 '((message-cite-function 'message-cite-original)
2041 (message-citation-line-function 'message-insert-formatted-citation-line)
2042 (message-cite-reply-position 'traditional)
2043 (message-yank-prefix "> ")
2044 (message-yank-cited-prefix ">")
2045 (message-yank-empty-prefix ">")
2046 (message-citation-line-format
2047 (if b/message-cite-say-hi
2048 (concat "Hi %F,\n\n" b/message-cite-style-format)
2049 b/message-cite-style-format)))
2050 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2051 (setq ;; message-cite-style 'message-cite-style-bandali
2052 message-kill-buffer-on-exit t
2053 message-send-mail-function 'message-send-mail-with-sendmail
2054 message-sendmail-envelope-from 'header
2055 message-subscribed-address-functions
2056 '(gnus-find-subscribed-addresses)
2057 message-dont-reply-to-names
2058 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2059 ;; (require 'company-ebdb)
2060 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2061 (message-mode . flyspell-mode)
2062 (message-mode . (lambda ()
2063 ;; (setq-local fill-column b/fill-column
2064 ;; message-fill-column b/fill-column)
2065 (make-local-variable 'company-idle-delay)
2066 (setq company-idle-delay 0.2))))
2068 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2069 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2070 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2072 (message-elide-ellipsis "[...]\n"))
2076 (use-package mml-sec
2078 (mml-secure-openpgp-encrypt-to-self t)
2079 (mml-secure-openpgp-sign-with-sender t))
2081 (use-package footnote
2084 ;; (setq footnote-start-tag ""
2085 ;; footnote-end-tag ""
2086 ;; footnote-style 'unicode)
2088 (:map message-mode-map
2089 :prefix-map b/footnote-prefix-map
2091 ("a" . footnote-add-footnote)
2092 ("b" . footnote-back-to-message)
2093 ("c" . footnote-cycle-style)
2094 ("d" . footnote-delete-footnote)
2095 ("g" . footnote-goto-footnote)
2096 ("r" . footnote-renumber-footnotes)
2097 ("s" . footnote-set-style)))
2102 :bind (:map gnus-group-mode-map ("e" . ebdb))
2104 (setq ebdb-sources (b/var "ebdb"))
2105 (with-eval-after-load 'swiper
2106 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2108 (use-package ebdb-com
2111 (use-package ebdb-complete
2114 ;; (setq ebdb-complete-mail 'capf)
2115 (ebdb-complete-enable))
2117 (use-package ebdb-message
2121 ;; (use-package company-ebdb
2123 ;; (defun company-ebdb--post-complete (_) nil))
2125 (use-package ebdb-gnus
2128 (ebdb-gnus-window-size 0.3))
2130 (use-package ebdb-mua
2133 :custom (ebdb-mua-pop-up t))
2135 ;; (use-package ebdb-message
2138 ;; (use-package ebdb-vcard
2141 (use-package message-x)
2144 (use-package message-x
2146 (message-x-completion-alist
2148 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2151 (quote message-newgroups-header-regexp))
2152 message-newgroups-header-regexp message-newsgroups-header-regexp)
2153 . message-expand-group))))))
2156 (use-package gnus-harvest
2157 :commands gnus-harvest-install
2160 (if (featurep 'message-x)
2161 (gnus-harvest-install 'message-x)
2162 (gnus-harvest-install))))
2164 (use-package gnus-article-treat-patch
2169 ;; note: be sure to customize faces with `:foreground "white"' when
2170 ;; using a theme with a white/light background :)
2171 (setq ft/gnus-article-patch-conditions
2172 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2175 ;;; IRC (with ERC and ZNC)
2178 :bind (("C-c b b" . erc-switch-to-buffer)
2180 ("M-a" . erc-track-switch-buffer))
2182 (erc-join-buffer 'bury)
2183 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2184 (erc-nick "bandali")
2186 (erc-rename-buffers t)
2187 (erc-server-reconnect-attempts 5)
2188 (erc-server-reconnect-timeout 3)
2190 (defun erc-cmd-OPME ()
2191 "Request chanserv to op me."
2192 (erc-message "PRIVMSG"
2193 (format "chanserv op %s %s"
2194 (erc-default-target)
2195 (erc-current-nick)) nil))
2196 (defun erc-cmd-DEOPME ()
2197 "Deop myself from current channel."
2198 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2199 (add-to-list 'erc-modules 'keep-place)
2200 (add-to-list 'erc-modules 'notifications)
2201 (add-to-list 'erc-modules 'smiley)
2202 (add-to-list 'erc-modules 'spelling)
2203 (add-to-list 'erc-modules 'scrolltoplace)
2204 (erc-update-modules))
2206 (use-package erc-fill
2209 (erc-fill-column 77)
2210 (erc-fill-function 'erc-fill-static)
2211 (erc-fill-static-center 18))
2213 (use-package erc-pcomplete
2216 (erc-pcomplete-nick-postfix ", "))
2218 (use-package erc-track
2220 :bind (("C-c a e t d" . erc-track-disable)
2221 ("C-c a e t e" . erc-track-enable))
2223 (erc-track-enable-keybindings nil)
2224 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2225 "324" "329" "332" "333" "353" "477"))
2226 (erc-track-position-in-mode-line t)
2227 (erc-track-priority-faces-only 'all)
2228 (erc-track-shorten-function nil))
2230 (use-package erc-hl-nicks
2233 (use-package erc-scrolltoplace
2237 :bind (("C-c a e e" . znc-erc)
2238 ("C-c a e a" . znc-all))
2240 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2242 ((null auth) (error "Couldn't find znca's authinfo"))
2243 (t (funcall (plist-get (car auth) :secret)))))))
2245 `(("znc.shemshak.org" 1337 t
2246 ((freenode "amin/freenode" ,pwd)))
2247 ("znc.shemshak.org" 1337 t
2248 ((oftc "amin/oftc" ,pwd)))))))
2251 ;;; Post initialization
2254 (message "Loading %s...done (%.3fs)" user-init-file
2255 (float-time (time-subtract (current-time)
2256 b/before-user-init-time)))
2258 ;;; init.el ends here