1 ;;; init.el --- mab's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2019 Amin Bandali <mab@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 ;; Emacs configuration of Amin Bandali, computer scientist, free
21 ;; software activist, GNU maintainer & webmaster. Packages are
22 ;; installed from GNU Guix, for purely functional and fully
23 ;; reproducible package management. Before switching to GNU Guix,
24 ;; I used straight.el for package management, and before that, Borg.
26 ;; Over the years, I've taken inspiration from configurations of many
27 ;; great people. Some that I can remember off the top of my head are:
29 ;; - https://github.com/dieggsy/dotfiles
30 ;; - https://github.com/dakra/dmacs
31 ;; - http://pages.sachachua.com/.emacs.d/Sacha.html
32 ;; - https://github.com/dakrone/eos
33 ;; - http://doc.rix.si/cce/cce.html
34 ;; - https://github.com/jwiegley/dot-emacs
35 ;; - https://github.com/wasamasa/dotemacs
36 ;; - https://github.com/hlissner/doom-emacs
40 ;;; Emacs initialization
42 (defvar b
/before-user-init-time
(current-time)
43 "Value of `current-time' when Emacs begins loading `user-init-file'.")
44 (defvar b
/emacs-initialized nil
45 "Whether Emacs has been initialized.")
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
(* 400 1024 1024) ; 400 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
))
71 (add-hook 'after-init-hook
#'b
/post-init
)
73 ;; increase number of lines kept in *Messages* log
74 (setq message-log-max
20000)
76 ;; optionally, uncomment to supress some byte-compiler warnings
77 ;; (see C-h v byte-compile-warnings RET for more info)
78 ;; (setq byte-compile-warnings
79 ;; '(not free-vars unresolved noruntime lexical make-local))
84 (setq user-full-name
"Amin Bandali"
85 user-mail-address
"mab@gnu.org")
90 ;; useful for commenting out multiple sexps at a time
91 (defmacro comment
(&rest _
)
92 "Comment out one or more s-expressions."
93 (declare (indent defun
))
97 ;;; Package management
99 ;; No package.el (for emacs 26 and before)
100 (when (version< emacs-version
"27")
101 (setq package-enable-at-startup nil
)
102 ;; (package-initialize)
104 ;; for emacs 27 and later, we use early-init.el. see
105 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
109 (if nil
; set to t when need to debug init
111 (setq use-package-verbose t
112 use-package-expand-minimally nil
113 use-package-compute-statistics t
115 (require 'use-package
))
116 (setq use-package-verbose nil
117 use-package-expand-minimally t
))
119 (setq use-package-always-defer t
)
125 (defvar b
/exwm-p
(string= (system-name) "chaman")
126 "Whether or not we will be using `exwm'.")
128 ;; keep ~/.emacs.d clean
129 (use-package no-littering
132 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
133 (defalias 'b
/var
'no-littering-expand-var-file-name
))
135 ;; separate custom file (don't want it mixing with init.el)
139 (setq custom-file
(b/etc
"custom.el"))
140 (when (file-exists-p custom-file
)
142 ;; while at it, treat themes as safe
143 (setf custom-safe-themes t
)
144 ;; only one custom theme at a time
146 (defadvice load-theme
(before clear-previous-themes activate
)
147 "Clear existing theme settings instead of layering them"
148 (mapc #'disable-theme custom-enabled-themes
))))
150 ;; load the secrets file if it exists, otherwise show a warning
153 (load (b/etc
"secrets"))))
155 ;; better $PATH (and other environment variable) handling
156 (use-package exec-path-from-shell
159 (setq exec-path-from-shell-arguments nil
160 exec-path-from-shell-check-startup-files nil
)
162 (exec-path-from-shell-initialize)
163 ;; while we're at it, let's fix access to our running ssh-agent
164 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
165 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")
166 (exec-path-from-shell-copy-env "XDG_DOWNLOAD_DIR"))
168 ;; start up emacs server. see
169 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
172 :config
(or (server-running-p) (server-mode)))
181 (defmacro b
/setq-every
(value &rest vars
)
182 "Set all the variables from VARS to value VALUE."
183 (declare (indent defun
) (debug t
))
184 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
186 (defun b/start-process
(program &rest args
)
187 "Same as `start-process', but doesn't bother about name and buffer."
188 (let ((process-name (concat program
"_process"))
189 (buffer-name (generate-new-buffer-name
190 (concat program
"_output"))))
191 (apply #'start-process
192 process-name buffer-name program args
)))
194 (defun b/dired-start-process
(program &optional args
)
195 "Open current file with a PROGRAM."
196 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
197 ;; be nil, so remove it).
198 (apply #'b
/start-process
200 (remove nil
(list args
(dired-get-file-for-visit)))))
202 (defun b/add-elisp-section
()
206 (insert "\n\f\n;;; "))
208 ;; (defvar b/fill-column 47
209 ;; "My custom `fill-column'.")
211 (defconst b
/asterism
"* * *")
213 (defun b/insert-asterism
()
214 "Insert a centred asterism."
219 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
224 (defun b/no-mouse-autoselect-window
()
225 "Conveniently disable `focus-follows-mouse'.
226 For disabling the behaviour for certain buffers and/or modes."
227 (make-local-variable 'mouse-autoselect-window
)
228 (setq mouse-autoselect-window nil
))
230 (defun b/kill-current-buffer
()
231 "Kill the current buffer."
232 ;; also see https://redd.it/64xb3q
234 (kill-buffer (current-buffer)))
239 ;;;; C-level customizations
243 enable-recursive-minibuffers t
244 resize-mini-windows t
245 ;; more useful frame titles
246 frame-title-format
'("" invocation-name
" - "
248 (if (buffer-file-name)
249 (abbreviate-file-name (buffer-file-name))
251 ;; i don't feel like jumping out of my chair every now and again; so
252 ;; don't BEEP! at me, emacs
253 ring-bell-function
'ignore
256 ;; scroll-conservatively 10000
258 scroll-conservatively
10
259 scroll-preserve-screen-position
1
260 ;; focus follows mouse
261 mouse-autoselect-window t
)
264 ;; always use space for indentation
272 (dolist (ft (fontset-list))
276 (font-spec :name
"Source Code Pro" :size
14))
280 (font-spec :name
"DejaVu Sans Mono")
287 ;; :name "Symbola monospacified for DejaVu Sans Mono")
293 ;; (font-spec :name "DejaVu Sans Mono")
299 (font-spec :name
"DejaVu Sans Mono" :size
14)
303 ;;;; Elisp-level customizations
309 ;; don't need to see the startup echo area message
310 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
312 ;; i want *scratch* as my startup buffer
313 (initial-buffer-choice t
)
314 ;; i don't need the default hint
315 (initial-scratch-message nil
)
316 ;; use customizable text-mode as major mode for *scratch*
317 ;; (initial-major-mode 'text-mode)
318 ;; inhibit buffer list when more than 2 files are loaded
319 (inhibit-startup-buffer-menu t
)
320 ;; don't need to see the startup screen or echo area message
321 (inhibit-startup-screen t
)
322 (inhibit-startup-echo-area-message user-login-name
))
328 ;; backups (C-h v make-backup-files RET)
329 (backup-by-copying t
)
331 (delete-old-versions t
)
334 (auto-save-file-name-transforms
335 `((".*" ,(b/var
"auto-save/") t
)))
337 ;; insert newline at the end of files
338 (require-final-newline t
)
340 ;; open read-only file buffers in view-mode
341 ;; (enables niceties like `q' for quit)
344 ;; disable disabled commands
345 (setq disabled-command-function nil
)
347 ;; lazy-person-friendly yes/no prompts
348 (defalias 'yes-or-no-p
#'y-or-n-p
)
350 ;; enable automatic reloading of changed buffers and files
351 (use-package autorevert
354 (global-auto-revert-mode 1)
356 (auto-revert-verbose nil
)
357 (global-auto-revert-non-file-buffers nil
))
359 ;; time and battery in mode-line
366 (display-time-default-load-average nil
)
367 (display-time-format "%a %b %-e, %-l:%M%P")
368 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
369 (display-time-use-mail-icon t
))
375 (display-battery-mode)
377 (battery-mode-line-format " %p%% %t"))
383 ;; (fringe-mode '(3 . 1))
389 ;; enable winner-mode (C-h f winner-mode RET)
394 ;; don't display *compilation* buffer on success. based on
395 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
396 ;; instead of the now obsolete `flet'.
397 (defun b/compilation-finish-function
(buffer outstr
)
398 (unless (string-match "finished" outstr
)
399 (switch-to-buffer-other-window buffer
))
402 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
406 (defadvice compilation-start
407 (around inhibit-display
408 (command &optional mode name-function highlight-regexp
))
409 (if (not (string-match "^\\(find\\|grep\\)" command
))
410 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
411 (save-window-excursion ad-do-it
))
413 (ad-activate 'compilation-start
))
417 ;; allow scrolling in Isearch
418 (isearch-allow-scroll t
)
419 ;; search for non-ASCII characters: i’d like non-ASCII characters such
420 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
421 ;; counterpart. shoutout to
422 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
423 (search-default-mode #'char-fold-to-regexp
))
425 ;; uncomment to extend the above behaviour to query-replace
429 (replace-char-fold t
)))
432 :bind
("C-x v C-=" . vc-ediff
))
437 (vc-git-print-log-follow t
))
440 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
441 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
442 (ediff-split-window-function 'split-window-horizontally
)))
444 (use-package face-remap
446 ;; gentler font resizing
447 (text-scale-mode-step 1.05))
452 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
453 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
454 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
456 (use-package pixel-scroll
458 :config
(pixel-scroll-mode 1))
460 (use-package epg-config
462 ;; ask for GPG passphrase in minibuffer
463 ;; this will fail if gpg>=2.1 is not available
464 (if (version< "27" emacs-version
)
465 (setq epg-pinentry-mode
'loopback
)
466 (setq epa-pinentry-mode
'loopback
))
468 (epg-gpg-program (executable-find "gpg")))
473 (use-package pinentry
475 :after
(epa epg server
)
477 ;; workaround for systemd-based distros:
478 ;; (setq pinentry--socket-dir server-socket-dir)
481 (use-package auth-source
483 (auth-sources '("~/.authinfo.gpg"))
484 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
492 ("C-c e b" . eval-buffer
)
493 ("C-c e e" . eval-last-sexp
)
494 ("C-c e r" . eval-region
)
496 ("C-c e i" . emacs-init-time
)
497 ("C-c e u" . emacs-uptime
)
498 ("C-c e v" . emacs-version
)
500 ("C-c F m" . make-frame-command
)
501 ("C-c F d" . delete-frame
)
502 ("C-c F D" . server-edit
)
504 ("C-S-h C" . describe-char
)
505 ("C-S-h F" . describe-face
)
507 ("C-x k" . b
/kill-current-buffer
)
508 ("C-x K" . kill-buffer
)
509 ("C-x s" . save-buffer
)
510 ("C-x S" . save-some-buffers
)
512 :map emacs-lisp-mode-map
513 ("<C-return>" . b
/add-elisp-section
))
515 (when (display-graphic-p)
516 (unbind-key "C-z" global-map
))
519 ;; for back and forward mouse keys
520 ("<XF86Back>" . previous-buffer
)
521 ("<mouse-8>" . previous-buffer
)
522 ;; ("<drag-mouse-8>" . previous-buffer)
523 ("<XF86Forward>" . next-buffer
)
524 ("<mouse-9>" . next-buffer
)
525 ;; ("<drag-mouse-9>" . next-buffer)
526 ;; ("<drag-mouse-2>" . kill-this-buffer)
527 ;; ("<drag-mouse-3>" . switch-to-buffer)
531 ;;; Essential packages
537 ;; make class name the buffer name, truncating beyond 60 characters
538 (defun b/exwm-rename-buffer
()
540 (exwm-workspace-rename-buffer
541 (concat exwm-class-name
":"
542 (if (<= (length exwm-title
) 60) exwm-title
543 (concat (substring exwm-title
0 59) "...")))))
546 :hook
((exwm-update-class . b
/exwm-rename-buffer
)
547 (exwm-update-title . b
/exwm-rename-buffer
)))
549 (use-package exwm-config
552 :hook
(exwm-init . exwm-config--fix
/ido-buffer-window-other-frame
))
554 (use-package exwm-input
558 (defun b/exwm-ws-prev-index
()
559 "Return the index for the previous EXWM workspace, wrapping
561 (if (= exwm-workspace-current-index
0)
562 (1- exwm-workspace-number
)
563 (1- exwm-workspace-current-index
)))
565 (defun b/exwm-ws-next-index
()
566 "Return the index for the next EXWM workspace, wrapping
568 (if (= exwm-workspace-current-index
569 (1- exwm-workspace-number
))
571 (1+ exwm-workspace-current-index
)))
573 ;; shorten 'C-c C-q' to 'C-q'
574 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
576 (setq exwm-workspace-number
4
577 exwm-input-global-keys
578 `(([?\s-R
] . exwm-reset
)
579 ([?\s-
\\] . exwm-workspace-switch
)
581 ([?\S-\s-\s
] .
(lambda (command)
583 (list (read-shell-command "➜ ")))
584 (start-process-shell-command
585 command nil command
)))
586 ([s-return
] .
(lambda ()
588 (start-process "" nil
"urxvt")))
589 ([?\C-\s-\s
] . counsel-linux-app
)
590 ([?\M-\s-\s
] .
(lambda ()
592 (start-process-shell-command
593 "rofi-pass" nil
"rofi-pass")))
594 ([?\s-h
] . windmove-left
)
595 ([?\s-j
] . windmove-down
)
596 ([?\s-k
] . windmove-up
)
597 ([?\s-l
] . windmove-right
)
598 ([?\s-H
] . windmove-swap-states-left
)
599 ([?\s-J
] . windmove-swap-states-down
)
600 ([?\s-K
] . windmove-swap-states-up
)
601 ([?\s-L
] . windmove-swap-states-right
)
602 ([?\M-\s-h
] . shrink-window-horizontally
)
603 ([?\M-\s-l
] . enlarge-window-horizontally
)
604 ([?\M-\s-k
] . shrink-window
)
605 ([?\M-\s-j
] . enlarge-window
)
606 ([?\s-\
[] .
(lambda ()
608 (exwm-workspace-switch-create
609 (b/exwm-ws-prev-index
))))
610 ([?\s-\
]] .
(lambda ()
612 (exwm-workspace-switch-create
613 (b/exwm-ws-next-index
))))
614 ([?\s-
{] .
(lambda ()
616 (exwm-workspace-move-window
617 (b/exwm-ws-prev-index
))))
618 ([?\s-
}] .
(lambda ()
620 (exwm-workspace-move-window
621 (b/exwm-ws-next-index
))))
622 ,@(mapcar (lambda (i)
623 `(,(kbd (format "s-%d" i
)) .
626 (exwm-workspace-switch-create ,i
))))
627 (number-sequence 0 (1- exwm-workspace-number
)))
628 ([?\s-t
] . exwm-floating-toggle-floating
)
629 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
630 ([?\s-W
] .
(lambda ()
632 (kill-buffer (current-buffer))))
633 ([?\s-Q
] .
(lambda ()
635 (exwm-manage--kill-client)))
636 ([?\s-
\'] .
(lambda ()
638 (start-process-shell-command
639 "rofi-light" nil
"rofi-light")))
643 (start-process "" nil "amixer" "set" "'Master',0" "toggle")))
644 ([XF86AudioLowerVolume] .
648 "" nil "amixer" "set" "'Master',0" "5%-")))
649 ([XF86AudioRaiseVolume] .
653 "" nil "amixer" "set" "'Master',0" "5%+")))
657 (start-process "" nil "mpc" "toggle")))
661 (start-process "" nil "mpc" "prev")))
665 (start-process "" nil "mpc" "next")))
669 (start-process "" nil "dm-tool" "lock")))
670 ([\s-XF86Back] . previous-buffer)
671 ([\s-XF86Forward] . next-buffer)))
673 ;; Line-editing shortcuts
674 (setq exwm-input-simulation-keys
679 ([?\M-f] . [C-right])
687 ([?\C-k] . [S-end ?\C-x])
694 ([?\M-d] . [C-S-right ?\C-x])
695 ([?\M-\d] . [C-S-left ?\C-x])
702 ([?\C-g] . [escape]))))
704 (use-package exwm-manage
708 (exwm-manage-finish . (lambda ()
709 (when exwm-class-name
711 ((string= exwm-class-name "IceCat")
712 (exwm-input-set-local-simulation-keys
713 `(,@exwm-input-simulation-keys
714 ([?\C-\S-d] . [?\C-d]))))
715 ((string= exwm-class-name "URxvt")
716 (exwm-input-set-local-simulation-keys
717 '(([?\C-c ?\C-c] . [?\C-c])
718 ([?\C-c ?\C-u] . [?\C-u]))))
719 ((string= exwm-class-name "Zathura")
720 (exwm-input-set-local-simulation-keys
722 ([?\C-n] . [C-down])))))))))
724 (use-package exwm-randr
730 (exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
732 (use-package exwm-systemtray
736 (exwm-systemtray-enable))
738 (use-package exwm-workspace)
740 (use-package exwm-edit
744 ;; use the org-plus-contrib package to get the whole deal
745 (use-package org-plus-contrib)
750 (setq org-src-tab-acts-natively t
751 org-src-preserve-indentation nil
752 org-edit-src-content-indentation 0
753 org-link-email-description-format "Email %c: %s" ; %.30s
754 org-highlight-latex-and-related '(entities)
755 org-use-speed-commands t
756 org-startup-folded 'content
757 org-catch-invisible-edits 'show-and-error
759 (when (version< org-version "9.3")
760 (setq org-email-link-description-format
761 org-link-email-description-format))
762 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
763 (add-to-list 'org-modules 'org-habit)
765 (("C-c a o a" . org-agenda)
767 ("M-L" . org-insert-last-stored-link)
768 ("M-O" . org-toggle-link-display))
769 :hook ((org-mode . org-indent-mode)
770 (org-mode . auto-fill-mode)
771 (org-mode . flyspell-mode))
773 (org-pretty-entities t)
774 (org-agenda-files '("~/usr/org/todos/personal.org"
775 "~/usr/org/todos/habits.org"
776 "~/src/git/masters-thesis/todo.org"))
777 (org-agenda-start-on-weekday 0)
778 (org-agenda-time-leading-zero t)
779 (org-habit-graph-column 44)
780 (org-latex-packages-alist '(("" "listings") ("" "color")))
782 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
783 '(org-block ((t (:background "#1d1f21"))))
784 '(org-latex-and-related ((t (:foreground "#b294bb")))))
786 (use-package ox-latex
789 (setq org-latex-listings 'listings
790 ;; org-latex-prefer-user-labels t
792 (add-to-list 'org-latex-classes
793 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
794 ("\\section{%s}" . "\\section*{%s}")
795 ("\\subsection{%s}" . "\\subsection*{%s}")
796 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
797 ("\\paragraph{%s}" . "\\paragraph*{%s}")
798 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
800 (require 'ox-beamer))
802 (use-package ox-extra
804 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
806 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
807 ;; org file. closely inspired by
808 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
809 (with-eval-after-load 'org
810 (defvar b/show-async-tangle-results nil
811 "Keep *emacs* async buffers around for later inspection.")
813 (defvar b/show-async-tangle-time nil
814 "Show the time spent tangling the file.")
816 (defun b/async-babel-tangle ()
817 "Tangle org file asynchronously."
819 (let* ((file-tangle-start-time (current-time))
820 (file (buffer-file-name))
821 (file-nodir (file-name-nondirectory file))
822 ;; (async-quiet-switch "-q")
823 (file-noext (file-name-sans-extension file)))
827 (org-babel-tangle-file ,file))
828 (unless b/show-async-tangle-results
831 (message "Tangled %s%s"
833 (if b/show-async-tangle-time
835 (float-time (time-subtract (current-time)
836 ',file-tangle-start-time)))
838 (message "Tangling %s failed" ,file-nodir))))))))
841 'safe-local-variable-values
842 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
844 ;; *the* right way to do git
847 :bind (("C-x g" . magit-status)
848 ("C-c g g" . magit-status)
849 ("C-c g b" . magit-blame-addition)
850 ("C-c g l" . magit-log-buffer-file))
852 (magit-add-section-hook 'magit-status-sections-hook
853 'magit-insert-modules
854 'magit-insert-stashes
856 ;; (magit-add-section-hook 'magit-status-sections-hook
857 ;; 'magit-insert-ignored-files
858 ;; 'magit-insert-untracked-files
860 (setq magit-repository-directories '(("~/" . 0)
862 (nconc magit-section-initial-visibility-alist
863 '(([unpulled status] . show)
864 ([unpushed status] . show)))
866 (magit-diff-refine-hunk t)
867 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
868 ;; (magit-completing-read-function 'magit-ido-completing-read)
869 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
871 ;; recently opened files
875 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
879 (recentf-max-saved-items 2000))
881 ;; smart M-x enhancement (needed by counsel for history)
882 ;; (use-package smex)
885 ("C-c f ." . find-file)
886 ("C-c f l" . find-library)
887 ("C-c f r" . recentf-open-files)
888 ("C-c x" . execute-extended-command))
894 (:map ido-common-completion-map
895 ([escape] . minibuffer-keyboard-quit)
896 ("DEL" . b/ido-backspace))
899 (defun b/ido-backspace ()
900 "Forward to `backward-delete-char'. On error (read-only), quit."
903 (backward-delete-char 1)
905 (minibuffer-keyboard-quit))))
909 (ido-enable-flex-matching t)
910 ;; (ido-enable-regexp t)
911 ;; (ido-enable-prefix t)
912 (ido-max-window-height 10)
913 (ido-use-virtual-buffers t))
915 (use-package ido-vertical-mode
918 (ido-vertical-mode 1)
920 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
921 (ido-vertical-show-count t))
923 (use-package ido-completing-read+
927 (ido-ubiquitous-mode 1))
929 (use-package crm-custom
934 (use-package icomplete
947 (:map ivy-minibuffer-map
948 ([escape] . keyboard-escape-quit)
949 ([S-up] . ivy-previous-history-element)
950 ([S-down] . ivy-next-history-element)
951 ("DEL" . ivy-backward-delete-char))
955 ivy-use-virtual-buffers t
956 ivy-virtual-abbreviate 'abbreviate
957 ivy-count-format "%d/%d ")
959 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
960 (defun b/ivy-ignore-buffer-p (str)
961 "Return non-nil if str names a buffer with a major mode
962 derived from one of `b/ivy-ignore-buffer-modes'.
964 This function is intended for use with `ivy-ignore-buffers'."
965 (let* ((buf (get-buffer str))
966 (mode (and buf (buffer-local-value 'major-mode buf))))
968 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
969 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
973 (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
974 (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
975 (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
976 (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
977 (ivy-current-match ((((class color) (background light))
978 :background "#d7d7d7" :foreground "black")
979 (((class color) (background dark))
980 :background "#65a7e2" :foreground "black"))))
985 :bind (("C-S-s" . swiper-isearch)))
990 :bind (("C-c f r" . counsel-recentf)
991 :map minibuffer-local-map
992 ("C-r" . counsel-minibuffer-history))
995 (defalias 'locate #'counsel-locate))
999 :commands (helm-M-x helm-mini helm-resume)
1000 :bind (("M-x" . helm-M-x)
1001 ("M-y" . helm-show-kill-ring)
1002 ("C-x b" . helm-mini)
1003 ("C-x C-b" . helm-buffers-list)
1004 ("C-x C-f" . helm-find-files)
1005 ("C-h r" . helm-info-emacs)
1006 ("C-s-r" . helm-resume)
1008 ("<tab>" . helm-execute-persistent-action)
1009 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
1010 ("C-z" . helm-select-action)) ; List actions
1011 :config (helm-mode 1)))
1016 :bind ("C-c a s e" . eshell)
1018 (eval-when-compile (defvar eshell-prompt-regexp))
1019 (defun b/eshell-quit-or-delete-char (arg)
1021 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
1022 (eshell-life-is-too-much)
1025 (defun b/eshell-clear ()
1027 (let ((inhibit-read-only t))
1029 (eshell-send-input))
1031 (defun b/eshell-setup ()
1032 (make-local-variable 'company-idle-delay)
1033 (defvar company-idle-delay)
1034 (setq company-idle-delay nil)
1035 (bind-keys :map eshell-mode-map
1036 ("C-d" . b/eshell-quit-or-delete-char)
1037 ("C-S-l" . b/eshell-clear)
1038 ("M-r" . counsel-esh-history)
1039 ;; ([tab] . company-complete)
1041 (if (version< "27" emacs-version)
1042 (bind-keys :map eshell-hist-mode-map
1043 ("M-r" . counsel-esh-history))
1044 (bind-keys :map eshell-mode-map
1045 ("M-r" . counsel-esh-history))))
1047 :hook (eshell-mode . b/eshell-setup)
1049 (eshell-hist-ignoredups t)
1050 (eshell-input-filter 'eshell-input-filter-initial-space))
1052 (use-package ibuffer
1054 (("C-x C-b" . ibuffer)
1055 :map ibuffer-mode-map
1056 ("P" . ibuffer-backward-filter-group)
1057 ("N" . ibuffer-forward-filter-group)
1058 ("M-p" . ibuffer-do-print)
1059 ("M-n" . ibuffer-do-shell-command-pipe-replace))
1061 ;; Use human readable Size column instead of original one
1062 (define-ibuffer-column size-h
1063 (:name "Size" :inline t)
1065 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1066 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
1067 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
1068 (t (format "%8d" (buffer-size)))))
1070 (ibuffer-saved-filter-groups
1072 ("dired" (mode . dired-mode))
1073 ("org" (mode . org-mode))
1076 (mode . gnus-group-mode)
1077 (mode . gnus-summary-mode)
1078 (mode . gnus-article-mode)
1079 ;; not really, but...
1080 (mode . message-mode)))
1089 (mode . eshell-mode)
1091 (mode . term-mode)))
1094 (mode . python-mode)
1098 (mode . emacs-lisp-mode)
1099 (mode . scheme-mode)
1100 (mode . haskell-mode)
1103 (mode . alloy-mode)))
1106 (mode . bibtex-mode)
1107 (mode . latex-mode)))
1110 (name . "^\\*scratch\\*$")
1111 (name . "^\\*Messages\\*$")))
1112 ("exwm" (mode . exwm-mode))
1113 ("erc" (mode . erc-mode)))))
1115 '((mark modified read-only locked " "
1116 (name 72 72 :left :elide)
1118 (size-h 9 -1 :right)
1120 (mode 16 16 :left :elide)
1121 " " filename-and-process)
1125 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1127 (use-package outline
1129 :hook (prog-mode . outline-minor-mode)
1132 outline-minor-mode-map
1133 ("<s-tab>" . outline-toggle-children)
1134 ("M-p" . outline-previous-visible-heading)
1135 ("M-n" . outline-next-visible-heading)
1136 :prefix-map b/outline-prefix-map
1138 ("TAB" . outline-toggle-children)
1139 ("a" . outline-hide-body)
1140 ("H" . outline-hide-body)
1141 ("S" . outline-show-all)
1142 ("h" . outline-hide-subtree)
1143 ("s" . outline-show-subtree)))
1145 (use-package ls-lisp
1146 :custom (ls-lisp-dirs-first t))
1150 (setq dired-dwim-target t
1151 dired-listing-switches "-alh"
1152 ls-lisp-use-insert-directory-program nil)
1154 ;; easily diff 2 marked files
1155 ;; https://oremacs.com/2017/03/18/dired-ediff/
1156 (defun dired-ediff-files ()
1158 (require 'dired-aux)
1159 (defvar ediff-after-quit-hook-internal)
1160 (let ((files (dired-get-marked-files))
1161 (wnd (current-window-configuration)))
1162 (if (<= (length files) 2)
1163 (let ((file1 (car files))
1164 (file2 (if (cdr files)
1168 (dired-dwim-target-directory)))))
1169 (if (file-newer-than-file-p file1 file2)
1170 (ediff-files file2 file1)
1171 (ediff-files file1 file2))
1172 (add-hook 'ediff-after-quit-hook-internal
1174 (setq ediff-after-quit-hook-internal nil)
1175 (set-window-configuration wnd))))
1176 (error "no more than 2 files should be marked"))))
1179 (setq dired-guess-shell-alist-user
1180 '(("\\.pdf\\'" "evince" "zathura" "okular")
1181 ("\\.doc\\'" "libreoffice")
1182 ("\\.docx\\'" "libreoffice")
1183 ("\\.ppt\\'" "libreoffice")
1184 ("\\.pptx\\'" "libreoffice")
1185 ("\\.xls\\'" "libreoffice")
1186 ("\\.xlsx\\'" "libreoffice")
1187 ("\\.flac\\'" "mpv")))
1188 :bind (:map dired-mode-map
1189 ("b" . dired-up-directory)
1190 ("E" . dired-ediff-files)
1191 ("e" . dired-toggle-read-only)
1192 ("\\" . dired-hide-details-mode)
1195 (b/dired-start-process "zathura"))))
1196 :hook (dired-mode . dired-hide-details-mode))
1200 (temp-buffer-resize-mode)
1201 (setq help-window-select t))
1205 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1206 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1207 (add-to-list 'tramp-default-proxies-alist
1208 (list (regexp-quote (system-name)) nil nil)))
1211 :config (dash-enable-font-lock))
1213 (use-package doc-view
1214 :bind (:map doc-view-mode-map
1215 ("M-RET" . image-previous-line)))
1220 ;; highlight uncommitted changes in the left fringe
1221 (use-package diff-hl
1224 (setq diff-hl-draw-borders nil)
1225 (global-diff-hl-mode)
1226 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
1228 ;; display Lisp objects at point in the echo area
1230 :when (version< "25" emacs-version)
1231 :config (global-eldoc-mode))
1233 ;; highlight matching parens
1236 :config (show-paren-mode))
1238 (use-package elec-pair
1240 :config (electric-pair-mode))
1243 :config (column-number-mode)
1245 ;; Save what I copy into clipboard from other applications into Emacs'
1246 ;; kill-ring, which would allow me to still be able to easily access
1247 ;; it in case I kill (cut or copy) something else inside Emacs before
1248 ;; yanking (pasting) what I'd originally intended to.
1249 (save-interprogram-paste-before-kill t))
1251 ;; save minibuffer history
1252 (use-package savehist
1256 (add-to-list 'savehist-additional-variables 'kill-ring))
1258 ;; automatically save place in files
1259 (use-package saveplace
1260 :when (version< "25" emacs-version)
1261 :config (save-place-mode))
1263 (use-package prog-mode
1264 :config (global-prettify-symbols-mode)
1265 (defun indicate-buffer-boundaries-left ()
1266 (setq indicate-buffer-boundaries 'left))
1267 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1269 (use-package text-mode
1270 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
1271 :hook ((text-mode . indicate-buffer-boundaries-left)
1272 (text-mode . flyspell-mode)))
1274 (use-package conf-mode
1277 (use-package sh-mode
1280 (use-package company
1282 (:map company-active-map
1283 ([tab] . company-complete-common-or-cycle)
1284 ([escape] . company-abort)
1285 ("C-p" . company-select-previous-or-abort)
1286 ("C-n" . company-select-next-or-abort))
1288 (company-minimum-prefix-length 1)
1289 (company-selection-wrap-around t)
1290 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1291 (company-dabbrev-downcase nil)
1292 (company-dabbrev-ignore-case nil)
1294 ;; (global-company-mode t)
1297 (use-package flycheck
1299 :hook (prog-mode . flycheck-mode)
1301 (:map flycheck-mode-map
1302 ("M-P" . flycheck-previous-error)
1303 ("M-N" . flycheck-next-error))
1305 ;; Use the load-path from running Emacs when checking elisp files
1306 (setq flycheck-emacs-lisp-load-path 'inherit)
1308 ;; Only flycheck when I actually save the buffer
1309 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1310 :custom (flycheck-mode-line-prefix "flyc"))
1312 (use-package flyspell)
1314 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1318 ;; ’ can be part of a word
1319 (setq ispell-local-dictionary-alist
1320 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1321 "['\x2019]" nil ("-B") nil utf-8))
1322 ispell-program-name (executable-find "hunspell"))
1323 ;; don't send ’ to the subprocess
1324 (defun endless/replace-apostrophe (args)
1325 (cons (replace-regexp-in-string
1328 (advice-add #'ispell-send-string :filter-args
1329 #'endless/replace-apostrophe)
1331 ;; convert ' back to ’ from the subprocess
1332 (defun endless/replace-quote (args)
1333 (if (not (derived-mode-p 'org-mode))
1335 (cons (replace-regexp-in-string
1338 (advice-add #'ispell-parse-output :filter-args
1339 #'endless/replace-quote))
1342 :hook (text-mode . abbrev-mode))
1345 ;;; Programming modes
1347 (use-package lisp-mode
1349 (defun indent-spaces-mode ()
1350 (setq indent-tabs-mode nil))
1351 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1354 :hook (emacs-lisp-mode . reveal-mode))
1356 (use-package elisp-mode)
1358 ;; (use-package alloy-mode
1359 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1360 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1362 ;; (setq alloy-basic-offset 2)
1363 ;; ;; (defun b/alloy-simple-indent (start end)
1364 ;; ;; (interactive "r")
1365 ;; ;; ;; (if (region-active-p)
1366 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1368 ;; ;; ;; (indent-rigidly (line-beginning-position)
1369 ;; ;; ;; (line-end-position)
1370 ;; ;; ;; alloy-basic-offset)))
1371 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1372 ;; :bind (:map alloy-mode-map
1373 ;; ("RET" . electric-newline-and-maybe-indent)
1374 ;; ;; ("TAB" . b/alloy-simple-indent)
1375 ;; ("TAB" . indent-for-tab-command))
1376 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1378 (eval-when-compile (defvar lean-mode-map))
1379 (use-package lean-mode
1381 :bind (:map lean-mode-map
1382 ("S-SPC" . company-complete))
1384 (require 'lean-input)
1385 (setq default-input-method "Lean"
1386 lean-input-tweak-all '(lean-input-compose
1387 (lean-input-prepend "/")
1388 (lean-input-nonempty))
1389 lean-input-user-translations '(("/" "/")))
1393 (use-package proof-site ; for Coq
1394 :straight proof-general)
1396 (use-package haskell-mode
1398 (setq haskell-indentation-layout-offset 4
1399 haskell-indentation-left-offset 4
1400 flycheck-checker 'haskell-hlint
1401 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1405 :commands dante-mode
1406 :hook (haskell-mode . dante-mode))
1408 (use-package hlint-refactor
1410 :bind (:map hlint-refactor-mode-map
1411 ("C-c l b" . hlint-refactor-refactor-buffer)
1412 ("C-c l r" . hlint-refactor-refactor-at-point))
1413 :hook (haskell-mode . hlint-refactor-mode))
1415 (use-package flycheck-haskell
1416 :after haskell-mode)
1417 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1420 (use-package sgml-mode
1422 (setq sgml-basic-offset 2))
1424 (use-package css-mode
1426 (setq css-indent-offset 2))
1428 (use-package web-mode
1432 web-mode-code-indent-offset
1433 web-mode-css-indent-offset
1434 web-mode-markup-indent-offset)
1436 (web-mode-enable-auto-indentation nil))
1438 (use-package emmet-mode
1439 :after (:any web-mode css-mode sgml-mode)
1440 :bind* (("C-)" . emmet-next-edit-point)
1441 ("C-(" . emmet-prev-edit-point))
1443 (unbind-key "C-j" emmet-mode-keymap)
1444 (setq emmet-move-cursor-between-quotes t)
1445 :hook (web-mode css-mode html-mode sgml-mode))
1448 (use-package meghanada
1450 (:map meghanada-mode-map
1451 (("C-M-o" . meghanada-optimize-import)
1452 ("C-M-t" . meghanada-import-all)))
1453 :hook (java-mode . meghanada-mode)))
1456 (use-package treemacs
1457 :config (setq treemacs-never-persist t))
1459 (use-package yasnippet
1461 ;; (yas-global-mode)
1464 (use-package lsp-mode
1465 :init (setq lsp-eldoc-render-all nil
1466 lsp-highlight-symbol-at-point nil)
1471 (use-package company-lsp
1474 (setq company-lsp-cache-candidates t
1475 company-lsp-async t))
1479 (setq lsp-ui-sideline-update-mode 'point))
1481 (use-package lsp-java
1483 (add-hook 'java-mode-hook
1485 (setq-local company-backends (list 'company-lsp))))
1487 (add-hook 'java-mode-hook 'lsp-java-enable)
1488 (add-hook 'java-mode-hook 'flycheck-mode)
1489 (add-hook 'java-mode-hook 'company-mode)
1490 (add-hook 'java-mode-hook 'lsp-ui-mode))
1492 (use-package dap-mode
1498 (use-package dap-java
1501 (use-package lsp-java-treemacs
1506 :bind (:map eclim-mode-map ("S-SPC" . company-complete))
1507 :hook ((java-mode . eclim-mode)
1508 (eclim-mode . (lambda ()
1509 (make-local-variable 'company-idle-delay)
1510 (defvar company-idle-delay)
1511 ;; (setq company-idle-delay 0.7)
1512 (setq company-idle-delay nil))))
1514 (eclim-auto-save nil)
1515 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1516 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1517 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1519 (use-package geiser)
1521 (use-package geiser-guile
1523 (setq geiser-guile-load-path "~/src/git/guix"))
1530 (font-latex-fontify-sectioning 'color)))
1532 (use-package go-mode
1535 (use-package po-mode
1537 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1539 (use-package tex-mode
1542 (lambda (p) (string-match "^---?" (car p)))
1543 tex--prettify-symbols-alist)
1544 :hook ((tex-mode . auto-fill-mode)
1545 (tex-mode . flyspell-mode)))
1547 ;; (use-package george-mode
1548 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1549 ;; :mode "\\.grg\\'")
1554 (add-to-list 'custom-theme-load-path
1556 (convert-standard-filename "lisp") user-emacs-directory))
1557 (load-theme 'tangomod t)
1559 (use-package smart-mode-line
1560 :commands (sml/apply-theme)
1563 ;; thanks, but no thnaks; don't make fixed-width fills.
1564 (defun sml/fill-for-buffer-identification () "")
1565 (setq sml/theme 'tangomod)
1567 (smart-mode-line-enable))
1569 (use-package doom-modeline
1572 :hook (after-init . doom-modeline-init)
1574 (doom-modeline-buffer-file-name-style 'relative-to-project))
1576 (use-package doom-themes)
1578 (use-package solarized-theme
1581 (load-theme 'solarized-light t))
1587 (setq x-underline-at-descent-line t)
1588 (let ((line (face-attribute 'mode-line :underline)))
1589 (set-face-attribute 'mode-line nil :overline line)
1590 (set-face-attribute 'mode-line-inactive nil :overline line)
1591 (set-face-attribute 'mode-line-inactive nil :underline line)
1592 (set-face-attribute 'mode-line nil :box nil)
1593 (set-face-attribute 'mode-line-inactive nil :box nil)
1594 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1595 (moody-replace-mode-line-buffer-identification)
1596 (moody-replace-vc-mode))
1598 (use-package mini-modeline
1601 :config (mini-modeline-mode))
1603 (defvar b/org-mode-font-lock-keywords
1604 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1605 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1606 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1607 (4 '(:foreground "#c5c8c6") t))) ; title
1608 "For use with the `doom-tomorrow-night' theme.")
1610 (defun b/lights-on ()
1611 "Enable my favourite light theme."
1613 (mapc #'disable-theme custom-enabled-themes)
1614 (load-theme 'tangomod t)
1615 (when (featurep 'smart-mode-line)
1616 (sml/apply-theme 'tangomod))
1617 (font-lock-remove-keywords
1618 'org-mode b/org-mode-font-lock-keywords)
1619 (when (featurep 'erc-hl-nicks)
1620 (erc-hl-nicks-reset-face-table))
1621 (when (featurep 'exwm-systemtray)
1622 (exwm-systemtray--refresh)))
1624 (defun b/lights-off ()
1627 (mapc #'disable-theme custom-enabled-themes)
1628 (load-theme 'doom-one t)
1629 (when (featurep 'smart-mode-line)
1630 (sml/apply-theme 'automatic))
1631 (font-lock-add-keywords
1632 'org-mode b/org-mode-font-lock-keywords t)
1633 (when (featurep 'erc-hl-nicks)
1634 (erc-hl-nicks-reset-face-table))
1635 (when (featurep 'exwm-systemtray)
1636 (exwm-systemtray--refresh)))
1639 ("C-c t d" . b/lights-off)
1640 ("C-c t l" . b/lights-on))
1643 ;;; Emacs enhancements & auxiliary packages
1646 :config (setq Man-width 80))
1648 (use-package which-key
1651 (which-key-add-key-based-replacements
1652 ;; prefixes for global prefixes and minor modes
1655 "C-x RET" "coding system"
1657 "C-x @" "event modifiers"
1658 "C-x a" "abbrev/expand"
1659 "C-x r" "rectangle/register/bookmark"
1661 "C-x v" "version control"
1665 ;; prefixes for my personal bindings
1667 "C-c a" "applications"
1672 "C-c c" "compile-and-comments"
1678 "C-c m" "multiple-cursors"
1679 "C-c p" "projectile"
1680 "C-c p s" "projectile/search"
1681 "C-c p x" "projectile/execute"
1682 "C-c p 4" "projectile/other-window"
1688 ;; prefixes for major modes
1689 (which-key-add-major-mode-key-based-replacements 'message-mode
1690 "C-c f n" "footnote")
1691 (which-key-add-major-mode-key-based-replacements 'org-mode
1692 "C-c C-v" "org-babel")
1693 (which-key-add-major-mode-key-based-replacements 'web-mode
1694 "C-c C-a" "web/attributes"
1695 "C-c C-b" "web/blocks"
1697 "C-c C-e" "web/element"
1698 "C-c C-t" "web/tags")
1702 (which-key-add-column-padding 5)
1703 (which-key-max-description-length 32))
1705 (use-package crux ; results in Waiting for git... [2 times]
1707 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1708 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1709 ("C-c f C" . crux-copy-file-preserve-attributes)
1710 ("C-c f D" . crux-delete-file-and-buffer)
1711 ("C-c f R" . crux-rename-file-and-buffer)
1712 ("C-c j" . crux-top-join-line)
1713 ("C-S-j" . crux-top-join-line)))
1716 :bind (("C-a" . mwim-beginning-of-code-or-line)
1717 ("C-e" . mwim-end-of-code-or-line)
1718 ("<home>" . mwim-beginning-of-line-or-code)
1719 ("<end>" . mwim-end-of-line-or-code)))
1721 (use-package projectile
1723 :bind-keymap ("C-c p" . projectile-command-map)
1727 (defun b/projectile-mode-line-fun ()
1728 "Report project name and type in the modeline."
1729 (let ((project-name (projectile-project-name))
1730 (project-type (projectile-project-type)))
1732 projectile-mode-line-prefix
1734 (format ":%s" project-type)
1736 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1738 (defun my-projectile-invalidate-cache (&rest _args)
1739 ;; ignore the args to `magit-checkout'
1740 (projectile-invalidate-cache nil))
1742 (eval-after-load 'magit-branch
1744 (advice-add 'magit-checkout
1745 :after #'my-projectile-invalidate-cache)
1746 (advice-add 'magit-branch-and-checkout
1747 :after #'my-projectile-invalidate-cache)))
1749 (projectile-completion-system 'ivy)
1750 (projectile-mode-line-prefix " proj"))
1752 (use-package helpful
1755 (("C-S-h c" . helpful-command)
1756 ("C-S-h f" . helpful-callable) ; helpful-function
1757 ("C-S-h v" . helpful-variable)
1758 ("C-S-h k" . helpful-key)
1759 ("C-S-h p" . helpful-at-point)))
1761 (use-package unkillable-scratch
1764 (unkillable-scratch 1)
1766 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1769 ;; | make pretty boxed quotes like this
1771 (use-package boxquote
1774 (:prefix-map b/boxquote-prefix-map
1776 ("b" . boxquote-buffer)
1777 ("B" . boxquote-insert-buffer)
1778 ("d" . boxquote-defun)
1779 ("F" . boxquote-insert-file)
1780 ("hf" . boxquote-describe-function)
1781 ("hk" . boxquote-describe-key)
1782 ("hv" . boxquote-describe-variable)
1783 ("hw" . boxquote-where-is)
1784 ("k" . boxquote-kill)
1785 ("p" . boxquote-paragraph)
1786 ("q" . boxquote-boxquote)
1787 ("r" . boxquote-region)
1788 ("s" . boxquote-shell-command)
1789 ("t" . boxquote-text)
1790 ("T" . boxquote-title)
1791 ("u" . boxquote-unbox)
1792 ("U" . boxquote-unbox-region)
1793 ("y" . boxquote-yank)
1794 ("M-q" . boxquote-fill-paragraph)
1795 ("M-w" . boxquote-kill-ring-save)))
1797 (use-package orgalist
1798 ;; breaks auto-fill-mode, showing this error:
1799 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1802 :hook (message-mode . orgalist-mode))
1804 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1808 :hook (((text-mode erc-mode web-mode) . typo-mode)
1809 ((tex-mode git-commit-mode) . (lambda ()(typo-mode -1)))))
1811 (use-package electric
1815 (electric-quote-mode))
1817 ;; highlight TODOs in buffers
1818 (use-package hl-todo
1821 (global-hl-todo-mode))
1823 (use-package shrink-path
1827 (defvar user-@-host (concat (user-login-name) "@" (system-name) ":"))
1828 (defun +eshell/prompt ()
1829 (concat (propertize user-@-host 'face 'default)
1830 (propertize (abbreviate-file-name default-directory)
1831 'face 'font-lock-comment-face)
1832 (propertize "\n" 'face 'default)
1833 (if (= (user-uid) 0)
1834 (propertize "#" 'face 'red)
1835 (propertize "$" 'face 'default))
1836 (propertize " " 'face 'default)))
1837 (setq eshell-prompt-regexp "\\(.*\n\\)*[$#] "
1838 eshell-prompt-function #'+eshell/prompt))
1840 (use-package eshell-up
1842 :commands eshell-up)
1844 (use-package multi-term
1847 :bind (("C-c a s m m" . multi-term)
1848 ("C-c a s m d" . multi-term-dedicated-toggle)
1849 ("C-c a s m p" . multi-term-prev)
1850 ("C-c a s m n" . multi-term-next)
1852 ("C-c C-j" . term-char-mode))
1854 (setq multi-term-program "screen"
1855 multi-term-program-switches (concat "-c"
1856 (getenv "XDG_CONFIG_HOME")
1858 ;; TODO: add separate bindings for connecting to existing
1859 ;; session vs. always creating a new one
1860 multi-term-dedicated-select-after-open-p t
1861 multi-term-dedicated-window-height 20
1862 multi-term-dedicated-max-window-height 30
1864 '(("C-c C-c" . term-interrupt-subjob)
1865 ("C-c C-e" . term-send-esc)
1866 ("C-c C-j" . term-line-mode)
1868 ;; ("C-y" . term-paste)
1869 ("C-y" . term-send-raw)
1870 ("M-f" . term-send-forward-word)
1871 ("M-b" . term-send-backward-word)
1872 ("M-p" . term-send-up)
1873 ("M-n" . term-send-down)
1874 ("M-j" . term-send-raw-meta)
1875 ("M-y" . term-send-raw-meta)
1876 ("M-/" . term-send-raw-meta)
1877 ("M-0" . term-send-raw-meta)
1878 ("M-1" . term-send-raw-meta)
1879 ("M-2" . term-send-raw-meta)
1880 ("M-3" . term-send-raw-meta)
1881 ("M-4" . term-send-raw-meta)
1882 ("M-5" . term-send-raw-meta)
1883 ("M-6" . term-send-raw-meta)
1884 ("M-7" . term-send-raw-meta)
1885 ("M-8" . term-send-raw-meta)
1886 ("M-9" . term-send-raw-meta)
1887 ("<C-backspace>" . term-send-backward-kill-word)
1888 ("<M-DEL>" . term-send-backward-kill-word)
1889 ("M-d" . term-send-delete-word)
1890 ("M-," . term-send-raw)
1891 ("M-." . comint-dynamic-complete))
1892 term-unbind-key-alist
1893 '("C-z" "C-x" "C-c" "C-h"
1897 (use-package page-break-lines
1900 (page-break-lines-max-width fill-column)
1902 (global-page-break-lines-mode))
1904 (use-package expand-region
1905 :bind ("C-=" . er/expand-region))
1907 (use-package multiple-cursors
1909 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1910 (:prefix-map b/mc-prefix-map
1912 ("c" . mc/edit-lines)
1913 ("n" . mc/mark-next-like-this)
1914 ("p" . mc/mark-previous-like-this)
1915 ("a" . mc/mark-all-like-this))))
1922 (use-package yasnippet
1925 (defconst yas-verbosity-cur yas-verbosity)
1926 (setq yas-verbosity 2)
1927 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1929 (setq yas-verbosity yas-verbosity-cur)
1931 (defun b/yas--maybe-expand-key-filter (cmd)
1932 (when (and (yas--maybe-expand-key-filter cmd)
1933 (not (bound-and-true-p git-commit-mode)))
1935 (defconst b/yas-maybe-expand
1936 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1937 (define-key yas-minor-mode-map
1938 (kbd "SPC") b/yas-maybe-expand)
1942 (use-package debbugs
1944 (("C-c D d" . debbugs-gnu)
1945 ("C-c D b" . debbugs-gnu-bugs)
1949 (setq debbugs-gnu-current-suppress t)
1950 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1954 (setq debbugs-gnu-current-suppress t)
1955 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1959 (setq debbugs-gnu-current-suppress t)
1960 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))))
1962 (use-package org-ref
1964 (b/setq-every '("~/usr/org/references.bib")
1965 reftex-default-bibliography
1966 org-ref-default-bibliography)
1968 org-ref-bibliography-notes "~/usr/org/notes.org"
1969 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1973 :init (setq alert-default-style 'notifications))
1975 ;; (use-package fill-column-indicator)
1977 (use-package emojify
1979 :hook (erc-mode . emojify-mode))
1983 (("C-c w e" . (lambda ()
1985 (split-window-right)
1987 (erc-switch-to-buffer)))
1988 ("C-c w s l" . (lambda ()
1990 (split-window-right)
1992 ("C-c w s j" . (lambda ()
1994 (split-window-below)
1996 ("C-c w q" . quit-window))
1998 (split-width-threshold 150))
2000 (use-package windmove
2003 (("C-c w h" . windmove-left)
2004 ("C-c w j" . windmove-down)
2005 ("C-c w k" . windmove-up)
2006 ("C-c w l" . windmove-right)
2007 ("C-c w H" . windmove-swap-states-left)
2008 ("C-c w J" . windmove-swap-states-down)
2009 ("C-c w K" . windmove-swap-states-up)
2010 ("C-c w L" . windmove-swap-states-right)))
2014 :bind ("C-c a p" . pass)
2015 :hook (pass-mode . View-exit))
2017 (use-package pdf-tools
2019 :bind (:map pdf-view-mode-map
2020 ("<C-XF86Back>" . pdf-history-backward)
2021 ("<mouse-8>" . pdf-history-backward)
2022 ("<drag-mouse-8>" . pdf-history-backward)
2023 ("<C-XF86Forward>" . pdf-history-forward)
2024 ("<mouse-9>" . pdf-history-forward)
2025 ("<drag-mouse-9>" . pdf-history-forward)
2026 ("M-RET" . image-previous-line)
2027 ("C-s" . isearch-forward)
2028 ("s s" . isearch-forward))
2029 :config (pdf-tools-install nil t)
2030 :custom (pdf-view-resize-factor 1.05))
2032 (use-package org-pdftools
2034 :straight (:host github :repo "fuxialexander/org-pdftools")
2038 (with-eval-after-load 'org
2039 (require 'org-pdftools)))
2041 (use-package biblio)
2044 :hook (latex-mode . reftex-mode))
2046 (use-package reftex-cite
2048 :disabled ; enable to disable
2049 ; reftex-cite's default choice
2052 (defun reftex-get-bibkey-default ()
2053 "If the cursor is in a citation macro, return the word before the macro."
2054 (let* ((macro (reftex-what-macro 1)))
2056 (when (and macro (string-match "cite" (car macro)))
2057 (goto-char (cdr macro)))
2058 (reftex-this-word)))))
2060 (use-package minions
2062 :config (minions-mode))
2066 (dmenu-prompt-string "run: ")
2067 (dmenu-save-file (b/var "dmenu-items")))
2070 ;; TODO: fix build by properly building the eosd-pixbuf.c module
2071 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
2073 :straight (:host github :repo "clarete/eosd")
2079 (use-package nnreddit
2084 (nnreddit-python-command "python3"))
2086 (use-package hyperbole
2088 :straight (hyperbole
2089 :host github :repo "rswgnu/hyperbole"
2090 :files ("*.el" ("kotl" "kotl/*.el")
2091 "DEMO" "man/*.info" "man/*.texi")))
2093 ;; (use-package oddmuse-curl
2094 ;; :straight (:host github :repo "kensanata/oddmuse-curl")
2099 ;; '(("EmacsConf" "https://emacsconf.org" utf-8 "question" nil)
2100 ;; ("EmacsConf 2019" "https://emacsconf.org/2019" utf-8 "question" nil))
2103 ;; (oddmuse-username "bandali"))
2105 (use-package debpaste
2107 (debpaste-paste-is-hidden t))
2109 (use-package scpaste
2112 (setq scpaste-http-destination "https://p.bndl.org"
2113 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
2117 (eww-download-directory (file-name-as-directory
2118 (getenv "XDG_DOWNLOAD_DIR"))))
2121 ;;; Email (with Gnus)
2123 (defvar b/maildir (expand-file-name "~/mail/"))
2124 (with-eval-after-load 'recentf
2125 (add-to-list 'recentf-exclude b/maildir))
2128 b/gnus-init-file (b/etc "gnus")
2129 mail-user-agent 'gnus-user-agent
2130 read-mail-command 'gnus)
2133 :bind (("s-m" . gnus-plugged)
2134 ("s-M" . gnus-unplugged)
2135 ("C-c a m" . gnus-plugged)
2136 ("C-c a M" . gnus-unplugged))
2139 gnus-select-method '(nnnil "")
2140 gnus-secondary-select-methods
2141 '((nnimap "shemshak"
2142 (nnimap-stream plain)
2143 (nnimap-address "127.0.0.1")
2144 (nnimap-server-port 143)
2145 (nnimap-authenticator plain)
2146 (nnimap-user "amin@shemshak.local"))
2148 (nnimap-stream plain)
2149 (nnimap-address "127.0.0.1")
2150 (nnimap-server-port 143)
2151 (nnimap-authenticator plain)
2152 (nnimap-user "mab@gnu.local")
2153 (nnimap-inbox "INBOX")
2154 (nnimap-split-methods 'nnimap-split-fancy)
2155 (nnimap-split-fancy (|
2156 ;; (: gnus-registry-split-fancy-with-parent)
2157 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
2159 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
2161 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
2163 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
2164 ;; *.lists.sr.ht, omitting one dot if present
2165 ;; add more \\.?\\([^.]*\\) if needed
2166 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
2168 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
2170 (list ".*atreus.freelists.org" "l.atreus")
2171 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
2172 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
2173 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
2174 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
2175 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
2176 ;; ----------------------------------
2177 ;; legend: (u)nsubscribed | (d)ead
2178 ;; ----------------------------------
2179 ;; otherwise, leave mail in INBOX
2182 (nnimap-stream plain)
2183 (nnimap-address "127.0.0.1")
2184 (nnimap-server-port 143)
2185 (nnimap-authenticator plain)
2186 (nnimap-user "abandali@uw.local")
2187 (nnimap-inbox "INBOX")
2188 (nnimap-split-methods 'nnimap-split-fancy)
2189 (nnimap-split-fancy (|
2190 ;; (: gnus-registry-split-fancy-with-parent)
2192 ("subject" "SE\\s-?212" "course.se212-f19")
2193 (from "SE\\s-?212" "course.se212-f19")
2197 (nnimap-stream plain)
2198 (nnimap-address "127.0.0.1")
2199 (nnimap-server-port 143)
2200 (nnimap-authenticator plain)
2201 (nnimap-user "abandali@csc.uw.local")))
2202 gnus-message-archive-group "nnimap+gnu:INBOX"
2205 (to-address . "atreus@freelists.org")
2206 (to-list . "atreus@freelists.org"))
2208 (to-address . "deepspec@lists.cs.princeton.edu")
2209 (to-list . "deepspec@lists.cs.princeton.edu")
2210 (list-identifier . "\\[deepspec\\]"))
2212 (to-address . "emacs-devel@gnu.org")
2213 (to-list . "emacs-devel@gnu.org"))
2214 ("l\\.help-gnu-emacs"
2215 (to-address . "help-gnu-emacs@gnu.org")
2216 (to-list . "help-gnu-emacs@gnu.org"))
2217 ("l\\.info-gnu-emacs"
2218 (to-address . "info-gnu-emacs@gnu.org")
2219 (to-list . "info-gnu-emacs@gnu.org"))
2220 ("l\\.emacs-orgmode"
2221 (to-address . "emacs-orgmode@gnu.org")
2222 (to-list . "emacs-orgmode@gnu.org")
2223 (list-identifier . "\\[O\\]"))
2224 ("l\\.emacs-tangents"
2225 (to-address . "emacs-tangents@gnu.org")
2226 (to-list . "emacs-tangents@gnu.org"))
2227 ("l\\.emacsconf-committee"
2228 (to-address . "emacsconf-committee@gnu.org")
2229 (to-list . "emacsconf-committee@gnu.org"))
2230 ("l\\.emacsconf-discuss"
2231 (to-address . "emacsconf-discuss@gnu.org")
2232 (to-list . "emacsconf-discuss@gnu.org"))
2233 ("l\\.emacsconf-register"
2234 (to-address . "emacsconf-register@gnu.org")
2235 (to-list . "emacsconf-register@gnu.org"))
2236 ("l\\.emacsconf-submit"
2237 (to-address . "emacsconf-submit@gnu.org")
2238 (to-list . "emacsconf-submit@gnu.org"))
2239 ("l\\.fencepost-users"
2240 (to-address . "fencepost-users@gnu.org")
2241 (to-list . "fencepost-users@gnu.org")
2242 (list-identifier . "\\[Fencepost-users\\]"))
2243 ("l\\.gnewsense-art"
2244 (to-address . "gnewsense-art@nongnu.org")
2245 (to-list . "gnewsense-art@nongnu.org")
2246 (list-identifier . "\\[gNewSense-art\\]"))
2247 ("l\\.gnewsense-dev"
2248 (to-address . "gnewsense-dev@nongnu.org")
2249 (to-list . "gnewsense-dev@nongnu.org")
2250 (list-identifier . "\\[Gnewsense-dev\\]"))
2251 ("l\\.gnewsense-users"
2252 (to-address . "gnewsense-users@nongnu.org")
2253 (to-list . "gnewsense-users@nongnu.org")
2254 (list-identifier . "\\[gNewSense-users\\]"))
2255 ("l\\.gnunet-developers"
2256 (to-address . "gnunet-developers@gnu.org")
2257 (to-list . "gnunet-developers@gnu.org")
2258 (list-identifier . "\\[GNUnet-developers\\]"))
2260 (to-address . "help-gnunet@gnu.org")
2261 (to-list . "help-gnunet@gnu.org")
2262 (list-identifier . "\\[Help-gnunet\\]"))
2264 (to-address . "bug-gnuzilla@gnu.org")
2265 (to-list . "bug-gnuzilla@gnu.org")
2266 (list-identifier . "\\[Bug-gnuzilla\\]"))
2268 (to-address . "gnuzilla-dev@gnu.org")
2269 (to-list . "gnuzilla-dev@gnu.org")
2270 (list-identifier . "\\[Gnuzilla-dev\\]"))
2272 (to-address . "guile-devel@gnu.org")
2273 (to-list . "guile-devel@gnu.org"))
2275 (to-address . "guile-user@gnu.org")
2276 (to-list . "guile-user@gnu.org"))
2278 (to-address . "guix-devel@gnu.org")
2279 (to-list . "guix-devel@gnu.org"))
2281 (to-address . "help-guix@gnu.org")
2282 (to-list . "help-guix@gnu.org"))
2284 (to-address . "info-guix@gnu.org")
2285 (to-list . "info-guix@gnu.org"))
2286 ("l\\.savannah-hackers-public"
2287 (to-address . "savannah-hackers-public@gnu.org")
2288 (to-list . "savannah-hackers-public@gnu.org"))
2289 ("l\\.savannah-users"
2290 (to-address . "savannah-users@gnu.org")
2291 (to-list . "savannah-users@gnu.org"))
2293 (to-address . "www-commits@gnu.org")
2294 (to-list . "www-commits@gnu.org"))
2296 (to-address . "www-discuss@gnu.org")
2297 (to-list . "www-discuss@gnu.org"))
2299 (to-address . "haskell-art@we.lurk.org")
2300 (to-list . "haskell-art@we.lurk.org")
2301 (list-identifier . "\\[haskell-art\\]"))
2303 (to-address . "haskell-cafe@haskell.org")
2304 (to-list . "haskell-cafe@haskell.org")
2305 (list-identifier . "\\[Haskell-cafe\\]"))
2307 (to-address . "notmuch@notmuchmail.org")
2308 (to-list . "notmuch@notmuchmail.org"))
2310 (to-address . "dev@lists.parabola.nu")
2311 (to-list . "dev@lists.parabola.nu")
2312 (list-identifier . "\\[Dev\\]"))
2313 ("l\\.~bandali\\.public-inbox"
2314 (to-address . "~bandali/public-inbox@lists.sr.ht")
2315 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2316 ("l\\.~sircmpwn\\.free-writers-club"
2317 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2318 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2319 ("l\\.~sircmpwn\\.srht-admins"
2320 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2321 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2322 ("l\\.~sircmpwn\\.srht-announce"
2323 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2324 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2325 ("l\\.~sircmpwn\\.srht-dev"
2326 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2327 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2328 ("l\\.~sircmpwn\\.srht-discuss"
2329 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2330 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2332 (to-address . "webmasters@gnu.org")
2333 (to-list . "webmasters@gnu.org"))
2340 gnus-large-newsgroup 50
2341 gnus-home-directory (b/var "gnus/")
2342 gnus-directory (concat gnus-home-directory "news/")
2343 message-directory (concat gnus-home-directory "mail/")
2344 nndraft-directory (concat gnus-home-directory "drafts/")
2345 gnus-save-newsrc-file nil
2346 gnus-read-newsrc-file nil
2347 gnus-interactive-exit nil
2348 gnus-gcc-mark-as-read t)
2350 (when (version< emacs-version "27")
2351 (with-eval-after-load 'nnmail
2353 'nnmail-split-abbrev-alist
2354 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2357 ;; (gnus-registry-initialize)
2359 (with-eval-after-load 'recentf
2360 (add-to-list 'recentf-exclude gnus-home-directory)))
2362 (use-package gnus-art
2365 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2366 gnus-sorted-header-list '("^From:"
2382 "^Mail-Followup-To:"
2386 "^X-detected-operating-system:"
2391 gnus-visible-headers (mapconcat 'identity
2392 gnus-sorted-header-list
2394 ;; local-lapsed article dates
2395 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2396 gnus-article-date-headers '(user-defined)
2397 gnus-article-time-format
2399 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2400 (local (article-make-date-line date 'local))
2401 (combined-lapsed (article-make-date-line date
2404 (string-match " (.+" combined-lapsed)
2405 (match-string 0 combined-lapsed))))
2406 (concat local lapsed))))
2408 :map gnus-article-mode-map
2409 ("M-L" . org-store-link)))
2411 (use-package gnus-sum
2412 :bind (:map gnus-summary-mode-map
2413 :prefix-map b/gnus-summary-prefix-map
2415 ("r" . gnus-summary-reply)
2416 ("w" . gnus-summary-wide-reply)
2417 ("v" . gnus-summary-show-raw-article))
2420 :map gnus-summary-mode-map
2421 ("M-L" . org-store-link))
2422 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2424 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2425 gnus-thread-sort-by-subject
2426 gnus-thread-sort-by-date)))
2428 (use-package gnus-msg
2430 (defvar b/shemshak-signature "Amin Bandali
2431 https://shemshak.org/~amin")
2432 (defvar b/uw-signature "Amin Bandali, MMath Student
2433 Cheriton School of Computer Science
2434 University of Waterloo
2435 https://bandali.eu.org")
2436 (defvar b/csc-signature "Amin Bandali
2437 System Administrator, Systems Committee
2438 Computer Science Club, University of Waterloo
2439 https://csclub.uwaterloo.ca/~abandali")
2440 (setq gnus-message-replysign t
2443 (address "mab@gnu.org"))
2444 ("nnimap\\+gnu:l\\..*"
2447 (organization "GNU"))
2448 ((header "subject" "ThankCRM")
2449 (to "webmasters-comment@gnu.org")
2451 (eval (setq b/message-cite-say-hi nil)))
2452 ("nnimap\\+shemshak:.*"
2453 (address "amin@shemshak.org")
2455 (signature b/shemshak-signature)
2456 (gcc "nnimap+shemshak:Sent")
2457 (eval (setq b/message-cite-say-hi t)))
2459 (address "bandali@uwaterloo.ca")
2461 (signature b/uw-signature))
2462 ("nnimap\\+uw:INBOX"
2463 (gcc "\"nnimap+uw:Sent Items\""))
2465 (address "bandali@csclub.uwaterloo.ca")
2466 (signature b/csc-signature)
2467 (gcc "nnimap+csc:Sent"))))
2468 :hook (gnus-message-setup . (lambda ()
2469 (unless (mml-secure-is-encrypted-p)
2470 (mml-secure-message-sign)))))
2472 (use-package gnus-topic
2473 :hook (gnus-group-mode . gnus-topic-mode)
2474 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2476 (use-package gnus-agent
2478 (setq gnus-agent-synchronize-flags 'ask)
2479 :hook (gnus-group-mode . gnus-agent-mode))
2481 (use-package gnus-group
2483 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2486 ;; problematic with ebdb's popup, *EBDB-Gnus*
2487 (use-package gnus-win
2489 (setq gnus-use-full-window nil)))
2491 (use-package gnus-dired
2492 :commands gnus-dired-mode
2494 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2497 (use-package gnus-utils
2499 (gnus-completing-read-function 'gnus-ido-completing-read)))
2501 (use-package mm-decode
2503 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2504 mm-decrypt-option 'known
2505 mm-verify-option 'known))
2509 (when (version< "27" emacs-version)
2510 (set-face-attribute 'mm-uu-extract nil :extend t))
2512 (mm-uu-diff-groups-regexp
2513 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2515 (use-package sendmail
2517 (setq sendmail-program (executable-find "msmtp")
2518 ;; message-sendmail-extra-arguments '("-v" "-d")
2519 mail-specify-envelope-from t
2520 mail-envelope-from 'header))
2522 (use-package message
2523 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2525 ;; redefine for a simplified In-Reply-To header
2526 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2527 (defun message-make-in-reply-to ()
2528 "Return the In-Reply-To header for this message."
2529 (when message-reply-headers
2530 (let ((from (mail-header-from message-reply-headers))
2531 (msg-id (mail-header-id message-reply-headers)))
2535 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2536 (defconst message-cite-style-bandali
2537 '((message-cite-function 'message-cite-original)
2538 (message-citation-line-function 'message-insert-formatted-citation-line)
2539 (message-cite-reply-position 'traditional)
2540 (message-yank-prefix "> ")
2541 (message-yank-cited-prefix ">")
2542 (message-yank-empty-prefix ">")
2543 (message-citation-line-format
2544 (if b/message-cite-say-hi
2545 (concat "Hi %F,\n\n" b/message-cite-style-format)
2546 b/message-cite-style-format)))
2547 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2548 (setq ;; message-cite-style 'message-cite-style-bandali
2549 message-kill-buffer-on-exit t
2550 message-send-mail-function 'message-send-mail-with-sendmail
2551 message-sendmail-envelope-from 'header
2552 message-subscribed-address-functions
2553 '(gnus-find-subscribed-addresses)
2554 message-dont-reply-to-names
2555 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(mab\\|bandali\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2556 ;; (require 'company-ebdb)
2557 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2558 (message-mode . flyspell-mode)
2559 (message-mode . (lambda ()
2560 ;; (setq-local fill-column b/fill-column
2561 ;; message-fill-column b/fill-column)
2562 (make-local-variable 'company-idle-delay)
2563 (setq company-idle-delay 0.2))))
2565 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2566 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2567 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2569 (message-elide-ellipsis "[...]\n"))
2573 (use-package mml-sec
2575 (mml-secure-openpgp-encrypt-to-self t)
2576 (mml-secure-openpgp-sign-with-sender t))
2578 (use-package footnote
2581 ;; (setq footnote-start-tag ""
2582 ;; footnote-end-tag ""
2583 ;; footnote-style 'unicode)
2585 (:map message-mode-map
2586 :prefix-map b/footnote-prefix-map
2588 ("a" . footnote-add-footnote)
2589 ("b" . footnote-back-to-message)
2590 ("c" . footnote-cycle-style)
2591 ("d" . footnote-delete-footnote)
2592 ("g" . footnote-goto-footnote)
2593 ("r" . footnote-renumber-footnotes)
2594 ("s" . footnote-set-style)))
2600 :bind (:map gnus-group-mode-map ("e" . bbdb))
2602 (bbdb-initialize 'gnus 'message)
2604 (bbdb-complete-mail-allow-cycling t)
2605 (bbdb-user-mail-address-re message-dont-reply-to-names))
2610 :bind (:map gnus-group-mode-map ("e" . ebdb))
2612 (setq ebdb-sources (b/var "ebdb"))
2613 (with-eval-after-load 'swiper
2614 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2616 (use-package ebdb-com
2619 (use-package ebdb-complete
2622 ;; (setq ebdb-complete-mail 'capf)
2623 (ebdb-complete-enable))
2625 (use-package ebdb-message
2629 ;; (use-package company-ebdb
2631 ;; (defun company-ebdb--post-complete (_) nil))
2633 (use-package ebdb-gnus
2636 (ebdb-gnus-window-size 0.3))
2638 (use-package ebdb-mua
2641 :custom (ebdb-mua-pop-up t))
2643 ;; (use-package ebdb-message
2646 ;; (use-package ebdb-vcard
2649 (use-package message-x)
2652 (use-package message-x
2654 (message-x-completion-alist
2656 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2659 (quote message-newgroups-header-regexp))
2660 message-newgroups-header-regexp message-newsgroups-header-regexp)
2661 . message-expand-group))))))
2664 (use-package gnus-harvest
2665 :commands gnus-harvest-install
2668 (if (featurep 'message-x)
2669 (gnus-harvest-install 'message-x)
2670 (gnus-harvest-install))))
2672 (use-package gnus-article-treat-patch
2677 ;; note: be sure to customize faces with `:foreground "white"' when
2678 ;; using a theme with a white/light background :)
2679 (setq ft/gnus-article-patch-conditions
2680 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2683 ;;; IRC (with ERC and ZNC)
2686 :bind (("C-c b b" . erc-switch-to-buffer)
2688 ("M-a" . erc-track-switch-buffer))
2690 (erc-join-buffer 'bury)
2691 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2692 (erc-nick "bandali")
2694 (erc-rename-buffers t)
2695 (erc-server-reconnect-attempts 5)
2696 (erc-server-reconnect-timeout 3)
2698 (defun erc-cmd-OPME ()
2699 "Request chanserv to op me."
2700 (erc-message "PRIVMSG"
2701 (format "chanserv op %s %s"
2702 (erc-default-target)
2703 (erc-current-nick)) nil))
2704 (defun erc-cmd-DEOPME ()
2705 "Deop myself from current channel."
2706 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2707 (add-to-list 'erc-modules 'keep-place)
2708 (add-to-list 'erc-modules 'notifications)
2709 (add-to-list 'erc-modules 'smiley)
2710 (add-to-list 'erc-modules 'spelling)
2711 (add-to-list 'erc-modules 'scrolltoplace)
2712 (erc-update-modules))
2714 (use-package erc-fill
2717 (erc-fill-column 77)
2718 (erc-fill-function 'erc-fill-static)
2719 (erc-fill-static-center 18))
2721 (use-package erc-pcomplete
2724 (erc-pcomplete-nick-postfix ", "))
2726 (use-package erc-track
2728 :bind (("C-c a e t d" . erc-track-disable)
2729 ("C-c a e t e" . erc-track-enable))
2731 (erc-track-enable-keybindings nil)
2732 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2733 "324" "329" "332" "333" "353" "477"))
2734 (erc-track-position-in-mode-line t)
2735 (erc-track-priority-faces-only 'all)
2736 (erc-track-shorten-function nil))
2738 (use-package erc-hl-nicks
2741 (use-package erc-scrolltoplace
2745 :bind (("C-c a e e" . znc-erc)
2746 ("C-c a e a" . znc-all))
2748 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2750 ((null auth) (error "Couldn't find znca's authinfo"))
2751 (t (funcall (plist-get (car auth) :secret)))))))
2753 `(("znc.shemshak.org" 1337 t
2754 ((freenode "amin/freenode" ,pwd)))
2755 ("znc.shemshak.org" 1337 t
2756 ((moznet "amin/moznet" ,pwd)))
2757 ("znc.shemshak.org" 1337 t
2758 ((oftc "amin/oftc" ,pwd)))))))
2761 ;;; Post initialization
2763 (message "Loading %s...done (%.3fs)" user-init-file
2764 (float-time (time-subtract (current-time)
2765 b/before-user-init-time)))
2767 ;;; init.el ends here