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 GNU Guix for a fully reproducible setup.
23 ;; Before switching to Guix, I used straight.el, and before that Borg.
25 ;; Over the years, I've taken inspiration from configurations of many
26 ;; great people. Some that I can remember off the top of my head are:
28 ;; - https://github.com/dieggsy/dotfiles
29 ;; - https://github.com/dakra/dmacs
30 ;; - http://pages.sachachua.com/.emacs.d/Sacha.html
31 ;; - https://github.com/dakrone/eos
32 ;; - http://doc.rix.si/cce/cce.html
33 ;; - https://github.com/jwiegley/dot-emacs
34 ;; - https://github.com/wasamasa/dotemacs
35 ;; - https://github.com/hlissner/doom-emacs
39 ;;; Emacs initialization
41 (defvar b
/before-user-init-time
(current-time)
42 "Value of `current-time' when Emacs begins loading `user-init-file'.")
43 (defvar b
/emacs-initialized nil
44 "Whether Emacs has been initialized.")
46 (when (not (bound-and-true-p b
/emacs-initialized
))
47 (message "Loading Emacs...done (%.3fs)"
48 (float-time (time-subtract b
/before-user-init-time
51 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
52 ;; during startup to reduce garbage collection frequency. clearing
53 ;; `file-name-handler-alist' seems to help reduce startup time too.
54 (defvar b
/gc-cons-threshold gc-cons-threshold
)
55 (defvar b
/gc-cons-percentage gc-cons-percentage
)
56 (defvar b
/file-name-handler-alist file-name-handler-alist
)
57 (setq gc-cons-threshold
(* 30 1024 1024) ; 30 MiB
58 gc-cons-percentage
0.6
59 file-name-handler-alist nil
60 ;; sidesteps a bug when profiling with esup
61 esup-child-profile-require-level
0)
63 ;; set them back to their defaults once we're done initializing
65 "My post-initialize function, run after loading `user-init-file'."
66 (setq b
/emacs-initialized t
67 gc-cons-threshold b
/gc-cons-threshold
68 gc-cons-percentage b
/gc-cons-percentage
69 file-name-handler-alist b
/file-name-handler-alist
)
70 (with-eval-after-load 'exwm-workspace
77 "[%s]" (number-to-string
78 exwm-workspace-current-index
))))))))
79 (add-hook 'after-init-hook
#'b
/post-init
)
81 ;; increase number of lines kept in *Messages* log
82 (setq message-log-max
20000)
84 ;; optionally, uncomment to supress some byte-compiler warnings
85 ;; (see C-h v byte-compile-warnings RET for more info)
86 ;; (setq byte-compile-warnings
87 ;; '(not free-vars unresolved noruntime lexical make-local))
92 (setq user-full-name
"Amin Bandali"
93 user-mail-address
"bandali@gnu.org")
98 ;; useful for commenting out multiple sexps at a time
99 (defmacro comment
(&rest _
)
100 "Comment out one or more s-expressions."
101 (declare (indent defun
))
105 ;;; Package management
107 ;; No package.el (for emacs 26 and before)
108 (when (version< emacs-version
"27")
109 (setq package-enable-at-startup nil
)
110 ;; (package-initialize)
112 ;; for emacs 27 and later, we use early-init.el. see
113 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
116 (add-to-list 'load-path
117 (expand-file-name "lib/borg" user-emacs-directory
))
120 (setq borg-rewrite-urls-alist
121 '(("git@github.com:" .
"https://github.com/")
122 ("git@gitlab.com:" .
"https://gitlab.com/"))))
125 (if nil
; set to t when need to debug init
127 (setq use-package-verbose t
128 use-package-expand-minimally nil
129 use-package-compute-statistics t
131 (require 'use-package
))
132 (setq use-package-verbose nil
133 use-package-expand-minimally t
))
135 (setq use-package-always-defer t
)
141 (defvar b
/exwm-p
(string= (system-name) "chaman")
142 "Whether or not we will be using `exwm'.")
144 ;; keep ~/.emacs.d clean
145 (use-package no-littering
148 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
149 (defalias 'b
/var
'no-littering-expand-var-file-name
))
151 (use-package auto-compile
154 (auto-compile-on-load-mode)
155 (auto-compile-on-save-mode)
156 (setq auto-compile-display-buffer nil
)
157 (setq auto-compile-mode-line-counter t
)
158 (setq auto-compile-source-recreate-deletes-dest t
)
159 (setq auto-compile-toggle-deletes-nonlib-dest t
)
160 (setq auto-compile-update-autoloads t
))
162 ;; separate custom file (don't want it mixing with init.el)
166 (setq custom-file
(b/etc
"custom.el"))
167 (when (file-exists-p custom-file
)
169 ;; while at it, treat themes as safe
170 (setf custom-safe-themes t
)
171 ;; only one custom theme at a time
173 (defadvice load-theme
(before clear-previous-themes activate
)
174 "Clear existing theme settings instead of layering them"
175 (mapc #'disable-theme custom-enabled-themes
))))
177 ;; load the secrets file if it exists, otherwise show a warning
180 (load (b/etc
"secrets"))))
182 ;; start up emacs server. see
183 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
186 :config
(or (server-running-p) (server-mode)))
195 (defmacro b
/setq-every
(value &rest vars
)
196 "Set all the variables from VARS to value VALUE."
197 (declare (indent defun
) (debug t
))
198 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
200 (defun b/start-process
(program &rest args
)
201 "Same as `start-process', but doesn't bother about name and buffer."
202 (let ((process-name (concat program
"_process"))
203 (buffer-name (generate-new-buffer-name
204 (concat program
"_output"))))
205 (apply #'start-process
206 process-name buffer-name program args
)))
208 (defun b/dired-start-process
(program &optional args
)
209 "Open current file with a PROGRAM."
210 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
211 ;; be nil, so remove it).
212 (apply #'b
/start-process
214 (remove nil
(list args
(dired-get-file-for-visit)))))
216 (defun b/add-elisp-section
()
220 (insert "\n\f\n;;; "))
222 ;; (defvar b/fill-column 47
223 ;; "My custom `fill-column'.")
225 (defconst b
/asterism
"* * *")
227 (defun b/insert-asterism
()
228 "Insert a centred asterism."
233 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
238 (defun b/no-mouse-autoselect-window
()
239 "Conveniently disable `focus-follows-mouse'.
240 For disabling the behaviour for certain buffers and/or modes."
241 (make-local-variable 'mouse-autoselect-window
)
242 (setq mouse-autoselect-window nil
))
244 (defun b/kill-current-buffer
()
245 "Kill the current buffer."
246 ;; also see https://redd.it/64xb3q
248 (kill-buffer (current-buffer)))
253 ;;;; C-level customizations
257 enable-recursive-minibuffers t
258 resize-mini-windows t
259 ;; more useful frame titles
260 frame-title-format
'("" invocation-name
" - "
262 (if (buffer-file-name)
263 (abbreviate-file-name (buffer-file-name))
265 ;; i don't feel like jumping out of my chair every now and again; so
266 ;; don't BEEP! at me, emacs
267 ring-bell-function
'ignore
270 ;; scroll-conservatively 10000
272 scroll-conservatively
10
273 scroll-preserve-screen-position
1
274 ;; focus follows mouse
275 mouse-autoselect-window t
)
278 ;; always use space for indentation
286 (dolist (ft (fontset-list))
290 (font-spec :name
"Source Code Pro" :size
14))
294 (font-spec :name
"DejaVu Sans Mono")
301 ;; :name "Symbola monospacified for DejaVu Sans Mono")
307 ;; (font-spec :name "DejaVu Sans Mono")
313 (font-spec :name
"DejaVu Sans Mono" :size
14)
317 ;;;; Elisp-level customizations
323 ;; don't need to see the startup echo area message
324 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
326 ;; i want *scratch* as my startup buffer
327 (initial-buffer-choice t
)
328 ;; i don't need the default hint
329 (initial-scratch-message nil
)
330 ;; use customizable text-mode as major mode for *scratch*
331 ;; (initial-major-mode 'text-mode)
332 ;; inhibit buffer list when more than 2 files are loaded
333 (inhibit-startup-buffer-menu t
)
334 ;; don't need to see the startup screen or echo area message
335 (inhibit-startup-screen t
)
336 (inhibit-startup-echo-area-message user-login-name
))
342 ;; backups (C-h v make-backup-files RET)
343 (backup-by-copying t
)
345 (delete-old-versions t
)
348 (auto-save-file-name-transforms
349 `((".*" ,(b/var
"auto-save/") t
)))
351 ;; insert newline at the end of files
352 (require-final-newline t
)
354 ;; open read-only file buffers in view-mode
355 ;; (enables niceties like `q' for quit)
358 ;; disable disabled commands
359 (setq disabled-command-function nil
)
361 ;; lazy-person-friendly yes/no prompts
362 (defalias 'yes-or-no-p
#'y-or-n-p
)
364 ;; enable automatic reloading of changed buffers and files
365 (use-package autorevert
368 (global-auto-revert-mode 1)
370 (auto-revert-verbose nil
)
371 (global-auto-revert-non-file-buffers nil
))
373 ;; time and battery in mode-line
379 (display-time-default-load-average nil
)
380 (display-time-format "%a %b %-e %-l:%M%P")
381 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
382 (display-time-use-mail-icon t
))
387 (display-battery-mode)
389 (battery-mode-line-format " %p%% %t"))
395 ;; (fringe-mode '(3 . 1))
401 ;; enable winner-mode (C-h f winner-mode RET)
406 ;; don't display *compilation* buffer on success. based on
407 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
408 ;; instead of the now obsolete `flet'.
409 (defun b/compilation-finish-function
(buffer outstr
)
410 (unless (string-match "finished" outstr
)
411 (switch-to-buffer-other-window buffer
))
414 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
418 (defadvice compilation-start
419 (around inhibit-display
420 (command &optional mode name-function highlight-regexp
))
421 (if (not (string-match "^\\(find\\|grep\\)" command
))
422 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
423 (save-window-excursion ad-do-it
))
425 (ad-activate 'compilation-start
))
429 ;; allow scrolling in Isearch
430 (isearch-allow-scroll t
)
431 ;; search for non-ASCII characters: i’d like non-ASCII characters such
432 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
433 ;; counterpart. shoutout to
434 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
435 (search-default-mode #'char-fold-to-regexp
))
437 ;; uncomment to extend the above behaviour to query-replace
441 (replace-char-fold t
)))
444 :bind
("C-x v C-=" . vc-ediff
))
449 (vc-git-print-log-follow t
))
452 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
453 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
454 (ediff-split-window-function 'split-window-horizontally
)))
456 (use-package face-remap
458 ;; gentler font resizing
459 (text-scale-mode-step 1.05))
464 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
465 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
466 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
468 (use-package pixel-scroll
470 :config
(pixel-scroll-mode 1))
472 (use-package epg-config
474 ;; ask for GPG passphrase in minibuffer
475 ;; this will fail if gpg>=2.1 is not available
476 (if (version< "27" emacs-version
)
477 (setq epg-pinentry-mode
'loopback
)
478 (setq epa-pinentry-mode
'loopback
))
480 (epg-gpg-program (executable-find "gpg")))
485 (use-package pinentry
487 :after
(epa epg server
)
489 ;; workaround for systemd-based distros:
490 ;; (setq pinentry--socket-dir server-socket-dir)
493 (use-package auth-source
495 (auth-sources '("~/.authinfo.gpg"))
496 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
504 ("C-c e b" . eval-buffer
)
505 ("C-c e e" . eval-last-sexp
)
506 ("C-c e r" . eval-region
)
508 ("C-c e i" . emacs-init-time
)
509 ("C-c e u" . emacs-uptime
)
510 ("C-c e v" . emacs-version
)
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-x k" . b
/kill-current-buffer
)
520 ("C-x K" . kill-buffer
)
521 ("C-x s" . save-buffer
)
522 ("C-x S" . save-some-buffers
)
524 :map emacs-lisp-mode-map
525 ("<C-return>" . b
/add-elisp-section
))
527 (when (display-graphic-p)
528 (unbind-key "C-z" global-map
))
531 ;; for back and forward mouse keys
532 ("<XF86Back>" . previous-buffer
)
533 ("<mouse-8>" . previous-buffer
)
534 ;; ("<drag-mouse-8>" . previous-buffer)
535 ("<XF86Forward>" . next-buffer
)
536 ("<mouse-9>" . next-buffer
)
537 ;; ("<drag-mouse-9>" . next-buffer)
538 ;; ("<drag-mouse-2>" . kill-this-buffer)
539 ;; ("<drag-mouse-3>" . switch-to-buffer)
543 ;;; Essential packages
549 ;; make class name the buffer name, truncating beyond 60 characters
550 (defun b/exwm-rename-buffer
()
552 (exwm-workspace-rename-buffer
553 (concat exwm-class-name
":"
554 (if (<= (length exwm-title
) 60) exwm-title
555 (concat (substring exwm-title
0 59) "...")))))
558 :hook
((exwm-update-class . b
/exwm-rename-buffer
)
559 (exwm-update-title . b
/exwm-rename-buffer
)))
561 (use-package exwm-config
564 :hook
(exwm-init . exwm-config--fix
/ido-buffer-window-other-frame
))
566 (use-package exwm-input
570 (defun b/exwm-ws-prev-index
()
571 "Return the index for the previous EXWM workspace, wrapping
573 (if (= exwm-workspace-current-index
0)
574 (1- exwm-workspace-number
)
575 (1- exwm-workspace-current-index
)))
577 (defun b/exwm-ws-next-index
()
578 "Return the index for the next EXWM workspace, wrapping
580 (if (= exwm-workspace-current-index
581 (1- exwm-workspace-number
))
583 (1+ exwm-workspace-current-index
)))
585 ;; shorten 'C-c C-q' to 'C-q'
586 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
588 (setq exwm-workspace-number
4
589 exwm-input-global-keys
590 `(([?\s-R
] . exwm-reset
)
591 ([?\s-
\\] . exwm-workspace-switch
)
593 ([?\S-\s-\s
] .
(lambda (command)
595 (list (read-shell-command "➜ ")))
596 (start-process-shell-command
597 command nil command
)))
598 ([s-return
] .
(lambda ()
600 (start-process "" nil
"urxvt")))
601 ([?\C-\s-\s
] . counsel-linux-app
)
602 ([?\M-\s-\s
] .
(lambda ()
604 (start-process-shell-command
605 "rofi-pass" nil
"rofi-pass")))
606 ([?\s-h
] . windmove-left
)
607 ([?\s-j
] . windmove-down
)
608 ([?\s-k
] . windmove-up
)
609 ([?\s-l
] . windmove-right
)
610 ([?\s-H
] . windmove-swap-states-left
)
611 ([?\s-J
] . windmove-swap-states-down
)
612 ([?\s-K
] . windmove-swap-states-up
)
613 ([?\s-L
] . windmove-swap-states-right
)
614 ([?\M-\s-h
] . shrink-window-horizontally
)
615 ([?\M-\s-l
] . enlarge-window-horizontally
)
616 ([?\M-\s-k
] . shrink-window
)
617 ([?\M-\s-j
] . enlarge-window
)
618 ([?\s-\
[] .
(lambda ()
620 (exwm-workspace-switch-create
621 (b/exwm-ws-prev-index
))))
622 ([?\s-\
]] .
(lambda ()
624 (exwm-workspace-switch-create
625 (b/exwm-ws-next-index
))))
626 ([?\s-
{] .
(lambda ()
628 (exwm-workspace-move-window
629 (b/exwm-ws-prev-index
))))
630 ([?\s-
}] .
(lambda ()
632 (exwm-workspace-move-window
633 (b/exwm-ws-next-index
))))
634 ,@(mapcar (lambda (i)
635 `(,(kbd (format "s-%d" i
)) .
638 (exwm-workspace-switch-create ,i
))))
639 (number-sequence 0 (1- exwm-workspace-number
)))
640 ([?\s-t
] . exwm-floating-toggle-floating
)
641 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
642 ([?\s-W
] .
(lambda ()
644 (kill-buffer (current-buffer))))
645 ([?\s-Q
] .
(lambda ()
647 (exwm-manage--kill-client)))
648 ([?\s-
\'] .
(lambda ()
650 (start-process-shell-command
651 "rofi-light" nil
"rofi-light")))
655 (start-process "" nil "amixer" "set" "'Master',0" "toggle")))
656 ([XF86AudioLowerVolume] .
660 "" nil "amixer" "set" "'Master',0" "5%-")))
661 ([XF86AudioRaiseVolume] .
665 "" nil "amixer" "set" "'Master',0" "5%+")))
669 (start-process "" nil "mpc" "toggle")))
673 (start-process "" nil "mpc" "prev")))
677 (start-process "" nil "mpc" "next")))
681 (start-process "" nil "dm-tool" "lock")))
682 ([\s-XF86Back] . previous-buffer)
683 ([\s-XF86Forward] . next-buffer)))
685 ;; Line-editing shortcuts
686 (setq exwm-input-simulation-keys
691 ([?\M-f] . [C-right])
699 ([?\C-k] . [S-end ?\C-x])
706 ([?\M-d] . [C-S-right ?\C-x])
707 ([?\M-\d] . [C-S-left ?\C-x])
714 ([?\C-g] . [escape]))))
716 (use-package exwm-manage
720 (exwm-manage-finish . (lambda ()
721 (when exwm-class-name
723 ((string= exwm-class-name "IceCat")
724 (exwm-input-set-local-simulation-keys
725 `(,@exwm-input-simulation-keys
726 ([?\C-\S-d] . [?\C-d]))))
727 ((string= exwm-class-name "URxvt")
728 (exwm-input-set-local-simulation-keys
729 '(([?\C-c ?\C-c] . [?\C-c])
730 ([?\C-c ?\C-u] . [?\C-u]))))
731 ((string= exwm-class-name "Zathura")
732 (exwm-input-set-local-simulation-keys
734 ([?\C-n] . [C-down])))))))))
736 (use-package exwm-randr
742 (exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
744 (use-package exwm-systemtray
748 (exwm-systemtray-enable))
750 (use-package exwm-workspace)
752 (use-package exwm-edit
756 ;; use the org-plus-contrib package to get the whole deal
757 (use-package org-plus-contrib)
762 (setq org-src-tab-acts-natively t
763 org-src-preserve-indentation nil
764 org-edit-src-content-indentation 0
765 org-link-email-description-format "Email %c: %s" ; %.30s
766 org-highlight-latex-and-related '(entities)
767 org-use-speed-commands t
768 org-startup-folded 'content
769 org-catch-invisible-edits 'show-and-error
771 (when (version< org-version "9.3")
772 (setq org-email-link-description-format
773 org-link-email-description-format))
774 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
775 (add-to-list 'org-modules 'org-habit)
777 (("C-c a o a" . org-agenda)
779 ("M-L" . org-insert-last-stored-link)
780 ("M-O" . org-toggle-link-display))
781 :hook ((org-mode . org-indent-mode)
782 (org-mode . auto-fill-mode)
783 (org-mode . flyspell-mode))
785 (org-pretty-entities t)
786 (org-agenda-files '("~/usr/org/todos/personal.org"
787 "~/usr/org/todos/habits.org"
788 "~/src/git/masters-thesis/todo.org"))
789 (org-agenda-start-on-weekday 0)
790 (org-agenda-time-leading-zero t)
791 (org-habit-graph-column 44)
792 (org-latex-packages-alist '(("" "listings") ("" "color")))
794 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
795 '(org-block ((t (:background "#1d1f21"))))
796 '(org-latex-and-related ((t (:foreground "#b294bb")))))
798 (use-package ox-latex
801 (setq org-latex-listings 'listings
802 ;; org-latex-prefer-user-labels t
804 (add-to-list 'org-latex-classes
805 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
806 ("\\section{%s}" . "\\section*{%s}")
807 ("\\subsection{%s}" . "\\subsection*{%s}")
808 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
809 ("\\paragraph{%s}" . "\\paragraph*{%s}")
810 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
812 (require 'ox-beamer))
814 (use-package ox-extra
816 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
818 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
819 ;; org file. closely inspired by
820 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
821 (with-eval-after-load 'org
822 (defvar b/show-async-tangle-results nil
823 "Keep *emacs* async buffers around for later inspection.")
825 (defvar b/show-async-tangle-time nil
826 "Show the time spent tangling the file.")
828 (defun b/async-babel-tangle ()
829 "Tangle org file asynchronously."
831 (let* ((file-tangle-start-time (current-time))
832 (file (buffer-file-name))
833 (file-nodir (file-name-nondirectory file))
834 ;; (async-quiet-switch "-q")
835 (file-noext (file-name-sans-extension file)))
839 (org-babel-tangle-file ,file))
840 (unless b/show-async-tangle-results
843 (message "Tangled %s%s"
845 (if b/show-async-tangle-time
847 (float-time (time-subtract (current-time)
848 ',file-tangle-start-time)))
850 (message "Tangling %s failed" ,file-nodir))))))))
853 'safe-local-variable-values
854 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
856 ;; *the* right way to do git
859 :bind (("C-x g" . magit-status)
860 ("C-c g g" . magit-status)
861 ("C-c g b" . magit-blame-addition)
862 ("C-c g l" . magit-log-buffer-file))
864 (magit-add-section-hook 'magit-status-sections-hook
865 'magit-insert-modules
866 'magit-insert-stashes
868 ;; (magit-add-section-hook 'magit-status-sections-hook
869 ;; 'magit-insert-ignored-files
870 ;; 'magit-insert-untracked-files
872 (setq magit-repository-directories '(("~/.emacs.d/" . 0)
874 (nconc magit-section-initial-visibility-alist
875 '(([unpulled status] . show)
876 ([unpushed status] . show)))
878 (magit-diff-refine-hunk t)
879 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
880 ;; (magit-completing-read-function 'magit-ido-completing-read)
881 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
883 ;; recently opened files
887 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
891 (recentf-max-saved-items 2000))
893 ;; smart M-x enhancement (needed by counsel for history)
894 ;; (use-package smex)
897 ("C-c f ." . find-file)
898 ("C-c f d" . find-name-dired)
899 ("C-c f l" . find-library)
900 ;; ("C-c f r" . recentf-open-files)
901 ("C-c x" . execute-extended-command))
907 (:map ido-common-completion-map
908 ([escape] . minibuffer-keyboard-quit)
909 ("DEL" . b/ido-backspace))
912 (defun b/ido-backspace ()
913 "Forward to `backward-delete-char'. On error (read-only), quit."
916 (backward-delete-char 1)
918 (minibuffer-keyboard-quit))))
922 (ido-enable-flex-matching t)
923 ;; (ido-enable-regexp t)
924 ;; (ido-enable-prefix t)
925 (ido-max-window-height 10)
926 (ido-use-virtual-buffers t))
928 (use-package ido-vertical-mode
931 (ido-vertical-mode 1)
933 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
934 (ido-vertical-show-count t))
936 (use-package ido-completing-read+
940 (ido-ubiquitous-mode 1))
942 (use-package crm-custom
947 (use-package icomplete
960 (:map ivy-minibuffer-map
961 ([escape] . keyboard-escape-quit)
962 ([S-up] . ivy-previous-history-element)
963 ([S-down] . ivy-next-history-element)
964 ("DEL" . ivy-backward-delete-char))
968 ivy-use-virtual-buffers t
969 ivy-virtual-abbreviate 'abbreviate
970 ivy-count-format "%d/%d ")
972 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
973 (defun b/ivy-ignore-buffer-p (str)
974 "Return non-nil if str names a buffer with a major mode
975 derived from one of `b/ivy-ignore-buffer-modes'.
977 This function is intended for use with `ivy-ignore-buffers'."
978 (let* ((buf (get-buffer str))
979 (mode (and buf (buffer-local-value 'major-mode buf))))
981 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
982 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
986 (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
987 (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
988 (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
989 (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
990 (ivy-current-match ((((class color) (background light))
991 :background "#d7d7d7" :foreground "black")
992 (((class color) (background dark))
993 :background "#65a7e2" :foreground "black"))))
998 :bind (("C-S-s" . swiper-isearch)))
1000 (use-package counsel
1003 :bind (("C-c f r" . counsel-recentf)
1004 :map minibuffer-local-map
1005 ("C-r" . counsel-minibuffer-history))
1008 (defalias 'locate #'counsel-locate))
1013 :bind ("C-c a s e" . eshell)
1015 (eval-when-compile (defvar eshell-prompt-regexp))
1016 (defun b/eshell-quit-or-delete-char (arg)
1018 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
1019 (eshell-life-is-too-much)
1022 (defun b/eshell-clear ()
1024 (let ((inhibit-read-only t))
1026 (eshell-send-input))
1028 (defun b/eshell-setup ()
1029 (make-local-variable 'company-idle-delay)
1030 (defvar company-idle-delay)
1031 (setq company-idle-delay nil)
1032 (bind-keys :map eshell-mode-map
1033 ("C-d" . b/eshell-quit-or-delete-char)
1034 ("C-S-l" . b/eshell-clear)
1035 ("M-r" . counsel-esh-history)
1036 ;; ([tab] . company-complete)
1038 (if (version< "27" emacs-version)
1039 (bind-keys :map eshell-hist-mode-map
1040 ("M-r" . counsel-esh-history))
1041 (bind-keys :map eshell-mode-map
1042 ("M-r" . counsel-esh-history))))
1045 eshell-prompt-regexp "\\(.*\n\\)*[$#] "
1046 eshell-prompt-function
1049 (propertize (format "%s@%s:" (user-login-name) (system-name))
1051 (propertize (abbreviate-file-name default-directory)
1052 'face 'font-lock-comment-face)
1053 (propertize "\n" 'face 'default)
1054 (if (= (user-uid) 0)
1055 (propertize "#" 'face 'red)
1056 (propertize "$" 'face 'default))
1057 (propertize " " 'face 'default))))
1059 :hook (eshell-mode . b/eshell-setup)
1061 (eshell-hist-ignoredups t)
1062 (eshell-input-filter 'eshell-input-filter-initial-space))
1064 (use-package ibuffer
1066 (("C-x C-b" . ibuffer)
1067 :map ibuffer-mode-map
1068 ("P" . ibuffer-backward-filter-group)
1069 ("N" . ibuffer-forward-filter-group)
1070 ("M-p" . ibuffer-do-print)
1071 ("M-n" . ibuffer-do-shell-command-pipe-replace))
1073 ;; Use human readable Size column instead of original one
1074 (define-ibuffer-column size-h
1075 (:name "Size" :inline t)
1077 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1078 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
1079 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
1080 (t (format "%8d" (buffer-size)))))
1082 (ibuffer-saved-filter-groups
1084 ("dired" (mode . dired-mode))
1085 ("org" (mode . org-mode))
1088 (mode . gnus-group-mode)
1089 (mode . gnus-summary-mode)
1090 (mode . gnus-article-mode)
1091 ;; not really, but...
1092 (mode . message-mode)))
1095 ;; (mode . web-mode)
1102 (mode . eshell-mode)
1104 (mode . term-mode)))
1107 (mode . python-mode)
1111 (mode . emacs-lisp-mode)
1112 (mode . scheme-mode)
1113 (mode . haskell-mode)
1116 (mode . alloy-mode)))
1119 (mode . bibtex-mode)
1120 (mode . latex-mode)))
1123 (name . "^\\*scratch\\*$")
1124 (name . "^\\*Messages\\*$")))
1125 ("exwm" (mode . exwm-mode))
1126 ("erc" (mode . erc-mode)))))
1128 '((mark modified read-only locked " "
1129 (name 72 72 :left :elide)
1131 (size-h 9 -1 :right)
1133 (mode 16 16 :left :elide)
1134 " " filename-and-process)
1138 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1140 (use-package outline
1142 :hook (prog-mode . outline-minor-mode)
1145 outline-minor-mode-map
1146 ("<s-tab>" . outline-toggle-children)
1147 ("M-p" . outline-previous-visible-heading)
1148 ("M-n" . outline-next-visible-heading)
1149 :prefix-map b/outline-prefix-map
1151 ("TAB" . outline-toggle-children)
1152 ("a" . outline-hide-body)
1153 ("H" . outline-hide-body)
1154 ("S" . outline-show-all)
1155 ("h" . outline-hide-subtree)
1156 ("s" . outline-show-subtree)))
1158 (use-package ls-lisp
1159 :custom (ls-lisp-dirs-first t))
1163 (setq dired-dwim-target t
1164 dired-listing-switches "-alh"
1165 ls-lisp-use-insert-directory-program nil)
1167 ;; easily diff 2 marked files
1168 ;; https://oremacs.com/2017/03/18/dired-ediff/
1169 (defun dired-ediff-files ()
1171 (require 'dired-aux)
1172 (defvar ediff-after-quit-hook-internal)
1173 (let ((files (dired-get-marked-files))
1174 (wnd (current-window-configuration)))
1175 (if (<= (length files) 2)
1176 (let ((file1 (car files))
1177 (file2 (if (cdr files)
1181 (dired-dwim-target-directory)))))
1182 (if (file-newer-than-file-p file1 file2)
1183 (ediff-files file2 file1)
1184 (ediff-files file1 file2))
1185 (add-hook 'ediff-after-quit-hook-internal
1187 (setq ediff-after-quit-hook-internal nil)
1188 (set-window-configuration wnd))))
1189 (error "no more than 2 files should be marked"))))
1192 (setq dired-guess-shell-alist-user
1193 '(("\\.pdf\\'" "evince" "zathura" "okular")
1194 ("\\.doc\\'" "libreoffice")
1195 ("\\.docx\\'" "libreoffice")
1196 ("\\.ppt\\'" "libreoffice")
1197 ("\\.pptx\\'" "libreoffice")
1198 ("\\.xls\\'" "libreoffice")
1199 ("\\.xlsx\\'" "libreoffice")
1200 ("\\.flac\\'" "mpv")))
1201 :bind (:map dired-mode-map
1202 ("b" . dired-up-directory)
1203 ("E" . dired-ediff-files)
1204 ("e" . dired-toggle-read-only)
1205 ("\\" . dired-hide-details-mode)
1208 (b/dired-start-process "zathura"))))
1209 :hook (dired-mode . dired-hide-details-mode))
1213 (temp-buffer-resize-mode)
1214 (setq help-window-select t))
1218 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1219 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1220 (add-to-list 'tramp-default-proxies-alist
1221 (list (regexp-quote (system-name)) nil nil)))
1223 (use-package doc-view
1224 :bind (:map doc-view-mode-map
1225 ("M-RET" . image-previous-line)))
1230 ;; highlight uncommitted changes in the left fringe
1231 (use-package diff-hl
1234 (setq diff-hl-draw-borders nil)
1235 (global-diff-hl-mode)
1236 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
1238 ;; display Lisp objects at point in the echo area
1240 :when (version< "25" emacs-version)
1241 :config (global-eldoc-mode))
1243 ;; highlight matching parens
1246 :config (show-paren-mode))
1248 (use-package elec-pair
1250 :config (electric-pair-mode))
1253 :config (column-number-mode)
1255 ;; Save what I copy into clipboard from other applications into Emacs'
1256 ;; kill-ring, which would allow me to still be able to easily access
1257 ;; it in case I kill (cut or copy) something else inside Emacs before
1258 ;; yanking (pasting) what I'd originally intended to.
1259 (save-interprogram-paste-before-kill t))
1261 ;; save minibuffer history
1262 (use-package savehist
1266 (add-to-list 'savehist-additional-variables 'kill-ring))
1268 ;; automatically save place in files
1269 (use-package saveplace
1270 :when (version< "25" emacs-version)
1271 :config (save-place-mode))
1273 (use-package prog-mode
1274 :config (global-prettify-symbols-mode)
1275 (defun indicate-buffer-boundaries-left ()
1276 (setq indicate-buffer-boundaries 'left))
1277 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1279 (use-package text-mode
1280 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
1281 :hook ((text-mode . indicate-buffer-boundaries-left)
1282 (text-mode . flyspell-mode)))
1284 (use-package conf-mode
1287 (use-package sh-mode
1290 (use-package company
1293 (:map company-active-map
1294 ([tab] . company-complete-common-or-cycle)
1295 ([escape] . company-abort)
1296 ("C-p" . company-select-previous-or-abort)
1297 ("C-n" . company-select-next-or-abort))
1299 (company-minimum-prefix-length 1)
1300 (company-selection-wrap-around t)
1301 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1302 (company-dabbrev-downcase nil)
1303 (company-dabbrev-ignore-case nil)
1305 ;; (global-company-mode t)
1308 (use-package flycheck
1310 :hook (prog-mode . flycheck-mode)
1312 (:map flycheck-mode-map
1313 ("M-P" . flycheck-previous-error)
1314 ("M-N" . flycheck-next-error))
1316 ;; Use the load-path from running Emacs when checking elisp files
1317 (setq flycheck-emacs-lisp-load-path 'inherit)
1319 ;; Only flycheck when I actually save the buffer
1320 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1321 :custom (flycheck-mode-line-prefix "flyc"))
1323 (use-package flyspell)
1325 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1329 ;; ’ can be part of a word
1330 (setq ispell-local-dictionary-alist
1331 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1332 "['\x2019]" nil ("-B") nil utf-8))
1333 ispell-program-name (executable-find "hunspell"))
1334 ;; don't send ’ to the subprocess
1335 (defun endless/replace-apostrophe (args)
1336 (cons (replace-regexp-in-string
1339 (advice-add #'ispell-send-string :filter-args
1340 #'endless/replace-apostrophe)
1342 ;; convert ' back to ’ from the subprocess
1343 (defun endless/replace-quote (args)
1344 (if (not (derived-mode-p 'org-mode))
1346 (cons (replace-regexp-in-string
1349 (advice-add #'ispell-parse-output :filter-args
1350 #'endless/replace-quote))
1353 :hook (text-mode . abbrev-mode))
1356 ;;; Programming modes
1358 (use-package lisp-mode
1360 (defun indent-spaces-mode ()
1361 (setq indent-tabs-mode nil))
1362 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1365 :hook (emacs-lisp-mode . reveal-mode))
1367 (use-package elisp-mode)
1369 ;; (use-package alloy-mode
1370 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1371 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1373 ;; (setq alloy-basic-offset 2)
1374 ;; ;; (defun b/alloy-simple-indent (start end)
1375 ;; ;; (interactive "r")
1376 ;; ;; ;; (if (region-active-p)
1377 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1379 ;; ;; ;; (indent-rigidly (line-beginning-position)
1380 ;; ;; ;; (line-end-position)
1381 ;; ;; ;; alloy-basic-offset)))
1382 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1383 ;; :bind (:map alloy-mode-map
1384 ;; ("RET" . electric-newline-and-maybe-indent)
1385 ;; ;; ("TAB" . b/alloy-simple-indent)
1386 ;; ("TAB" . indent-for-tab-command))
1387 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1389 (eval-when-compile (defvar lean-mode-map))
1390 (use-package lean-mode
1392 :bind (:map lean-mode-map
1393 ("S-SPC" . company-complete))
1395 (require 'lean-input)
1396 (setq default-input-method "Lean"
1397 lean-input-tweak-all '(lean-input-compose
1398 (lean-input-prepend "/")
1399 (lean-input-nonempty))
1400 lean-input-user-translations '(("/" "/")))
1403 (use-package mhtml-mode)
1405 (use-package sgml-mode
1407 (setq sgml-basic-offset 0))
1409 (use-package css-mode
1411 (setq css-indent-offset 2))
1413 (use-package emmet-mode
1414 :after (:any mhtml-mode css-mode sgml-mode)
1415 :bind* (("C-)" . emmet-next-edit-point)
1416 ("C-(" . emmet-prev-edit-point))
1418 (unbind-key "C-j" emmet-mode-keymap)
1419 (setq emmet-move-cursor-between-quotes t)
1420 :hook (css-mode html-mode sgml-mode))
1422 (use-package geiser)
1424 (use-package geiser-guile
1426 (setq geiser-guile-load-path "~/src/git/guix"))
1433 (font-latex-fontify-sectioning 'color)))
1435 (use-package go-mode
1438 (use-package po-mode
1440 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1442 (use-package tex-mode
1445 (lambda (p) (string-match "^---?" (car p)))
1446 tex--prettify-symbols-alist)
1447 :hook ((tex-mode . auto-fill-mode)
1448 (tex-mode . flyspell-mode)))
1450 ;; (use-package george-mode
1451 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1452 ;; :mode "\\.grg\\'")
1457 (add-to-list 'custom-theme-load-path
1459 (convert-standard-filename "lisp") user-emacs-directory))
1460 (load-theme 'tangomod t)
1462 (use-package smart-mode-line
1463 :commands (sml/apply-theme)
1466 ;; thanks, but no thnaks; don't make fixed-width fills.
1467 (defun sml/fill-for-buffer-identification () "")
1468 (setq sml/theme 'tangomod)
1470 (smart-mode-line-enable))
1472 (use-package doom-modeline
1475 :hook (after-init . doom-modeline-init)
1477 (doom-modeline-buffer-file-name-style 'relative-to-project))
1479 (use-package doom-themes)
1485 (setq x-underline-at-descent-line t)
1486 (let ((line (face-attribute 'mode-line :underline)))
1487 (set-face-attribute 'mode-line nil :overline line)
1488 (set-face-attribute 'mode-line-inactive nil :overline line)
1489 (set-face-attribute 'mode-line-inactive nil :underline line)
1490 (set-face-attribute 'mode-line nil :box nil)
1491 (set-face-attribute 'mode-line-inactive nil :box nil)
1492 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1493 (moody-replace-mode-line-buffer-identification)
1494 (moody-replace-vc-mode))
1496 (use-package mini-modeline
1499 :config (mini-modeline-mode))
1501 (defvar b/org-mode-font-lock-keywords
1502 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1503 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1504 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1505 (4 '(:foreground "#c5c8c6") t))) ; title
1506 "For use with the `doom-tomorrow-night' theme.")
1508 (defun b/lights-on ()
1509 "Enable my favourite light theme."
1511 (mapc #'disable-theme custom-enabled-themes)
1512 (load-theme 'tangomod t)
1513 (when (featurep 'smart-mode-line)
1514 (sml/apply-theme 'tangomod))
1515 (font-lock-remove-keywords
1516 'org-mode b/org-mode-font-lock-keywords)
1517 (when (featurep 'erc-hl-nicks)
1518 (erc-hl-nicks-reset-face-table))
1519 (when (featurep 'exwm-systemtray)
1520 (exwm-systemtray--refresh)))
1522 (defun b/lights-off ()
1525 (mapc #'disable-theme custom-enabled-themes)
1526 (load-theme 'doom-one t)
1527 (when (featurep 'smart-mode-line)
1528 (sml/apply-theme 'automatic))
1529 (font-lock-add-keywords
1530 'org-mode b/org-mode-font-lock-keywords t)
1531 (when (featurep 'erc-hl-nicks)
1532 (erc-hl-nicks-reset-face-table))
1533 (when (featurep 'exwm-systemtray)
1534 (exwm-systemtray--refresh)))
1537 ("C-c t d" . b/lights-off)
1538 ("C-c t l" . b/lights-on))
1541 ;;; Emacs enhancements & auxiliary packages
1544 :config (setq Man-width 80))
1546 (use-package which-key
1549 (which-key-add-key-based-replacements
1550 ;; prefixes for global prefixes and minor modes
1553 "C-x RET" "coding system"
1555 "C-x @" "event modifiers"
1556 "C-x a" "abbrev/expand"
1557 "C-x r" "rectangle/register/bookmark"
1559 "C-x v" "version control"
1563 ;; prefixes for my personal bindings
1565 "C-c a" "applications"
1570 "C-c c" "compile-and-comments"
1576 "C-c m" "multiple-cursors"
1577 "C-c p" "projectile"
1578 "C-c p s" "projectile/search"
1579 "C-c p x" "projectile/execute"
1580 "C-c p 4" "projectile/other-window"
1586 ;; prefixes for major modes
1587 (which-key-add-major-mode-key-based-replacements 'message-mode
1588 "C-c f n" "footnote")
1589 (which-key-add-major-mode-key-based-replacements 'org-mode
1590 "C-c C-v" "org-babel")
1594 (which-key-add-column-padding 5)
1595 (which-key-max-description-length 32))
1597 (use-package crux ; results in Waiting for git... [2 times]
1599 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1600 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1601 ("C-c f C" . crux-copy-file-preserve-attributes)
1602 ("C-c f D" . crux-delete-file-and-buffer)
1603 ("C-c f R" . crux-rename-file-and-buffer)
1604 ("C-c j" . crux-top-join-line)
1605 ("C-S-j" . crux-top-join-line)))
1608 :bind (("C-a" . mwim-beginning-of-code-or-line)
1609 ("C-e" . mwim-end-of-code-or-line)
1610 ("<home>" . mwim-beginning-of-line-or-code)
1611 ("<end>" . mwim-end-of-line-or-code)))
1613 (use-package projectile
1616 :bind-keymap ("C-c p" . projectile-command-map)
1620 (defun b/projectile-mode-line-fun ()
1621 "Report project name and type in the modeline."
1622 (let ((project-name (projectile-project-name))
1623 (project-type (projectile-project-type)))
1625 projectile-mode-line-prefix
1627 (format ":%s" project-type)
1629 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1631 (defun my-projectile-invalidate-cache (&rest _args)
1632 ;; ignore the args to `magit-checkout'
1633 (projectile-invalidate-cache nil))
1635 (eval-after-load 'magit-branch
1637 (advice-add 'magit-checkout
1638 :after #'my-projectile-invalidate-cache)
1639 (advice-add 'magit-branch-and-checkout
1640 :after #'my-projectile-invalidate-cache)))
1642 (projectile-completion-system 'ivy)
1643 (projectile-mode-line-prefix " proj"))
1645 (use-package helpful
1648 (("C-S-h c" . helpful-command)
1649 ("C-S-h f" . helpful-callable) ; helpful-function
1650 ("C-S-h v" . helpful-variable)
1651 ("C-S-h k" . helpful-key)
1652 ("C-S-h p" . helpful-at-point)))
1654 (use-package unkillable-scratch
1657 (unkillable-scratch 1)
1659 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1662 ;; | make pretty boxed quotes like this
1664 (use-package boxquote
1667 (:prefix-map b/boxquote-prefix-map
1669 ("b" . boxquote-buffer)
1670 ("B" . boxquote-insert-buffer)
1671 ("d" . boxquote-defun)
1672 ("F" . boxquote-insert-file)
1673 ("hf" . boxquote-describe-function)
1674 ("hk" . boxquote-describe-key)
1675 ("hv" . boxquote-describe-variable)
1676 ("hw" . boxquote-where-is)
1677 ("k" . boxquote-kill)
1678 ("p" . boxquote-paragraph)
1679 ("q" . boxquote-boxquote)
1680 ("r" . boxquote-region)
1681 ("s" . boxquote-shell-command)
1682 ("t" . boxquote-text)
1683 ("T" . boxquote-title)
1684 ("u" . boxquote-unbox)
1685 ("U" . boxquote-unbox-region)
1686 ("y" . boxquote-yank)
1687 ("M-q" . boxquote-fill-paragraph)
1688 ("M-w" . boxquote-kill-ring-save)))
1690 (use-package orgalist
1691 ;; breaks auto-fill-mode, showing this error:
1692 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1695 :hook (message-mode . orgalist-mode))
1697 ;; highlight TODOs in buffers
1698 (use-package hl-todo
1701 (global-hl-todo-mode))
1703 (use-package multi-term
1706 :bind (("C-c a s m m" . multi-term)
1707 ("C-c a s m d" . multi-term-dedicated-toggle)
1708 ("C-c a s m p" . multi-term-prev)
1709 ("C-c a s m n" . multi-term-next)
1711 ("C-c C-j" . term-char-mode))
1713 (setq multi-term-program "screen"
1714 multi-term-program-switches (concat "-c"
1715 (getenv "XDG_CONFIG_HOME")
1717 ;; TODO: add separate bindings for connecting to existing
1718 ;; session vs. always creating a new one
1719 multi-term-dedicated-select-after-open-p t
1720 multi-term-dedicated-window-height 20
1721 multi-term-dedicated-max-window-height 30
1723 '(("C-c C-c" . term-interrupt-subjob)
1724 ("C-c C-e" . term-send-esc)
1725 ("C-c C-j" . term-line-mode)
1727 ;; ("C-y" . term-paste)
1728 ("C-y" . term-send-raw)
1729 ("M-f" . term-send-forward-word)
1730 ("M-b" . term-send-backward-word)
1731 ("M-p" . term-send-up)
1732 ("M-n" . term-send-down)
1733 ("M-j" . term-send-raw-meta)
1734 ("M-y" . term-send-raw-meta)
1735 ("M-/" . term-send-raw-meta)
1736 ("M-0" . term-send-raw-meta)
1737 ("M-1" . term-send-raw-meta)
1738 ("M-2" . term-send-raw-meta)
1739 ("M-3" . term-send-raw-meta)
1740 ("M-4" . term-send-raw-meta)
1741 ("M-5" . term-send-raw-meta)
1742 ("M-6" . term-send-raw-meta)
1743 ("M-7" . term-send-raw-meta)
1744 ("M-8" . term-send-raw-meta)
1745 ("M-9" . term-send-raw-meta)
1746 ("<C-backspace>" . term-send-backward-kill-word)
1747 ("<M-DEL>" . term-send-backward-kill-word)
1748 ("M-d" . term-send-delete-word)
1749 ("M-," . term-send-raw)
1750 ("M-." . comint-dynamic-complete))
1751 term-unbind-key-alist
1752 '("C-z" "C-x" "C-c" "C-h"
1756 (use-package page-break-lines
1759 (page-break-lines-max-width fill-column)
1761 (global-page-break-lines-mode))
1763 (use-package expand-region
1764 :bind ("C-=" . er/expand-region))
1766 (use-package multiple-cursors
1768 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1769 (:prefix-map b/mc-prefix-map
1771 ("c" . mc/edit-lines)
1772 ("n" . mc/mark-next-like-this)
1773 ("p" . mc/mark-previous-like-this)
1774 ("a" . mc/mark-all-like-this))))
1776 (use-package yasnippet
1779 (defconst yas-verbosity-cur yas-verbosity)
1780 (setq yas-verbosity 2)
1781 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1783 (setq yas-verbosity yas-verbosity-cur)
1785 (defun b/yas--maybe-expand-key-filter (cmd)
1786 (when (and (yas--maybe-expand-key-filter cmd)
1787 (not (bound-and-true-p git-commit-mode)))
1789 (defconst b/yas-maybe-expand
1790 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1791 (define-key yas-minor-mode-map
1792 (kbd "SPC") b/yas-maybe-expand)
1796 (use-package debbugs
1798 (("C-c D d" . debbugs-gnu)
1799 ("C-c D b" . debbugs-gnu-bugs)
1802 (interactive) ; bug-gnu-emacs
1803 (setq debbugs-gnu-current-suppress t)
1804 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1805 ("C-c D g" . ; bug-gnuzilla
1808 (setq debbugs-gnu-current-suppress t)
1809 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1810 ("C-c D G b" . ; bug-guix
1813 (setq debbugs-gnu-current-suppress t)
1814 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1815 ("C-c D G p" . ; guix-patches
1818 (setq debbugs-gnu-current-suppress t)
1819 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1821 (use-package org-ref
1823 (b/setq-every '("~/usr/org/references.bib")
1824 reftex-default-bibliography
1825 org-ref-default-bibliography)
1827 org-ref-bibliography-notes "~/usr/org/notes.org"
1828 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1830 ;; (use-package fill-column-indicator)
1834 (("C-c w e" . (lambda ()
1836 (split-window-right)
1838 (erc-switch-to-buffer)))
1839 ("C-c w s l" . (lambda ()
1841 (split-window-right)
1843 ("C-c w s j" . (lambda ()
1845 (split-window-below)
1847 ("C-c w q" . quit-window))
1849 (split-width-threshold 150))
1851 (use-package windmove
1854 (("C-c w h" . windmove-left)
1855 ("C-c w j" . windmove-down)
1856 ("C-c w k" . windmove-up)
1857 ("C-c w l" . windmove-right)
1858 ("C-c w H" . windmove-swap-states-left)
1859 ("C-c w J" . windmove-swap-states-down)
1860 ("C-c w K" . windmove-swap-states-up)
1861 ("C-c w L" . windmove-swap-states-right)))
1865 :bind ("C-c a p" . pass)
1866 :hook (pass-mode . View-exit))
1868 (use-package pdf-tools
1870 :bind (:map pdf-view-mode-map
1871 ("<C-XF86Back>" . pdf-history-backward)
1872 ("<mouse-8>" . pdf-history-backward)
1873 ("<drag-mouse-8>" . pdf-history-backward)
1874 ("<C-XF86Forward>" . pdf-history-forward)
1875 ("<mouse-9>" . pdf-history-forward)
1876 ("<drag-mouse-9>" . pdf-history-forward)
1877 ("M-RET" . image-previous-line)
1878 ("C-s" . isearch-forward)
1879 ("s s" . isearch-forward))
1880 :config (pdf-tools-install nil t)
1881 :custom (pdf-view-resize-factor 1.05))
1883 (use-package org-pdftools
1885 :straight (:host github :repo "fuxialexander/org-pdftools")
1889 (with-eval-after-load 'org
1890 (require 'org-pdftools)))
1892 (use-package biblio)
1895 :hook (latex-mode . reftex-mode))
1897 (use-package reftex-cite
1899 :disabled ; enable to disable
1900 ; reftex-cite's default choice
1903 (defun reftex-get-bibkey-default ()
1904 "If the cursor is in a citation macro, return the word before the macro."
1905 (let* ((macro (reftex-what-macro 1)))
1907 (when (and macro (string-match "cite" (car macro)))
1908 (goto-char (cdr macro)))
1909 (reftex-this-word)))))
1911 (use-package minions
1913 :config (minions-mode))
1917 (dmenu-prompt-string "run: ")
1918 (dmenu-save-file (b/var "dmenu-items")))
1921 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1922 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1924 :straight (:host github :repo "clarete/eosd")
1930 (use-package scpaste
1933 (setq scpaste-http-destination "https://p.bndl.org"
1934 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1937 :bind ("C-c a e w" . eww)
1939 (eww-download-directory (file-name-as-directory
1940 (getenv "XDG_DOWNLOAD_DIR"))))
1943 ;;; Email (with Gnus)
1945 (defvar b/maildir (expand-file-name "~/mail/"))
1946 (with-eval-after-load 'recentf
1947 (add-to-list 'recentf-exclude b/maildir))
1950 b/gnus-init-file (b/etc "gnus")
1951 mail-user-agent 'gnus-user-agent
1952 read-mail-command 'gnus)
1955 :bind (("s-m" . gnus-plugged)
1956 ("s-M" . gnus-unplugged)
1957 ("C-c a m" . gnus-plugged)
1958 ("C-c a M" . gnus-unplugged))
1961 gnus-select-method '(nnnil "")
1962 gnus-secondary-select-methods
1963 '((nnimap "shemshak"
1964 (nnimap-stream plain)
1965 (nnimap-address "127.0.0.1")
1966 (nnimap-server-port 143)
1967 (nnimap-authenticator plain)
1968 (nnimap-user "amin@shemshak.local"))
1970 (nnimap-stream plain)
1971 (nnimap-address "127.0.0.1")
1972 (nnimap-server-port 143)
1973 (nnimap-authenticator plain)
1974 (nnimap-user "bandali@gnu.local")
1975 (nnimap-inbox "INBOX")
1976 (nnimap-split-methods 'nnimap-split-fancy)
1977 (nnimap-split-fancy (|
1978 ;; (: gnus-registry-split-fancy-with-parent)
1979 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1981 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1983 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
1985 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
1986 ;; *.lists.sr.ht, omitting one dot if present
1987 ;; add more \\.?\\([^.]*\\) if needed
1988 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
1990 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1992 (list ".*atreus.freelists.org" "l.atreus")
1993 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1994 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1995 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1996 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1997 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1998 ;; ----------------------------------
1999 ;; legend: (u)nsubscribed | (d)ead
2000 ;; ----------------------------------
2001 ;; otherwise, leave mail in INBOX
2004 (nnimap-stream plain)
2005 (nnimap-address "127.0.0.1")
2006 (nnimap-server-port 143)
2007 (nnimap-authenticator plain)
2008 (nnimap-user "abandali@uw.local")
2009 (nnimap-inbox "INBOX")
2010 (nnimap-split-methods 'nnimap-split-fancy)
2011 (nnimap-split-fancy (|
2012 ;; (: gnus-registry-split-fancy-with-parent)
2014 ("subject" "SE\\s-?212" "course.se212-f19")
2015 (from "SE\\s-?212" "course.se212-f19")
2019 (nnimap-stream plain)
2020 (nnimap-address "127.0.0.1")
2021 (nnimap-server-port 143)
2022 (nnimap-authenticator plain)
2023 (nnimap-user "abandali@csc.uw.local")))
2024 gnus-message-archive-group "nnimap+gnu:INBOX"
2027 (to-address . "atreus@freelists.org")
2028 (to-list . "atreus@freelists.org"))
2030 (to-address . "deepspec@lists.cs.princeton.edu")
2031 (to-list . "deepspec@lists.cs.princeton.edu")
2032 (list-identifier . "\\[deepspec\\]"))
2034 (to-address . "emacs-devel@gnu.org")
2035 (to-list . "emacs-devel@gnu.org"))
2036 ("l\\.help-gnu-emacs"
2037 (to-address . "help-gnu-emacs@gnu.org")
2038 (to-list . "help-gnu-emacs@gnu.org"))
2039 ("l\\.info-gnu-emacs"
2040 (to-address . "info-gnu-emacs@gnu.org")
2041 (to-list . "info-gnu-emacs@gnu.org"))
2042 ("l\\.emacs-orgmode"
2043 (to-address . "emacs-orgmode@gnu.org")
2044 (to-list . "emacs-orgmode@gnu.org")
2045 (list-identifier . "\\[O\\]"))
2046 ("l\\.emacs-tangents"
2047 (to-address . "emacs-tangents@gnu.org")
2048 (to-list . "emacs-tangents@gnu.org"))
2049 ("l\\.emacsconf-committee"
2050 (to-address . "emacsconf-committee@gnu.org")
2051 (to-list . "emacsconf-committee@gnu.org"))
2052 ("l\\.emacsconf-discuss"
2053 (to-address . "emacsconf-discuss@gnu.org")
2054 (to-list . "emacsconf-discuss@gnu.org"))
2055 ("l\\.emacsconf-register"
2056 (to-address . "emacsconf-register@gnu.org")
2057 (to-list . "emacsconf-register@gnu.org"))
2058 ("l\\.emacsconf-submit"
2059 (to-address . "emacsconf-submit@gnu.org")
2060 (to-list . "emacsconf-submit@gnu.org"))
2061 ("l\\.fencepost-users"
2062 (to-address . "fencepost-users@gnu.org")
2063 (to-list . "fencepost-users@gnu.org")
2064 (list-identifier . "\\[Fencepost-users\\]"))
2065 ("l\\.gnewsense-art"
2066 (to-address . "gnewsense-art@nongnu.org")
2067 (to-list . "gnewsense-art@nongnu.org")
2068 (list-identifier . "\\[gNewSense-art\\]"))
2069 ("l\\.gnewsense-dev"
2070 (to-address . "gnewsense-dev@nongnu.org")
2071 (to-list . "gnewsense-dev@nongnu.org")
2072 (list-identifier . "\\[Gnewsense-dev\\]"))
2073 ("l\\.gnewsense-users"
2074 (to-address . "gnewsense-users@nongnu.org")
2075 (to-list . "gnewsense-users@nongnu.org")
2076 (list-identifier . "\\[gNewSense-users\\]"))
2077 ("l\\.gnunet-developers"
2078 (to-address . "gnunet-developers@gnu.org")
2079 (to-list . "gnunet-developers@gnu.org")
2080 (list-identifier . "\\[GNUnet-developers\\]"))
2082 (to-address . "help-gnunet@gnu.org")
2083 (to-list . "help-gnunet@gnu.org")
2084 (list-identifier . "\\[Help-gnunet\\]"))
2086 (to-address . "bug-gnuzilla@gnu.org")
2087 (to-list . "bug-gnuzilla@gnu.org")
2088 (list-identifier . "\\[Bug-gnuzilla\\]"))
2090 (to-address . "gnuzilla-dev@gnu.org")
2091 (to-list . "gnuzilla-dev@gnu.org")
2092 (list-identifier . "\\[Gnuzilla-dev\\]"))
2094 (to-address . "guile-devel@gnu.org")
2095 (to-list . "guile-devel@gnu.org"))
2097 (to-address . "guile-user@gnu.org")
2098 (to-list . "guile-user@gnu.org"))
2100 (to-address . "guix-devel@gnu.org")
2101 (to-list . "guix-devel@gnu.org"))
2103 (to-address . "help-guix@gnu.org")
2104 (to-list . "help-guix@gnu.org"))
2106 (to-address . "info-guix@gnu.org")
2107 (to-list . "info-guix@gnu.org"))
2108 ("l\\.savannah-hackers-public"
2109 (to-address . "savannah-hackers-public@gnu.org")
2110 (to-list . "savannah-hackers-public@gnu.org"))
2111 ("l\\.savannah-users"
2112 (to-address . "savannah-users@gnu.org")
2113 (to-list . "savannah-users@gnu.org"))
2115 (to-address . "www-commits@gnu.org")
2116 (to-list . "www-commits@gnu.org"))
2118 (to-address . "www-discuss@gnu.org")
2119 (to-list . "www-discuss@gnu.org"))
2121 (to-address . "haskell-art@we.lurk.org")
2122 (to-list . "haskell-art@we.lurk.org")
2123 (list-identifier . "\\[haskell-art\\]"))
2125 (to-address . "haskell-cafe@haskell.org")
2126 (to-list . "haskell-cafe@haskell.org")
2127 (list-identifier . "\\[Haskell-cafe\\]"))
2129 (to-address . "notmuch@notmuchmail.org")
2130 (to-list . "notmuch@notmuchmail.org"))
2132 (to-address . "dev@lists.parabola.nu")
2133 (to-list . "dev@lists.parabola.nu")
2134 (list-identifier . "\\[Dev\\]"))
2135 ("l\\.~bandali\\.public-inbox"
2136 (to-address . "~bandali/public-inbox@lists.sr.ht")
2137 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2138 ("l\\.~sircmpwn\\.free-writers-club"
2139 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2140 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2141 ("l\\.~sircmpwn\\.srht-admins"
2142 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2143 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2144 ("l\\.~sircmpwn\\.srht-announce"
2145 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2146 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2147 ("l\\.~sircmpwn\\.srht-dev"
2148 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2149 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2150 ("l\\.~sircmpwn\\.srht-discuss"
2151 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2152 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2154 (to-address . "webmasters@gnu.org")
2155 (to-list . "webmasters@gnu.org"))
2162 gnus-large-newsgroup 50
2163 gnus-home-directory (b/var "gnus/")
2164 gnus-directory (concat gnus-home-directory "news/")
2165 message-directory (concat gnus-home-directory "mail/")
2166 nndraft-directory (concat gnus-home-directory "drafts/")
2167 gnus-save-newsrc-file nil
2168 gnus-read-newsrc-file nil
2169 gnus-interactive-exit nil
2170 gnus-gcc-mark-as-read t)
2172 (when (version< emacs-version "27")
2173 (with-eval-after-load 'nnmail
2175 'nnmail-split-abbrev-alist
2176 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2179 ;; (gnus-registry-initialize)
2181 (with-eval-after-load 'recentf
2182 (add-to-list 'recentf-exclude gnus-home-directory)))
2184 (use-package gnus-art
2187 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2188 gnus-sorted-header-list '("^From:"
2204 "^Mail-Followup-To:"
2208 "^X-detected-operating-system:"
2213 gnus-visible-headers (mapconcat 'identity
2214 gnus-sorted-header-list
2216 ;; local-lapsed article dates
2217 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2218 gnus-article-date-headers '(user-defined)
2219 gnus-article-time-format
2221 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2222 (local (article-make-date-line date 'local))
2223 (combined-lapsed (article-make-date-line date
2226 (string-match " (.+" combined-lapsed)
2227 (match-string 0 combined-lapsed))))
2228 (concat local lapsed))))
2230 :map gnus-article-mode-map
2231 ("M-L" . org-store-link)))
2233 (use-package gnus-sum
2234 :bind (:map gnus-summary-mode-map
2235 :prefix-map b/gnus-summary-prefix-map
2237 ("r" . gnus-summary-reply)
2238 ("w" . gnus-summary-wide-reply)
2239 ("v" . gnus-summary-show-raw-article))
2242 :map gnus-summary-mode-map
2243 ("M-L" . org-store-link))
2244 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2246 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2247 gnus-thread-sort-by-subject
2248 gnus-thread-sort-by-date)))
2250 (use-package gnus-msg
2252 (defvar b/shemshak-signature "Amin Bandali
2253 https://shemshak.org/~amin")
2254 (defvar b/uw-signature "Amin Bandali, MMath Student
2255 Cheriton School of Computer Science
2256 University of Waterloo
2257 https://bandali.eu.org")
2258 (defvar b/csc-signature "Amin Bandali
2259 System Administrator, Systems Committee
2260 Computer Science Club, University of Waterloo
2261 https://csclub.uwaterloo.ca/~abandali")
2262 (setq gnus-message-replysign t
2265 (address "bandali@gnu.org"))
2266 ("nnimap\\+gnu:l\\..*"
2269 (organization "GNU"))
2270 ((header "subject" "ThankCRM")
2271 (to "webmasters-comment@gnu.org")
2273 (eval (setq b/message-cite-say-hi nil)))
2274 ("nnimap\\+shemshak:.*"
2275 (address "amin@shemshak.org")
2277 (signature b/shemshak-signature)
2278 (gcc "nnimap+shemshak:Sent")
2279 (eval (setq b/message-cite-say-hi t)))
2281 (address "bandali@uwaterloo.ca")
2283 (signature b/uw-signature))
2284 ("nnimap\\+uw:INBOX"
2285 (gcc "\"nnimap+uw:Sent Items\""))
2287 (address "bandali@csclub.uwaterloo.ca")
2288 (signature b/csc-signature)
2289 (gcc "nnimap+csc:Sent"))))
2290 :hook (gnus-message-setup . (lambda ()
2291 (unless (mml-secure-is-encrypted-p)
2292 (mml-secure-message-sign)))))
2294 (use-package gnus-topic
2295 :hook (gnus-group-mode . gnus-topic-mode)
2296 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2298 (use-package gnus-agent
2300 (setq gnus-agent-synchronize-flags 'ask)
2301 :hook (gnus-group-mode . gnus-agent-mode))
2303 (use-package gnus-group
2305 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2308 ;; problematic with ebdb's popup, *EBDB-Gnus*
2309 (use-package gnus-win
2311 (setq gnus-use-full-window nil)))
2313 (use-package gnus-dired
2314 :commands gnus-dired-mode
2316 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2319 (use-package gnus-utils
2321 (gnus-completing-read-function 'gnus-ido-completing-read)))
2323 (use-package mm-decode
2325 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2326 mm-decrypt-option 'known
2327 mm-verify-option 'known))
2331 (when (version< "27" emacs-version)
2332 (set-face-attribute 'mm-uu-extract nil :extend t))
2334 (mm-uu-diff-groups-regexp
2335 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2337 (use-package sendmail
2339 (setq sendmail-program (executable-find "msmtp")
2340 ;; message-sendmail-extra-arguments '("-v" "-d")
2341 mail-specify-envelope-from t
2342 mail-envelope-from 'header))
2344 (use-package message
2345 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2347 ;; redefine for a simplified In-Reply-To header
2348 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2349 (defun message-make-in-reply-to ()
2350 "Return the In-Reply-To header for this message."
2351 (when message-reply-headers
2352 (let ((from (mail-header-from message-reply-headers))
2353 (msg-id (mail-header-id message-reply-headers)))
2357 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2358 (defconst message-cite-style-bandali
2359 '((message-cite-function 'message-cite-original)
2360 (message-citation-line-function 'message-insert-formatted-citation-line)
2361 (message-cite-reply-position 'traditional)
2362 (message-yank-prefix "> ")
2363 (message-yank-cited-prefix ">")
2364 (message-yank-empty-prefix ">")
2365 (message-citation-line-format
2366 (if b/message-cite-say-hi
2367 (concat "Hi %F,\n\n" b/message-cite-style-format)
2368 b/message-cite-style-format)))
2369 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2370 (setq ;; message-cite-style 'message-cite-style-bandali
2371 message-kill-buffer-on-exit t
2372 message-send-mail-function 'message-send-mail-with-sendmail
2373 message-sendmail-envelope-from 'header
2374 message-subscribed-address-functions
2375 '(gnus-find-subscribed-addresses)
2376 message-dont-reply-to-names
2377 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2378 ;; (require 'company-ebdb)
2379 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2380 (message-mode . flyspell-mode)
2381 (message-mode . (lambda ()
2382 ;; (setq-local fill-column b/fill-column
2383 ;; message-fill-column b/fill-column)
2384 (make-local-variable 'company-idle-delay)
2385 (setq company-idle-delay 0.2))))
2387 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2388 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2389 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2391 (message-elide-ellipsis "[...]\n"))
2395 (use-package mml-sec
2397 (mml-secure-openpgp-encrypt-to-self t)
2398 (mml-secure-openpgp-sign-with-sender t))
2400 (use-package footnote
2403 ;; (setq footnote-start-tag ""
2404 ;; footnote-end-tag ""
2405 ;; footnote-style 'unicode)
2407 (:map message-mode-map
2408 :prefix-map b/footnote-prefix-map
2410 ("a" . footnote-add-footnote)
2411 ("b" . footnote-back-to-message)
2412 ("c" . footnote-cycle-style)
2413 ("d" . footnote-delete-footnote)
2414 ("g" . footnote-goto-footnote)
2415 ("r" . footnote-renumber-footnotes)
2416 ("s" . footnote-set-style)))
2421 :bind (:map gnus-group-mode-map ("e" . ebdb))
2423 (setq ebdb-sources (b/var "ebdb"))
2424 (with-eval-after-load 'swiper
2425 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2427 (use-package ebdb-com
2430 (use-package ebdb-complete
2433 ;; (setq ebdb-complete-mail 'capf)
2434 (ebdb-complete-enable))
2436 (use-package ebdb-message
2440 ;; (use-package company-ebdb
2442 ;; (defun company-ebdb--post-complete (_) nil))
2444 (use-package ebdb-gnus
2447 (ebdb-gnus-window-size 0.3))
2449 (use-package ebdb-mua
2452 :custom (ebdb-mua-pop-up t))
2454 ;; (use-package ebdb-message
2457 ;; (use-package ebdb-vcard
2460 (use-package message-x)
2463 (use-package message-x
2465 (message-x-completion-alist
2467 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2470 (quote message-newgroups-header-regexp))
2471 message-newgroups-header-regexp message-newsgroups-header-regexp)
2472 . message-expand-group))))))
2475 (use-package gnus-harvest
2476 :commands gnus-harvest-install
2479 (if (featurep 'message-x)
2480 (gnus-harvest-install 'message-x)
2481 (gnus-harvest-install))))
2483 (use-package gnus-article-treat-patch
2488 ;; note: be sure to customize faces with `:foreground "white"' when
2489 ;; using a theme with a white/light background :)
2490 (setq ft/gnus-article-patch-conditions
2491 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2494 ;;; IRC (with ERC and ZNC)
2497 :bind (("C-c b b" . erc-switch-to-buffer)
2499 ("M-a" . erc-track-switch-buffer))
2501 (erc-join-buffer 'bury)
2502 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2503 (erc-nick "bandali")
2505 (erc-rename-buffers t)
2506 (erc-server-reconnect-attempts 5)
2507 (erc-server-reconnect-timeout 3)
2509 (defun erc-cmd-OPME ()
2510 "Request chanserv to op me."
2511 (erc-message "PRIVMSG"
2512 (format "chanserv op %s %s"
2513 (erc-default-target)
2514 (erc-current-nick)) nil))
2515 (defun erc-cmd-DEOPME ()
2516 "Deop myself from current channel."
2517 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2518 (add-to-list 'erc-modules 'keep-place)
2519 (add-to-list 'erc-modules 'notifications)
2520 (add-to-list 'erc-modules 'smiley)
2521 (add-to-list 'erc-modules 'spelling)
2522 (add-to-list 'erc-modules 'scrolltoplace)
2523 (erc-update-modules))
2525 (use-package erc-fill
2528 (erc-fill-column 77)
2529 (erc-fill-function 'erc-fill-static)
2530 (erc-fill-static-center 18))
2532 (use-package erc-pcomplete
2535 (erc-pcomplete-nick-postfix ", "))
2537 (use-package erc-track
2539 :bind (("C-c a e t d" . erc-track-disable)
2540 ("C-c a e t e" . erc-track-enable))
2542 (erc-track-enable-keybindings nil)
2543 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2544 "324" "329" "332" "333" "353" "477"))
2545 (erc-track-position-in-mode-line t)
2546 (erc-track-priority-faces-only 'all)
2547 (erc-track-shorten-function nil))
2549 (use-package erc-hl-nicks
2552 (use-package erc-scrolltoplace
2556 :bind (("C-c a e e" . znc-erc)
2557 ("C-c a e a" . znc-all))
2559 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2561 ((null auth) (error "Couldn't find znca's authinfo"))
2562 (t (funcall (plist-get (car auth) :secret)))))))
2564 `(("znc.shemshak.org" 1337 t
2565 ((freenode "amin/freenode" ,pwd)))
2566 ("znc.shemshak.org" 1337 t
2567 ((oftc "amin/oftc" ,pwd)))))))
2570 ;;; Post initialization
2572 (message "Loading %s...done (%.3fs)" user-init-file
2573 (float-time (time-subtract (current-time)
2574 b/before-user-init-time)))
2576 ;;; init.el ends here