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
109 ;; No package.el (for emacs 26 and before)
110 (when (version< emacs-version
"27")
111 (setq package-enable-at-startup nil
)
112 ;; (package-initialize)
114 ;; for emacs 27 and later, we use early-init.el. see
115 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
118 (add-to-list 'load-path
119 (expand-file-name "lib/borg" user-emacs-directory
))
122 (setq borg-rewrite-urls-alist
123 '(("git@github.com:" .
"https://github.com/")
124 ("git@gitlab.com:" .
"https://gitlab.com/"))))
127 (if nil
; set to t when need to debug init
129 (setq use-package-verbose t
130 use-package-expand-minimally nil
131 use-package-compute-statistics t
133 (require 'use-package
))
134 (setq use-package-verbose nil
135 use-package-expand-minimally t
))
137 (setq use-package-always-defer t
)
143 ;; keep ~/.emacs.d clean
144 (use-package no-littering
147 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
148 (defalias 'b
/var
'no-littering-expand-var-file-name
))
150 (use-package auto-compile
153 (auto-compile-on-load-mode)
154 (auto-compile-on-save-mode)
155 (setq auto-compile-display-buffer nil
)
156 (setq auto-compile-mode-line-counter t
)
157 (setq auto-compile-source-recreate-deletes-dest t
)
158 (setq auto-compile-toggle-deletes-nonlib-dest t
)
159 (setq auto-compile-update-autoloads t
))
161 ;; separate custom file (don't want it mixing with init.el)
165 (setq custom-file
(b/etc
"custom.el"))
166 (when (file-exists-p custom-file
)
168 ;; while at it, treat themes as safe
169 (setf custom-safe-themes t
)
170 ;; only one custom theme at a time
172 (defadvice load-theme
(before clear-previous-themes activate
)
173 "Clear existing theme settings instead of layering them"
174 (mapc #'disable-theme custom-enabled-themes
))))
176 ;; load the secrets file if it exists, otherwise show a warning
179 (load (b/etc
"secrets"))))
181 ;; start up emacs server. see
182 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
185 :config
(or (server-running-p) (server-mode)))
190 (defmacro b
/setq-every
(value &rest vars
)
191 "Set all the variables from VARS to value VALUE."
192 (declare (indent defun
) (debug t
))
193 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
195 (defun b/start-process
(program &rest args
)
196 "Same as `start-process', but doesn't bother about name and buffer."
197 (let ((process-name (concat program
"_process"))
198 (buffer-name (generate-new-buffer-name
199 (concat program
"_output"))))
200 (apply #'start-process
201 process-name buffer-name program args
)))
203 (defun b/dired-start-process
(program &optional args
)
204 "Open current file with a PROGRAM."
205 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
206 ;; be nil, so remove it).
207 (apply #'b
/start-process
209 (remove nil
(list args
(dired-get-file-for-visit)))))
211 (defun b/add-elisp-section
()
215 (insert "\n\f\n;;; "))
217 ;; (defvar b/fill-column 47
218 ;; "My custom `fill-column'.")
220 (defconst b
/asterism
"* * *")
222 (defun b/insert-asterism
()
223 "Insert a centred asterism."
228 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
233 (defun b/no-mouse-autoselect-window
()
234 "Conveniently disable `focus-follows-mouse'.
235 For disabling the behaviour for certain buffers and/or modes."
236 (make-local-variable 'mouse-autoselect-window
)
237 (setq mouse-autoselect-window nil
))
239 (defun b/kill-current-buffer
()
240 "Kill the current buffer."
241 ;; also see https://redd.it/64xb3q
243 (kill-buffer (current-buffer)))
248 ;;;; C-level customizations
252 enable-recursive-minibuffers t
253 resize-mini-windows t
254 ;; more useful frame titles
255 frame-title-format
'("" invocation-name
" - "
257 (if (buffer-file-name)
258 (abbreviate-file-name (buffer-file-name))
260 ;; i don't feel like jumping out of my chair every now and again; so
261 ;; don't BEEP! at me, emacs
262 ring-bell-function
'ignore
265 ;; scroll-conservatively 10000
267 scroll-conservatively
10
268 scroll-preserve-screen-position
1
269 ;; focus follows mouse
270 mouse-autoselect-window t
)
273 ;; always use space for indentation
281 (dolist (ft (fontset-list))
285 (font-spec :name
"Source Code Pro" :size
14))
289 (font-spec :name
"DejaVu Sans Mono")
296 ;; :name "Symbola monospacified for DejaVu Sans Mono")
302 ;; (font-spec :name "DejaVu Sans Mono")
308 (font-spec :name
"DejaVu Sans Mono" :size
14)
312 ;;;; Elisp-level customizations
318 ;; don't need to see the startup echo area message
319 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
321 ;; i want *scratch* as my startup buffer
322 (initial-buffer-choice t
)
323 ;; i don't need the default hint
324 (initial-scratch-message nil
)
325 ;; use customizable text-mode as major mode for *scratch*
326 ;; (initial-major-mode 'text-mode)
327 ;; inhibit buffer list when more than 2 files are loaded
328 (inhibit-startup-buffer-menu t
)
329 ;; don't need to see the startup screen or echo area message
330 (inhibit-startup-screen t
)
331 (inhibit-startup-echo-area-message user-login-name
))
337 ;; backups (C-h v make-backup-files RET)
338 (backup-by-copying t
)
340 (delete-old-versions t
)
343 (auto-save-file-name-transforms
344 `((".*" ,(b/var
"auto-save/") t
)))
346 ;; insert newline at the end of files
347 (require-final-newline t
)
349 ;; open read-only file buffers in view-mode
350 ;; (enables niceties like `q' for quit)
353 ;; disable disabled commands
354 (setq disabled-command-function nil
)
356 ;; lazy-person-friendly yes/no prompts
357 (defalias 'yes-or-no-p
#'y-or-n-p
)
359 ;; enable automatic reloading of changed buffers and files
360 (use-package autorevert
363 (global-auto-revert-mode 1)
365 (auto-revert-verbose nil
)
366 (global-auto-revert-non-file-buffers nil
))
368 ;; time and battery in mode-line
374 (display-time-default-load-average nil
)
375 (display-time-format " %a %b %-e %-l:%M%P")
376 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
377 (display-time-use-mail-icon t
))
382 (display-battery-mode)
384 (battery-mode-line-format "%p%% %t"))
390 ;; (fringe-mode '(3 . 1))
396 ;; enable winner-mode (C-h f winner-mode RET)
401 ;; don't display *compilation* buffer on success. based on
402 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
403 ;; instead of the now obsolete `flet'.
404 (defun b/compilation-finish-function
(buffer outstr
)
405 (unless (string-match "finished" outstr
)
406 (switch-to-buffer-other-window buffer
))
409 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
413 (defadvice compilation-start
414 (around inhibit-display
415 (command &optional mode name-function highlight-regexp
))
416 (if (not (string-match "^\\(find\\|grep\\)" command
))
417 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
418 (save-window-excursion ad-do-it
))
420 (ad-activate 'compilation-start
))
424 ;; allow scrolling in Isearch
425 (isearch-allow-scroll t
)
426 ;; search for non-ASCII characters: i’d like non-ASCII characters such
427 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
428 ;; counterpart. shoutout to
429 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
430 (search-default-mode #'char-fold-to-regexp
))
432 ;; uncomment to extend the above behaviour to query-replace
436 (replace-char-fold t
)))
439 :bind
("C-x v C-=" . vc-ediff
))
444 (vc-git-print-log-follow t
))
447 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
448 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
449 (ediff-split-window-function 'split-window-horizontally
)))
451 (use-package face-remap
453 ;; gentler font resizing
454 (text-scale-mode-step 1.05))
459 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
460 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
461 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
463 (use-package pixel-scroll
465 :config
(pixel-scroll-mode 1))
467 (use-package epg-config
469 ;; ask for GPG passphrase in minibuffer
470 ;; this will fail if gpg>=2.1 is not available
471 (if (version< "27" emacs-version
)
472 (setq epg-pinentry-mode
'loopback
)
473 (setq epa-pinentry-mode
'loopback
))
475 (epg-gpg-program (executable-find "gpg")))
480 (use-package pinentry
483 :after
(epa epg server
)
485 ;; workaround for systemd-based distros:
486 ;; (setq pinentry--socket-dir server-socket-dir)
489 (use-package auth-source
491 (auth-sources '("~/.authinfo.gpg"))
492 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
500 ("C-c e b" . eval-buffer
)
501 ("C-c e e" . eval-last-sexp
)
502 ("C-c e r" . eval-region
)
504 ("C-c e i" . emacs-init-time
)
505 ("C-c e u" . emacs-uptime
)
506 ("C-c e v" . emacs-version
)
508 ("C-c f ." . find-file
)
509 ("C-c f d" . find-name-dired
)
510 ("C-c f l" . find-library
)
512 ("C-c F m" . make-frame-command
)
513 ("C-c F d" . delete-frame
)
514 ("C-c F D" . server-edit
)
516 ("C-S-h C" . describe-char
)
517 ("C-S-h F" . describe-face
)
519 ("C-c x" . execute-extended-command
)
521 ("C-x k" . b
/kill-current-buffer
)
522 ("C-x K" . kill-buffer
)
523 ("C-x s" . save-buffer
)
524 ("C-x S" . save-some-buffers
)
526 :map emacs-lisp-mode-map
527 ("<C-return>" . b
/add-elisp-section
))
529 (when (display-graphic-p)
530 (unbind-key "C-z" global-map
))
533 ;; for back and forward mouse keys
534 ("<XF86Back>" . previous-buffer
)
535 ("<mouse-8>" . previous-buffer
)
536 ;; ("<drag-mouse-8>" . previous-buffer)
537 ("<XF86Forward>" . next-buffer
)
538 ("<mouse-9>" . next-buffer
)
539 ;; ("<drag-mouse-9>" . next-buffer)
540 ;; ("<drag-mouse-2>" . kill-this-buffer)
541 ;; ("<drag-mouse-3>" . switch-to-buffer)
545 ;;; Essential packages
550 (convert-standard-filename "lisp") user-emacs-directory
))
553 (require 'bandali-exwm
))
555 (require 'bandali-org
)
557 ;; *the* right way to do git
559 :bind
(("C-x g" . magit-status
)
560 ("C-c g g" . magit-status
)
561 ("C-c g b" . magit-blame-addition
)
562 ("C-c g l" . magit-log-buffer-file
))
564 (magit-add-section-hook 'magit-status-sections-hook
565 'magit-insert-modules
566 'magit-insert-stashes
568 ;; (magit-add-section-hook 'magit-status-sections-hook
569 ;; 'magit-insert-ignored-files
570 ;; 'magit-insert-untracked-files
572 (setq magit-repository-directories
'(("~/.emacs.d/" .
0)
574 (nconc magit-section-initial-visibility-alist
575 '(([unpulled status
] . show
)
576 ([unpushed status
] . show
)))
578 (magit-diff-refine-hunk t
)
579 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
580 ;; (magit-completing-read-function 'magit-ido-completing-read)
581 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
583 ;; recently opened files
587 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
591 (recentf-max-saved-items 2000))
597 (:map ido-common-completion-map
598 ([escape] . minibuffer-keyboard-quit)
599 ("DEL" . b/ido-backspace))
602 (defun b/ido-backspace ()
603 "Forward to `backward-delete-char'. On error (read-only), quit."
606 (backward-delete-char 1)
608 (minibuffer-keyboard-quit))))
612 (ido-enable-flex-matching t)
613 ;; (ido-enable-regexp t)
614 ;; (ido-enable-prefix t)
615 (ido-max-window-height 10)
616 (ido-use-virtual-buffers t))
618 (use-package ido-vertical-mode
621 (ido-vertical-mode 1)
623 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
624 (ido-vertical-show-count t))
626 (use-package ido-completing-read+
630 (ido-ubiquitous-mode 1))
632 (use-package crm-custom
637 (use-package icomplete
650 (:map ivy-minibuffer-map
651 ([escape] . keyboard-escape-quit
)
652 ([S-up
] . ivy-previous-history-element
)
653 ([S-down
] . ivy-next-history-element
)
654 ("DEL" . ivy-backward-delete-char
))
658 ivy-use-virtual-buffers t
659 ivy-virtual-abbreviate
'abbreviate
660 ivy-count-format
"%d/%d ")
662 (defvar b
/ivy-ignore-buffer-modes
'(magit-mode erc-mode dired-mode
))
663 (defun b/ivy-ignore-buffer-p
(str)
664 "Return non-nil if str names a buffer with a major mode
665 derived from one of `b/ivy-ignore-buffer-modes'.
667 This function is intended for use with `ivy-ignore-buffers'."
668 (let* ((buf (get-buffer str
))
669 (mode (and buf
(buffer-local-value 'major-mode buf
))))
671 (apply #'provided-mode-derived-p mode b
/ivy-ignore-buffer-modes
))))
672 (add-to-list 'ivy-ignore-buffers
'b
/ivy-ignore-buffer-p
)
676 (ivy-minibuffer-match-face-1 ((t (:background
"#eeeeee"))))
677 (ivy-minibuffer-match-face-2 ((t (:background
"#e7e7e7" :weight bold
))))
678 (ivy-minibuffer-match-face-3 ((t (:background
"light goldenrod" :weight semi-bold
))))
679 (ivy-minibuffer-match-face-4 ((t (:background
"misty rose" :weight semi-bold
))))
680 (ivy-current-match ((((class color
) (background light
))
681 :background
"#d7d7d7" :foreground
"black")
682 (((class color
) (background dark
))
683 :background
"#65a7e2" :foreground
"black"))))
688 :bind
(("C-S-s" . swiper-isearch
)))
693 :bind
(("C-c f r" . counsel-recentf
)
694 :map minibuffer-local-map
695 ("C-r" . counsel-minibuffer-history
))
698 (defalias 'locate
#'counsel-locate
))
704 :bind
("C-c a s e" . eshell
)
706 (eval-when-compile (defvar eshell-prompt-regexp
))
707 (defun b/eshell-quit-or-delete-char
(arg)
709 (if (and (eolp) (looking-back eshell-prompt-regexp nil
))
710 (eshell-life-is-too-much)
713 (defun b/eshell-clear
()
715 (let ((inhibit-read-only t
))
719 (defun b/eshell-setup
()
720 (make-local-variable 'company-idle-delay
)
721 (defvar company-idle-delay
)
722 (setq company-idle-delay nil
)
723 (bind-keys :map eshell-mode-map
724 ("C-d" . b
/eshell-quit-or-delete-char
)
725 ("C-S-l" . b
/eshell-clear
)
726 ("M-r" . counsel-esh-history
)
727 ;; ([tab] . company-complete)
729 (if (version< "27" emacs-version
)
730 (bind-keys :map eshell-hist-mode-map
731 ("M-r" . counsel-esh-history
))
732 (bind-keys :map eshell-mode-map
733 ("M-r" . counsel-esh-history
))))
736 eshell-prompt-regexp
"\\(.*\n\\)*[$#] "
737 eshell-prompt-function
740 (propertize (format "%s@%s:" (user-login-name) (system-name))
742 (propertize (abbreviate-file-name default-directory
)
743 'face
'font-lock-comment-face
)
744 (propertize "\n" 'face
'default
)
746 (propertize "#" 'face
'red
)
747 (propertize "$" 'face
'default
))
748 (propertize " " 'face
'default
))))
750 :hook
(eshell-mode . b
/eshell-setup
)
752 (eshell-hist-ignoredups t
)
753 (eshell-input-filter 'eshell-input-filter-initial-space
))
757 (("C-x C-b" . ibuffer
)
758 :map ibuffer-mode-map
759 ("P" . ibuffer-backward-filter-group
)
760 ("N" . ibuffer-forward-filter-group
)
761 ("M-p" . ibuffer-do-print
)
762 ("M-n" . ibuffer-do-shell-command-pipe-replace
))
764 ;; Use human readable Size column instead of original one
765 (define-ibuffer-column size-h
766 (:name
"Size" :inline t
)
768 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
769 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
770 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
771 (t (format "%8d" (buffer-size)))))
773 (ibuffer-saved-filter-groups
775 ("dired" (mode . dired-mode
))
776 ("org" (mode . org-mode
))
779 (mode . gnus-group-mode
)
780 (mode . gnus-summary-mode
)
781 (mode . gnus-article-mode
)
782 ;; not really, but...
783 (mode . message-mode
)))
802 (mode . emacs-lisp-mode
)
804 (mode . haskell-mode
)
807 (mode . alloy-mode
)))
811 (mode . latex-mode
)))
814 (name .
"^\\*scratch\\*$")
815 (name .
"^\\*Messages\\*$")))
816 ("exwm" (mode . exwm-mode
))
817 ("erc" (mode . erc-mode
)))))
819 '((mark modified read-only locked
" "
820 (name 72 72 :left
:elide
)
824 (mode 16 16 :left
:elide
)
825 " " filename-and-process
)
829 :hook
(ibuffer .
(lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
833 :hook
(prog-mode . outline-minor-mode
)
836 outline-minor-mode-map
837 ("<s-tab>" . outline-toggle-children
)
838 ("M-p" . outline-previous-visible-heading
)
839 ("M-n" . outline-next-visible-heading
)
840 :prefix-map b
/outline-prefix-map
842 ("TAB" . outline-toggle-children
)
843 ("a" . outline-hide-body
)
844 ("H" . outline-hide-body
)
845 ("S" . outline-show-all
)
846 ("h" . outline-hide-subtree
)
847 ("s" . outline-show-subtree
)))
850 :custom
(ls-lisp-dirs-first t
))
854 (setq dired-dwim-target t
855 dired-listing-switches
"-alh"
856 ls-lisp-use-insert-directory-program nil
)
858 ;; easily diff 2 marked files
859 ;; https://oremacs.com/2017/03/18/dired-ediff/
860 (defun dired-ediff-files ()
863 (defvar ediff-after-quit-hook-internal
)
864 (let ((files (dired-get-marked-files))
865 (wnd (current-window-configuration)))
866 (if (<= (length files
) 2)
867 (let ((file1 (car files
))
868 (file2 (if (cdr files
)
872 (dired-dwim-target-directory)))))
873 (if (file-newer-than-file-p file1 file2
)
874 (ediff-files file2 file1
)
875 (ediff-files file1 file2
))
876 (add-hook 'ediff-after-quit-hook-internal
878 (setq ediff-after-quit-hook-internal nil
)
879 (set-window-configuration wnd
))))
880 (error "no more than 2 files should be marked"))))
883 (setq dired-guess-shell-alist-user
884 '(("\\.pdf\\'" "evince" "zathura" "okular")
885 ("\\.doc\\'" "libreoffice")
886 ("\\.docx\\'" "libreoffice")
887 ("\\.ppt\\'" "libreoffice")
888 ("\\.pptx\\'" "libreoffice")
889 ("\\.xls\\'" "libreoffice")
890 ("\\.xlsx\\'" "libreoffice")
891 ("\\.flac\\'" "mpv")))
892 :bind
(:map dired-mode-map
893 ("b" . dired-up-directory
)
894 ("E" . dired-ediff-files
)
895 ("e" . dired-toggle-read-only
)
896 ("\\" . dired-hide-details-mode
)
899 (b/dired-start-process
"zathura"))))
900 :hook
(dired-mode . dired-hide-details-mode
))
904 (temp-buffer-resize-mode)
905 (setq help-window-select t
))
909 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
910 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
911 (add-to-list 'tramp-default-proxies-alist
912 (list (regexp-quote (system-name)) nil nil
)))
914 (use-package doc-view
915 :bind
(:map doc-view-mode-map
916 ("M-RET" . image-previous-line
)))
921 ;; highlight uncommitted changes in the left fringe
925 (setq diff-hl-draw-borders nil
)
926 (global-diff-hl-mode)
927 :hook
(magit-post-refresh . diff-hl-magit-post-refresh
))
929 ;; display Lisp objects at point in the echo area
931 :when
(version< "25" emacs-version
)
932 :config
(global-eldoc-mode))
934 ;; highlight matching parens
937 :config
(show-paren-mode))
939 (use-package elec-pair
941 :config
(electric-pair-mode))
944 :config
(column-number-mode)
946 ;; Save what I copy into clipboard from other applications into Emacs'
947 ;; kill-ring, which would allow me to still be able to easily access
948 ;; it in case I kill (cut or copy) something else inside Emacs before
949 ;; yanking (pasting) what I'd originally intended to.
950 (save-interprogram-paste-before-kill t
))
952 ;; save minibuffer history
953 (use-package savehist
957 (add-to-list 'savehist-additional-variables
'kill-ring
))
959 ;; automatically save place in files
960 (use-package saveplace
961 :when
(version< "25" emacs-version
)
962 :config
(save-place-mode))
964 (use-package prog-mode
965 :config
(global-prettify-symbols-mode)
966 (defun indicate-buffer-boundaries-left ()
967 (setq indicate-buffer-boundaries
'left
))
968 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
970 (use-package text-mode
971 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
972 :hook
((text-mode . indicate-buffer-boundaries-left
)
973 (text-mode . flyspell-mode
)))
975 (use-package conf-mode
984 (:map company-active-map
985 ([tab] . company-complete-common-or-cycle)
986 ([escape] . company-abort)
987 ("C-p" . company-select-previous-or-abort)
988 ("C-n" . company-select-next-or-abort))
990 (company-minimum-prefix-length 1)
991 (company-selection-wrap-around t)
992 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
993 (company-dabbrev-downcase nil)
994 (company-dabbrev-ignore-case nil)
996 ;; (global-company-mode t)
999 (use-package flycheck
1001 :hook (prog-mode . flycheck-mode)
1003 (:map flycheck-mode-map
1004 ("M-P" . flycheck-previous-error)
1005 ("M-N" . flycheck-next-error))
1007 ;; Use the load-path from running Emacs when checking elisp files
1008 (setq flycheck-emacs-lisp-load-path 'inherit)
1010 ;; Only flycheck when I actually save the buffer
1011 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1012 :custom (flycheck-mode-line-prefix "flyc"))
1014 (use-package flyspell)
1016 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1020 ;; ’ can be part of a word
1021 (setq ispell-local-dictionary-alist
1022 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1023 "['\x2019]" nil ("-B") nil utf-8))
1024 ispell-program-name (executable-find "hunspell"))
1025 ;; don't send ’ to the subprocess
1026 (defun endless/replace-apostrophe (args)
1027 (cons (replace-regexp-in-string
1030 (advice-add #'ispell-send-string :filter-args
1031 #'endless/replace-apostrophe)
1033 ;; convert ' back to ’ from the subprocess
1034 (defun endless/replace-quote (args)
1035 (if (not (derived-mode-p 'org-mode))
1037 (cons (replace-regexp-in-string
1040 (advice-add #'ispell-parse-output :filter-args
1041 #'endless/replace-quote))
1044 :hook (text-mode . abbrev-mode))
1047 ;;; Programming modes
1049 (use-package lisp-mode
1051 (defun indent-spaces-mode ()
1052 (setq indent-tabs-mode nil))
1053 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1056 :hook (emacs-lisp-mode . reveal-mode))
1058 (use-package elisp-mode)
1060 ;; (use-package alloy-mode
1061 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1062 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1064 ;; (setq alloy-basic-offset 2)
1065 ;; ;; (defun b/alloy-simple-indent (start end)
1066 ;; ;; (interactive "r")
1067 ;; ;; ;; (if (region-active-p)
1068 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1070 ;; ;; ;; (indent-rigidly (line-beginning-position)
1071 ;; ;; ;; (line-end-position)
1072 ;; ;; ;; alloy-basic-offset)))
1073 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1074 ;; :bind (:map alloy-mode-map
1075 ;; ("RET" . electric-newline-and-maybe-indent)
1076 ;; ;; ("TAB" . b/alloy-simple-indent)
1077 ;; ("TAB" . indent-for-tab-command))
1078 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1080 (eval-when-compile (defvar lean-mode-map))
1081 (use-package lean-mode
1083 :bind (:map lean-mode-map
1084 ("S-SPC" . company-complete))
1086 (require 'lean-input)
1087 (setq default-input-method "Lean"
1088 lean-input-tweak-all '(lean-input-compose
1089 (lean-input-prepend "/")
1090 (lean-input-nonempty))
1091 lean-input-user-translations '(("/" "/")))
1094 (use-package mhtml-mode)
1096 (use-package sgml-mode
1098 (setq sgml-basic-offset 0))
1100 (use-package css-mode
1102 (setq css-indent-offset 2))
1104 (use-package emmet-mode
1105 :after (:any mhtml-mode css-mode sgml-mode)
1106 :bind* (("C-)" . emmet-next-edit-point)
1107 ("C-(" . emmet-prev-edit-point))
1109 (unbind-key "C-j" emmet-mode-keymap)
1110 (setq emmet-move-cursor-between-quotes t)
1111 :hook (css-mode html-mode sgml-mode))
1113 (use-package geiser)
1115 (use-package geiser-guile
1117 (setq geiser-guile-load-path "~/src/git/guix"))
1124 (font-latex-fontify-sectioning 'color)))
1126 (use-package go-mode
1129 (use-package po-mode
1131 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1133 (use-package tex-mode
1136 (lambda (p) (string-match "^---?" (car p)))
1137 tex--prettify-symbols-alist)
1138 :hook ((tex-mode . auto-fill-mode)
1139 (tex-mode . flyspell-mode)))
1141 ;; (use-package george-mode
1142 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1143 ;; :mode "\\.grg\\'")
1148 (add-to-list 'custom-theme-load-path
1150 (convert-standard-filename "lisp") user-emacs-directory))
1151 (load-theme 'tangomod t)
1153 (use-package smart-mode-line
1154 :commands (sml/apply-theme)
1157 ;; thanks, but no thnaks; don't make fixed-width fills.
1158 (defun sml/fill-for-buffer-identification () "")
1159 (setq sml/theme 'tangomod)
1161 (smart-mode-line-enable))
1163 (use-package doom-modeline
1166 :hook (after-init . doom-modeline-init)
1168 (doom-modeline-buffer-file-name-style 'relative-to-project))
1170 (use-package doom-themes)
1176 (setq x-underline-at-descent-line t)
1177 (let ((line (face-attribute 'mode-line :underline)))
1178 (set-face-attribute 'mode-line nil :overline line)
1179 (set-face-attribute 'mode-line-inactive nil :overline line)
1180 (set-face-attribute 'mode-line-inactive nil :underline line)
1181 (set-face-attribute 'mode-line nil :box nil)
1182 (set-face-attribute 'mode-line-inactive nil :box nil)
1183 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1184 (moody-replace-mode-line-buffer-identification)
1185 (moody-replace-vc-mode))
1187 (use-package mini-modeline
1190 :config (mini-modeline-mode))
1192 (defvar b/org-mode-font-lock-keywords
1193 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1194 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1195 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1196 (4 '(:foreground "#c5c8c6") t))) ; title
1197 "For use with the `doom-tomorrow-night' theme.")
1199 (defun b/lights-on ()
1200 "Enable my favourite light theme."
1202 (mapc #'disable-theme custom-enabled-themes)
1203 (load-theme 'tangomod t)
1204 (when (featurep 'smart-mode-line)
1205 (sml/apply-theme 'tangomod))
1206 (font-lock-remove-keywords
1207 'org-mode b/org-mode-font-lock-keywords)
1208 (when (featurep 'erc-hl-nicks)
1209 (erc-hl-nicks-reset-face-table))
1210 (when (featurep 'exwm-systemtray)
1211 (exwm-systemtray--refresh)))
1213 (defun b/lights-off ()
1216 (mapc #'disable-theme custom-enabled-themes)
1217 (load-theme 'doom-one t)
1218 (when (featurep 'smart-mode-line)
1219 (sml/apply-theme 'automatic))
1220 (font-lock-add-keywords
1221 'org-mode b/org-mode-font-lock-keywords t)
1222 (when (featurep 'erc-hl-nicks)
1223 (erc-hl-nicks-reset-face-table))
1224 (when (featurep 'exwm-systemtray)
1225 (exwm-systemtray--refresh)))
1228 ("C-c t d" . b/lights-off)
1229 ("C-c t l" . b/lights-on))
1232 ;;; Emacs enhancements & auxiliary packages
1235 :config (setq Man-width 80))
1237 (use-package which-key
1240 (which-key-add-key-based-replacements
1241 ;; prefixes for global prefixes and minor modes
1244 "C-x RET" "coding system"
1246 "C-x @" "event modifiers"
1247 "C-x a" "abbrev/expand"
1248 "C-x r" "rectangle/register/bookmark"
1250 "C-x v" "version control"
1254 ;; prefixes for my personal bindings
1256 "C-c a" "applications"
1261 "C-c c" "compile-and-comments"
1267 "C-c m" "multiple-cursors"
1268 "C-c p" "projectile"
1269 "C-c p s" "projectile/search"
1270 "C-c p x" "projectile/execute"
1271 "C-c p 4" "projectile/other-window"
1277 ;; prefixes for major modes
1278 (which-key-add-major-mode-key-based-replacements 'message-mode
1279 "C-c f n" "footnote")
1280 (which-key-add-major-mode-key-based-replacements 'org-mode
1281 "C-c C-v" "org-babel")
1285 (which-key-add-column-padding 5)
1286 (which-key-max-description-length 32))
1288 (use-package crux ; results in Waiting for git... [2 times]
1290 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1291 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1292 ("C-c f C" . crux-copy-file-preserve-attributes)
1293 ("C-c f D" . crux-delete-file-and-buffer)
1294 ("C-c f R" . crux-rename-file-and-buffer)
1295 ("C-c j" . crux-top-join-line)
1296 ("C-S-j" . crux-top-join-line)))
1299 :bind (("C-a" . mwim-beginning-of-code-or-line)
1300 ("C-e" . mwim-end-of-code-or-line)
1301 ("<home>" . mwim-beginning-of-line-or-code)
1302 ("<end>" . mwim-end-of-line-or-code)))
1304 (use-package projectile
1307 :bind-keymap ("C-c p" . projectile-command-map)
1311 (defun b/projectile-mode-line-fun ()
1312 "Report project name and type in the modeline."
1313 (let ((project-name (projectile-project-name))
1314 (project-type (projectile-project-type)))
1316 projectile-mode-line-prefix
1318 (format ":%s" project-type)
1320 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1322 (defun my-projectile-invalidate-cache (&rest _args)
1323 ;; ignore the args to `magit-checkout'
1324 (projectile-invalidate-cache nil))
1326 (eval-after-load 'magit-branch
1328 (advice-add 'magit-checkout
1329 :after #'my-projectile-invalidate-cache)
1330 (advice-add 'magit-branch-and-checkout
1331 :after #'my-projectile-invalidate-cache)))
1333 (projectile-completion-system 'ivy)
1334 (projectile-mode-line-prefix " proj"))
1336 (use-package helpful
1339 (("C-S-h c" . helpful-command)
1340 ("C-S-h f" . helpful-callable) ; helpful-function
1341 ("C-S-h v" . helpful-variable)
1342 ("C-S-h k" . helpful-key)
1343 ("C-S-h p" . helpful-at-point)))
1345 (use-package unkillable-scratch
1348 (unkillable-scratch 1)
1350 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1353 ;; | make pretty boxed quotes like this
1355 (use-package boxquote
1358 (:prefix-map b/boxquote-prefix-map
1360 ("b" . boxquote-buffer)
1361 ("B" . boxquote-insert-buffer)
1362 ("d" . boxquote-defun)
1363 ("F" . boxquote-insert-file)
1364 ("hf" . boxquote-describe-function)
1365 ("hk" . boxquote-describe-key)
1366 ("hv" . boxquote-describe-variable)
1367 ("hw" . boxquote-where-is)
1368 ("k" . boxquote-kill)
1369 ("p" . boxquote-paragraph)
1370 ("q" . boxquote-boxquote)
1371 ("r" . boxquote-region)
1372 ("s" . boxquote-shell-command)
1373 ("t" . boxquote-text)
1374 ("T" . boxquote-title)
1375 ("u" . boxquote-unbox)
1376 ("U" . boxquote-unbox-region)
1377 ("y" . boxquote-yank)
1378 ("M-q" . boxquote-fill-paragraph)
1379 ("M-w" . boxquote-kill-ring-save)))
1381 (use-package orgalist
1382 ;; breaks auto-fill-mode, showing this error:
1383 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1386 :hook (message-mode . orgalist-mode))
1388 ;; highlight TODOs in buffers
1389 (use-package hl-todo
1392 (global-hl-todo-mode))
1394 (use-package multi-term
1397 :bind (("C-c a s m m" . multi-term)
1398 ("C-c a s m d" . multi-term-dedicated-toggle)
1399 ("C-c a s m p" . multi-term-prev)
1400 ("C-c a s m n" . multi-term-next)
1402 ("C-c C-j" . term-char-mode))
1404 (setq multi-term-program "screen"
1405 multi-term-program-switches (concat "-c"
1406 (getenv "XDG_CONFIG_HOME")
1408 ;; TODO: add separate bindings for connecting to existing
1409 ;; session vs. always creating a new one
1410 multi-term-dedicated-select-after-open-p t
1411 multi-term-dedicated-window-height 20
1412 multi-term-dedicated-max-window-height 30
1414 '(("C-c C-c" . term-interrupt-subjob)
1415 ("C-c C-e" . term-send-esc)
1416 ("C-c C-j" . term-line-mode)
1418 ;; ("C-y" . term-paste)
1419 ("C-y" . term-send-raw)
1420 ("M-f" . term-send-forward-word)
1421 ("M-b" . term-send-backward-word)
1422 ("M-p" . term-send-up)
1423 ("M-n" . term-send-down)
1424 ("M-j" . term-send-raw-meta)
1425 ("M-y" . term-send-raw-meta)
1426 ("M-/" . term-send-raw-meta)
1427 ("M-0" . term-send-raw-meta)
1428 ("M-1" . term-send-raw-meta)
1429 ("M-2" . term-send-raw-meta)
1430 ("M-3" . term-send-raw-meta)
1431 ("M-4" . term-send-raw-meta)
1432 ("M-5" . term-send-raw-meta)
1433 ("M-6" . term-send-raw-meta)
1434 ("M-7" . term-send-raw-meta)
1435 ("M-8" . term-send-raw-meta)
1436 ("M-9" . term-send-raw-meta)
1437 ("<C-backspace>" . term-send-backward-kill-word)
1438 ("<M-DEL>" . term-send-backward-kill-word)
1439 ("M-d" . term-send-delete-word)
1440 ("M-," . term-send-raw)
1441 ("M-." . comint-dynamic-complete))
1442 term-unbind-key-alist
1443 '("C-z" "C-x" "C-c" "C-h"
1447 (use-package page-break-lines
1450 (page-break-lines-max-width fill-column)
1452 (global-page-break-lines-mode))
1454 (use-package expand-region
1455 :bind ("C-=" . er/expand-region))
1457 (use-package multiple-cursors
1459 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1460 (:prefix-map b/mc-prefix-map
1462 ("c" . mc/edit-lines)
1463 ("n" . mc/mark-next-like-this)
1464 ("p" . mc/mark-previous-like-this)
1465 ("a" . mc/mark-all-like-this))))
1467 (use-package yasnippet
1470 (defconst yas-verbosity-cur yas-verbosity)
1471 (setq yas-verbosity 2)
1472 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1474 (setq yas-verbosity yas-verbosity-cur)
1476 (defun b/yas--maybe-expand-key-filter (cmd)
1477 (when (and (yas--maybe-expand-key-filter cmd)
1478 (not (bound-and-true-p git-commit-mode)))
1480 (defconst b/yas-maybe-expand
1481 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1482 (define-key yas-minor-mode-map
1483 (kbd "SPC") b/yas-maybe-expand)
1487 (use-package debbugs
1489 (("C-c D d" . debbugs-gnu)
1490 ("C-c D b" . debbugs-gnu-bugs)
1493 (interactive) ; bug-gnu-emacs
1494 (setq debbugs-gnu-current-suppress t)
1495 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1496 ("C-c D g" . ; bug-gnuzilla
1499 (setq debbugs-gnu-current-suppress t)
1500 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1501 ("C-c D G b" . ; bug-guix
1504 (setq debbugs-gnu-current-suppress t)
1505 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1506 ("C-c D G p" . ; guix-patches
1509 (setq debbugs-gnu-current-suppress t)
1510 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1512 (use-package org-ref
1514 (b/setq-every '("~/usr/org/references.bib")
1515 reftex-default-bibliography
1516 org-ref-default-bibliography)
1518 org-ref-bibliography-notes "~/usr/org/notes.org"
1519 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1521 ;; (use-package fill-column-indicator)
1525 (("C-c w e" . (lambda ()
1527 (split-window-right)
1529 (erc-switch-to-buffer)))
1530 ("C-c w s l" . (lambda ()
1532 (split-window-right)
1534 ("C-c w s j" . (lambda ()
1536 (split-window-below)
1538 ("C-c w q" . quit-window))
1540 (split-width-threshold 150))
1542 (use-package windmove
1545 (("C-c w h" . windmove-left)
1546 ("C-c w j" . windmove-down)
1547 ("C-c w k" . windmove-up)
1548 ("C-c w l" . windmove-right)
1549 ("C-c w H" . windmove-swap-states-left)
1550 ("C-c w J" . windmove-swap-states-down)
1551 ("C-c w K" . windmove-swap-states-up)
1552 ("C-c w L" . windmove-swap-states-right)))
1556 :bind ("C-c a p" . pass)
1557 :hook (pass-mode . View-exit))
1559 (use-package pdf-tools
1561 :bind (:map pdf-view-mode-map
1562 ("<C-XF86Back>" . pdf-history-backward)
1563 ("<mouse-8>" . pdf-history-backward)
1564 ("<drag-mouse-8>" . pdf-history-backward)
1565 ("<C-XF86Forward>" . pdf-history-forward)
1566 ("<mouse-9>" . pdf-history-forward)
1567 ("<drag-mouse-9>" . pdf-history-forward)
1568 ("M-RET" . image-previous-line)
1569 ("C-s" . isearch-forward)
1570 ("s s" . isearch-forward))
1571 :config (pdf-tools-install nil t)
1572 :custom (pdf-view-resize-factor 1.05))
1574 (use-package org-pdftools
1576 :straight (:host github :repo "fuxialexander/org-pdftools")
1580 (with-eval-after-load 'org
1581 (require 'org-pdftools)))
1583 (use-package biblio)
1586 :hook (latex-mode . reftex-mode))
1588 (use-package reftex-cite
1590 :disabled ; enable to disable
1591 ; reftex-cite's default choice
1594 (defun reftex-get-bibkey-default ()
1595 "If the cursor is in a citation macro, return the word before the macro."
1596 (let* ((macro (reftex-what-macro 1)))
1598 (when (and macro (string-match "cite" (car macro)))
1599 (goto-char (cdr macro)))
1600 (reftex-this-word)))))
1602 (use-package minions
1604 :config (minions-mode))
1608 (dmenu-prompt-string "run: ")
1609 (dmenu-save-file (b/var "dmenu-items")))
1612 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1613 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1615 :straight (:host github :repo "clarete/eosd")
1621 (use-package scpaste
1624 (setq scpaste-http-destination "https://p.bndl.org"
1625 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1628 :bind ("C-c a e w" . eww)
1630 (eww-download-directory (file-name-as-directory
1631 (getenv "XDG_DOWNLOAD_DIR"))))
1634 ;;; Email (with Gnus)
1636 (defvar b/maildir (expand-file-name "~/mail/"))
1637 (with-eval-after-load 'recentf
1638 (add-to-list 'recentf-exclude b/maildir))
1641 b/gnus-init-file (b/etc "gnus")
1642 mail-user-agent 'gnus-user-agent
1643 read-mail-command 'gnus)
1646 :bind (("s-m" . gnus-plugged)
1647 ("s-M" . gnus-unplugged)
1648 ("C-c a m" . gnus-plugged)
1649 ("C-c a M" . gnus-unplugged))
1652 gnus-select-method '(nnnil "")
1653 gnus-secondary-select-methods
1654 '((nnimap "shemshak"
1655 (nnimap-stream plain)
1656 (nnimap-address "127.0.0.1")
1657 (nnimap-server-port 143)
1658 (nnimap-authenticator plain)
1659 (nnimap-user "amin@shemshak.local"))
1661 (nnimap-stream plain)
1662 (nnimap-address "127.0.0.1")
1663 (nnimap-server-port 143)
1664 (nnimap-authenticator plain)
1665 (nnimap-user "bandali@gnu.local")
1666 (nnimap-inbox "INBOX")
1667 (nnimap-split-methods 'nnimap-split-fancy)
1668 (nnimap-split-fancy (|
1669 ;; (: gnus-registry-split-fancy-with-parent)
1670 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1672 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1674 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
1676 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
1677 ;; *.lists.sr.ht, omitting one dot if present
1678 ;; add more \\.?\\([^.]*\\) if needed
1679 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
1681 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1683 (list ".*atreus.freelists.org" "l.atreus")
1684 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1685 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1686 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1687 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1688 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1689 ;; ----------------------------------
1690 ;; legend: (u)nsubscribed | (d)ead
1691 ;; ----------------------------------
1692 ;; otherwise, leave mail in INBOX
1695 (nnimap-stream plain)
1696 (nnimap-address "127.0.0.1")
1697 (nnimap-server-port 143)
1698 (nnimap-authenticator plain)
1699 (nnimap-user "abandali@uw.local")
1700 (nnimap-inbox "INBOX")
1701 (nnimap-split-methods 'nnimap-split-fancy)
1702 (nnimap-split-fancy (|
1703 ;; (: gnus-registry-split-fancy-with-parent)
1705 ("subject" "SE\\s-?212" "course.se212-f19")
1706 (from "SE\\s-?212" "course.se212-f19")
1710 (nnimap-stream plain)
1711 (nnimap-address "127.0.0.1")
1712 (nnimap-server-port 143)
1713 (nnimap-authenticator plain)
1714 (nnimap-user "abandali@csc.uw.local")))
1715 gnus-message-archive-group "nnimap+gnu:INBOX"
1718 (to-address . "atreus@freelists.org")
1719 (to-list . "atreus@freelists.org"))
1721 (to-address . "deepspec@lists.cs.princeton.edu")
1722 (to-list . "deepspec@lists.cs.princeton.edu")
1723 (list-identifier . "\\[deepspec\\]"))
1725 (to-address . "emacs-devel@gnu.org")
1726 (to-list . "emacs-devel@gnu.org"))
1727 ("l\\.help-gnu-emacs"
1728 (to-address . "help-gnu-emacs@gnu.org")
1729 (to-list . "help-gnu-emacs@gnu.org"))
1730 ("l\\.info-gnu-emacs"
1731 (to-address . "info-gnu-emacs@gnu.org")
1732 (to-list . "info-gnu-emacs@gnu.org"))
1733 ("l\\.emacs-orgmode"
1734 (to-address . "emacs-orgmode@gnu.org")
1735 (to-list . "emacs-orgmode@gnu.org")
1736 (list-identifier . "\\[O\\]"))
1737 ("l\\.emacs-tangents"
1738 (to-address . "emacs-tangents@gnu.org")
1739 (to-list . "emacs-tangents@gnu.org"))
1740 ("l\\.emacsconf-committee"
1741 (to-address . "emacsconf-committee@gnu.org")
1742 (to-list . "emacsconf-committee@gnu.org"))
1743 ("l\\.emacsconf-discuss"
1744 (to-address . "emacsconf-discuss@gnu.org")
1745 (to-list . "emacsconf-discuss@gnu.org"))
1746 ("l\\.emacsconf-register"
1747 (to-address . "emacsconf-register@gnu.org")
1748 (to-list . "emacsconf-register@gnu.org"))
1749 ("l\\.emacsconf-submit"
1750 (to-address . "emacsconf-submit@gnu.org")
1751 (to-list . "emacsconf-submit@gnu.org"))
1752 ("l\\.fencepost-users"
1753 (to-address . "fencepost-users@gnu.org")
1754 (to-list . "fencepost-users@gnu.org")
1755 (list-identifier . "\\[Fencepost-users\\]"))
1756 ("l\\.gnewsense-art"
1757 (to-address . "gnewsense-art@nongnu.org")
1758 (to-list . "gnewsense-art@nongnu.org")
1759 (list-identifier . "\\[gNewSense-art\\]"))
1760 ("l\\.gnewsense-dev"
1761 (to-address . "gnewsense-dev@nongnu.org")
1762 (to-list . "gnewsense-dev@nongnu.org")
1763 (list-identifier . "\\[Gnewsense-dev\\]"))
1764 ("l\\.gnewsense-users"
1765 (to-address . "gnewsense-users@nongnu.org")
1766 (to-list . "gnewsense-users@nongnu.org")
1767 (list-identifier . "\\[gNewSense-users\\]"))
1768 ("l\\.gnunet-developers"
1769 (to-address . "gnunet-developers@gnu.org")
1770 (to-list . "gnunet-developers@gnu.org")
1771 (list-identifier . "\\[GNUnet-developers\\]"))
1773 (to-address . "help-gnunet@gnu.org")
1774 (to-list . "help-gnunet@gnu.org")
1775 (list-identifier . "\\[Help-gnunet\\]"))
1777 (to-address . "bug-gnuzilla@gnu.org")
1778 (to-list . "bug-gnuzilla@gnu.org")
1779 (list-identifier . "\\[Bug-gnuzilla\\]"))
1781 (to-address . "gnuzilla-dev@gnu.org")
1782 (to-list . "gnuzilla-dev@gnu.org")
1783 (list-identifier . "\\[Gnuzilla-dev\\]"))
1785 (to-address . "guile-devel@gnu.org")
1786 (to-list . "guile-devel@gnu.org"))
1788 (to-address . "guile-user@gnu.org")
1789 (to-list . "guile-user@gnu.org"))
1791 (to-address . "guix-devel@gnu.org")
1792 (to-list . "guix-devel@gnu.org"))
1794 (to-address . "help-guix@gnu.org")
1795 (to-list . "help-guix@gnu.org"))
1797 (to-address . "info-guix@gnu.org")
1798 (to-list . "info-guix@gnu.org"))
1799 ("l\\.savannah-hackers-public"
1800 (to-address . "savannah-hackers-public@gnu.org")
1801 (to-list . "savannah-hackers-public@gnu.org"))
1802 ("l\\.savannah-users"
1803 (to-address . "savannah-users@gnu.org")
1804 (to-list . "savannah-users@gnu.org"))
1806 (to-address . "www-commits@gnu.org")
1807 (to-list . "www-commits@gnu.org"))
1809 (to-address . "www-discuss@gnu.org")
1810 (to-list . "www-discuss@gnu.org"))
1812 (to-address . "haskell-art@we.lurk.org")
1813 (to-list . "haskell-art@we.lurk.org")
1814 (list-identifier . "\\[haskell-art\\]"))
1816 (to-address . "haskell-cafe@haskell.org")
1817 (to-list . "haskell-cafe@haskell.org")
1818 (list-identifier . "\\[Haskell-cafe\\]"))
1820 (to-address . "notmuch@notmuchmail.org")
1821 (to-list . "notmuch@notmuchmail.org"))
1823 (to-address . "dev@lists.parabola.nu")
1824 (to-list . "dev@lists.parabola.nu")
1825 (list-identifier . "\\[Dev\\]"))
1826 ("l\\.~bandali\\.public-inbox"
1827 (to-address . "~bandali/public-inbox@lists.sr.ht")
1828 (to-list . "~bandali/public-inbox@lists.sr.ht"))
1829 ("l\\.~sircmpwn\\.free-writers-club"
1830 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
1831 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
1832 ("l\\.~sircmpwn\\.srht-admins"
1833 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
1834 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
1835 ("l\\.~sircmpwn\\.srht-announce"
1836 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
1837 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
1838 ("l\\.~sircmpwn\\.srht-dev"
1839 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
1840 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
1841 ("l\\.~sircmpwn\\.srht-discuss"
1842 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
1843 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1845 (to-address . "webmasters@gnu.org")
1846 (to-list . "webmasters@gnu.org"))
1853 gnus-large-newsgroup 50
1854 gnus-home-directory (b/var "gnus/")
1855 gnus-directory (concat gnus-home-directory "news/")
1856 message-directory (concat gnus-home-directory "mail/")
1857 nndraft-directory (concat gnus-home-directory "drafts/")
1858 gnus-save-newsrc-file nil
1859 gnus-read-newsrc-file nil
1860 gnus-interactive-exit nil
1861 gnus-gcc-mark-as-read t)
1863 (when (version< emacs-version "27")
1864 (with-eval-after-load 'nnmail
1866 'nnmail-split-abbrev-alist
1867 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1870 ;; (gnus-registry-initialize)
1872 (with-eval-after-load 'recentf
1873 (add-to-list 'recentf-exclude gnus-home-directory)))
1875 (use-package gnus-art
1878 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
1879 gnus-sorted-header-list '("^From:"
1895 "^Mail-Followup-To:"
1899 "^X-detected-operating-system:"
1904 gnus-visible-headers (mapconcat 'identity
1905 gnus-sorted-header-list
1907 ;; local-lapsed article dates
1908 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1909 gnus-article-date-headers '(user-defined)
1910 gnus-article-time-format
1912 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1913 (local (article-make-date-line date 'local))
1914 (combined-lapsed (article-make-date-line date
1917 (string-match " (.+" combined-lapsed)
1918 (match-string 0 combined-lapsed))))
1919 (concat local lapsed))))
1921 :map gnus-article-mode-map
1922 ("M-L" . org-store-link)))
1924 (use-package gnus-sum
1925 :bind (:map gnus-summary-mode-map
1926 :prefix-map b/gnus-summary-prefix-map
1928 ("r" . gnus-summary-reply)
1929 ("w" . gnus-summary-wide-reply)
1930 ("v" . gnus-summary-show-raw-article))
1933 :map gnus-summary-mode-map
1934 ("M-L" . org-store-link))
1935 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
1937 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
1938 gnus-thread-sort-by-subject
1939 gnus-thread-sort-by-date)))
1941 (use-package gnus-msg
1943 (defvar b/shemshak-signature "Amin Bandali
1944 https://shemshak.org/~amin")
1945 (defvar b/uw-signature "Amin Bandali, MMath Student
1946 Cheriton School of Computer Science
1947 University of Waterloo
1948 https://bandali.eu.org")
1949 (defvar b/csc-signature "Amin Bandali
1950 System Administrator, Systems Committee
1951 Computer Science Club, University of Waterloo
1952 https://csclub.uwaterloo.ca/~abandali")
1953 (setq gnus-message-replysign t
1956 (address "bandali@gnu.org"))
1957 ("nnimap\\+gnu:l\\..*"
1960 (organization "GNU"))
1961 ((header "subject" "ThankCRM")
1962 (to "webmasters-comment@gnu.org")
1964 (eval (setq b/message-cite-say-hi nil)))
1965 ("nnimap\\+shemshak:.*"
1966 (address "amin@shemshak.org")
1968 (signature b/shemshak-signature)
1969 (gcc "nnimap+shemshak:Sent")
1970 (eval (setq b/message-cite-say-hi t)))
1972 (address "bandali@uwaterloo.ca")
1974 (signature b/uw-signature))
1975 ("nnimap\\+uw:INBOX"
1976 (gcc "\"nnimap+uw:Sent Items\""))
1978 (address "bandali@csclub.uwaterloo.ca")
1979 (signature b/csc-signature)
1980 (gcc "nnimap+csc:Sent"))))
1981 :hook (gnus-message-setup . (lambda ()
1982 (unless (mml-secure-is-encrypted-p)
1983 (mml-secure-message-sign)))))
1985 (use-package gnus-topic
1986 :hook (gnus-group-mode . gnus-topic-mode)
1987 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
1989 (use-package gnus-agent
1991 (setq gnus-agent-synchronize-flags 'ask)
1992 :hook (gnus-group-mode . gnus-agent-mode))
1994 (use-package gnus-group
1996 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
1999 ;; problematic with ebdb's popup, *EBDB-Gnus*
2000 (use-package gnus-win
2002 (setq gnus-use-full-window nil)))
2004 (use-package gnus-dired
2005 :commands gnus-dired-mode
2007 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2010 (use-package gnus-utils
2012 (gnus-completing-read-function 'gnus-ido-completing-read)))
2014 (use-package mm-decode
2016 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2017 mm-decrypt-option 'known
2018 mm-verify-option 'known))
2022 (when (version< "27" emacs-version)
2023 (set-face-attribute 'mm-uu-extract nil :extend t))
2025 (mm-uu-diff-groups-regexp
2026 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2028 (use-package sendmail
2030 (setq sendmail-program (executable-find "msmtp")
2031 ;; message-sendmail-extra-arguments '("-v" "-d")
2032 mail-specify-envelope-from t
2033 mail-envelope-from 'header))
2035 (use-package message
2036 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2038 ;; redefine for a simplified In-Reply-To header
2039 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2040 (defun message-make-in-reply-to ()
2041 "Return the In-Reply-To header for this message."
2042 (when message-reply-headers
2043 (let ((from (mail-header-from message-reply-headers))
2044 (msg-id (mail-header-id message-reply-headers)))
2048 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2049 (defconst message-cite-style-bandali
2050 '((message-cite-function 'message-cite-original)
2051 (message-citation-line-function 'message-insert-formatted-citation-line)
2052 (message-cite-reply-position 'traditional)
2053 (message-yank-prefix "> ")
2054 (message-yank-cited-prefix ">")
2055 (message-yank-empty-prefix ">")
2056 (message-citation-line-format
2057 (if b/message-cite-say-hi
2058 (concat "Hi %F,\n\n" b/message-cite-style-format)
2059 b/message-cite-style-format)))
2060 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2061 (setq ;; message-cite-style 'message-cite-style-bandali
2062 message-kill-buffer-on-exit t
2063 message-send-mail-function 'message-send-mail-with-sendmail
2064 message-sendmail-envelope-from 'header
2065 message-subscribed-address-functions
2066 '(gnus-find-subscribed-addresses)
2067 message-dont-reply-to-names
2068 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2069 ;; (require 'company-ebdb)
2070 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2071 (message-mode . flyspell-mode)
2072 (message-mode . (lambda ()
2073 ;; (setq-local fill-column b/fill-column
2074 ;; message-fill-column b/fill-column)
2075 (make-local-variable 'company-idle-delay)
2076 (setq company-idle-delay 0.2))))
2078 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2079 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2080 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2082 (message-elide-ellipsis "[...]\n"))
2086 (use-package mml-sec
2088 (mml-secure-openpgp-encrypt-to-self t)
2089 (mml-secure-openpgp-sign-with-sender t))
2091 (use-package footnote
2094 ;; (setq footnote-start-tag ""
2095 ;; footnote-end-tag ""
2096 ;; footnote-style 'unicode)
2098 (:map message-mode-map
2099 :prefix-map b/footnote-prefix-map
2101 ("a" . footnote-add-footnote)
2102 ("b" . footnote-back-to-message)
2103 ("c" . footnote-cycle-style)
2104 ("d" . footnote-delete-footnote)
2105 ("g" . footnote-goto-footnote)
2106 ("r" . footnote-renumber-footnotes)
2107 ("s" . footnote-set-style)))
2112 :bind (:map gnus-group-mode-map ("e" . ebdb))
2114 (setq ebdb-sources (b/var "ebdb"))
2115 (with-eval-after-load 'swiper
2116 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2118 (use-package ebdb-com
2121 (use-package ebdb-complete
2124 ;; (setq ebdb-complete-mail 'capf)
2125 (ebdb-complete-enable))
2127 (use-package ebdb-message
2131 ;; (use-package company-ebdb
2133 ;; (defun company-ebdb--post-complete (_) nil))
2135 (use-package ebdb-gnus
2138 (ebdb-gnus-window-size 0.3))
2140 (use-package ebdb-mua
2143 :custom (ebdb-mua-pop-up t))
2145 ;; (use-package ebdb-message
2148 ;; (use-package ebdb-vcard
2151 (use-package message-x)
2154 (use-package message-x
2156 (message-x-completion-alist
2158 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2161 (quote message-newgroups-header-regexp))
2162 message-newgroups-header-regexp message-newsgroups-header-regexp)
2163 . message-expand-group))))))
2166 (use-package gnus-harvest
2167 :commands gnus-harvest-install
2170 (if (featurep 'message-x)
2171 (gnus-harvest-install 'message-x)
2172 (gnus-harvest-install))))
2174 (use-package gnus-article-treat-patch
2179 ;; note: be sure to customize faces with `:foreground "white"' when
2180 ;; using a theme with a white/light background :)
2181 (setq ft/gnus-article-patch-conditions
2182 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2185 ;;; IRC (with ERC and ZNC)
2188 :bind (("C-c b b" . erc-switch-to-buffer)
2190 ("M-a" . erc-track-switch-buffer))
2192 (erc-join-buffer 'bury)
2193 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2194 (erc-nick "bandali")
2196 (erc-rename-buffers t)
2197 (erc-server-reconnect-attempts 5)
2198 (erc-server-reconnect-timeout 3)
2200 (defun erc-cmd-OPME ()
2201 "Request chanserv to op me."
2202 (erc-message "PRIVMSG"
2203 (format "chanserv op %s %s"
2204 (erc-default-target)
2205 (erc-current-nick)) nil))
2206 (defun erc-cmd-DEOPME ()
2207 "Deop myself from current channel."
2208 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2209 (add-to-list 'erc-modules 'keep-place)
2210 (add-to-list 'erc-modules 'notifications)
2211 (add-to-list 'erc-modules 'smiley)
2212 (add-to-list 'erc-modules 'spelling)
2213 (add-to-list 'erc-modules 'scrolltoplace)
2214 (erc-update-modules))
2216 (use-package erc-fill
2219 (erc-fill-column 77)
2220 (erc-fill-function 'erc-fill-static)
2221 (erc-fill-static-center 18))
2223 (use-package erc-pcomplete
2226 (erc-pcomplete-nick-postfix ", "))
2228 (use-package erc-track
2230 :bind (("C-c a e t d" . erc-track-disable)
2231 ("C-c a e t e" . erc-track-enable))
2233 (erc-track-enable-keybindings nil)
2234 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2235 "324" "329" "332" "333" "353" "477"))
2236 (erc-track-position-in-mode-line t)
2237 (erc-track-priority-faces-only 'all)
2238 (erc-track-shorten-function nil))
2240 (use-package erc-hl-nicks
2243 (use-package erc-scrolltoplace
2247 :bind (("C-c a e e" . znc-erc)
2248 ("C-c a e a" . znc-all))
2250 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2252 ((null auth) (error "Couldn't find znca's authinfo"))
2253 (t (funcall (plist-get (car auth) :secret)))))))
2255 `(("znc.shemshak.org" 1337 t
2256 ((freenode "amin/freenode" ,pwd)))
2257 ("znc.shemshak.org" 1337 t
2258 ((oftc "amin/oftc" ,pwd)))))))
2261 ;;; Post initialization
2264 (message "Loading %s...done (%.3fs)" user-init-file
2265 (float-time (time-subtract (current-time)
2266 b/before-user-init-time)))
2268 ;;; init.el ends here