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) "jirud")
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"))
167 ;; start up emacs server. see
168 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
171 :config
(or (server-running-p) (server-mode)))
180 (defmacro b
/setq-every
(value &rest vars
)
181 "Set all the variables from VARS to value VALUE."
182 (declare (indent defun
) (debug t
))
183 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
185 (defun b/start-process
(program &rest args
)
186 "Same as `start-process', but doesn't bother about name and buffer."
187 (let ((process-name (concat program
"_process"))
188 (buffer-name (generate-new-buffer-name
189 (concat program
"_output"))))
190 (apply #'start-process
191 process-name buffer-name program args
)))
193 (defun b/dired-start-process
(program &optional args
)
194 "Open current file with a PROGRAM."
195 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
196 ;; be nil, so remove it).
197 (apply #'b
/start-process
199 (remove nil
(list args
(dired-get-file-for-visit)))))
201 (defun b/add-elisp-section
()
205 (insert "\n\f\n;;; "))
207 ;; (defvar b/fill-column 47
208 ;; "My custom `fill-column'.")
210 (defconst b
/asterism
"* * *")
212 (defun b/insert-asterism
()
213 "Insert a centred asterism."
218 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
223 (defun b/no-mouse-autoselect-window
()
224 "Conveniently disable `focus-follows-mouse'.
225 For disabling the behaviour for certain buffers and/or modes."
226 (make-local-variable 'mouse-autoselect-window
)
227 (setq mouse-autoselect-window nil
))
229 (defun b/kill-current-buffer
()
230 "Kill the current buffer."
231 ;; also see https://redd.it/64xb3q
233 (kill-buffer (current-buffer)))
238 ;;;; C-level customizations
242 enable-recursive-minibuffers t
243 resize-mini-windows t
244 ;; more useful frame titles
245 frame-title-format
'("" invocation-name
" - "
247 (if (buffer-file-name)
248 (abbreviate-file-name (buffer-file-name))
250 ;; i don't feel like jumping out of my chair every now and again; so
251 ;; don't BEEP! at me, emacs
252 ring-bell-function
'ignore
255 ;; scroll-conservatively 10000
257 scroll-conservatively
10
258 scroll-preserve-screen-position
1
259 ;; focus follows mouse
260 mouse-autoselect-window t
)
263 ;; always use space for indentation
271 (dolist (ft (fontset-list))
275 (font-spec :name
"Source Code Pro" :size
14))
279 (font-spec :name
"DejaVu Sans Mono")
286 ;; :name "Symbola monospacified for DejaVu Sans Mono")
292 ;; (font-spec :name "DejaVu Sans Mono")
298 (font-spec :name
"DejaVu Sans Mono" :size
14)
302 ;;;; Elisp-level customizations
308 ;; don't need to see the startup echo area message
309 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
311 ;; i want *scratch* as my startup buffer
312 (initial-buffer-choice t
)
313 ;; i don't need the default hint
314 (initial-scratch-message nil
)
315 ;; use customizable text-mode as major mode for *scratch*
316 ;; (initial-major-mode 'text-mode)
317 ;; inhibit buffer list when more than 2 files are loaded
318 (inhibit-startup-buffer-menu t
)
319 ;; don't need to see the startup screen or echo area message
320 (inhibit-startup-screen t
)
321 (inhibit-startup-echo-area-message user-login-name
))
327 ;; backups (C-h v make-backup-files RET)
328 (backup-by-copying t
)
330 (delete-old-versions t
)
333 (auto-save-file-name-transforms
334 `((".*" ,(b/var
"auto-save/") t
)))
336 ;; insert newline at the end of files
337 (require-final-newline t
)
339 ;; open read-only file buffers in view-mode
340 ;; (enables niceties like `q' for quit)
343 ;; disable disabled commands
344 (setq disabled-command-function nil
)
346 ;; lazy-person-friendly yes/no prompts
347 (defalias 'yes-or-no-p
#'y-or-n-p
)
349 ;; enable automatic reloading of changed buffers and files
350 (use-package autorevert
353 (global-auto-revert-mode 1)
355 (auto-revert-verbose nil
)
356 (global-auto-revert-non-file-buffers nil
))
358 ;; time and battery in mode-line
365 (display-time-default-load-average nil
)
366 (display-time-format "%a %b %-e, %-l:%M%P")
367 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
368 (display-time-use-mail-icon t
))
374 (display-battery-mode)
376 (battery-mode-line-format " %p%% %t"))
382 ;; (fringe-mode '(3 . 1))
388 ;; enable winner-mode (C-h f winner-mode RET)
393 ;; don't display *compilation* buffer on success. based on
394 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
395 ;; instead of the now obsolete `flet'.
396 (defun b/compilation-finish-function
(buffer outstr
)
397 (unless (string-match "finished" outstr
)
398 (switch-to-buffer-other-window buffer
))
401 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
405 (defadvice compilation-start
406 (around inhibit-display
407 (command &optional mode name-function highlight-regexp
))
408 (if (not (string-match "^\\(find\\|grep\\)" command
))
409 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
410 (save-window-excursion ad-do-it
))
412 (ad-activate 'compilation-start
))
416 ;; allow scrolling in Isearch
417 (isearch-allow-scroll t
)
418 ;; search for non-ASCII characters: i’d like non-ASCII characters such
419 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
420 ;; counterpart. shoutout to
421 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
422 (search-default-mode #'char-fold-to-regexp
))
424 ;; uncomment to extend the above behaviour to query-replace
428 (replace-char-fold t
)))
431 :bind
("C-x v C-=" . vc-ediff
))
436 (vc-git-print-log-follow t
))
439 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
440 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
441 (ediff-split-window-function 'split-window-horizontally
)))
443 (use-package face-remap
445 ;; gentler font resizing
446 (text-scale-mode-step 1.05))
451 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
452 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
453 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
455 (use-package pixel-scroll
457 :config
(pixel-scroll-mode 1))
459 (use-package epg-config
461 ;; ask for GPG passphrase in minibuffer
462 ;; this will fail if gpg>=2.1 is not available
463 (if (version< "27" emacs-version
)
464 (setq epg-pinentry-mode
'loopback
)
465 (setq epa-pinentry-mode
'loopback
))
467 (epg-gpg-program (executable-find "gpg")))
472 (use-package pinentry
474 :after
(epa epg server
)
476 ;; workaround for systemd-based distros:
477 ;; (setq pinentry--socket-dir server-socket-dir)
480 (use-package auth-source
482 (auth-sources '("~/.authinfo.gpg"))
483 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
491 ("C-c e b" . eval-buffer
)
492 ("C-c e e" . eval-last-sexp
)
493 ("C-c e r" . eval-region
)
495 ("C-c e i" . emacs-init-time
)
496 ("C-c e u" . emacs-uptime
)
497 ("C-c e v" . emacs-version
)
499 ("C-c F m" . make-frame-command
)
500 ("C-c F d" . delete-frame
)
501 ("C-c F D" . server-edit
)
503 ("C-S-h C" . describe-char
)
504 ("C-S-h F" . describe-face
)
506 ("C-x k" . b
/kill-current-buffer
)
507 ("C-x K" . kill-buffer
)
508 ("C-x s" . save-buffer
)
509 ("C-x S" . save-some-buffers
)
511 :map emacs-lisp-mode-map
512 ("<C-return>" . b
/add-elisp-section
))
514 (when (display-graphic-p)
515 (unbind-key "C-z" global-map
))
518 ;; for back and forward mouse keys
519 ("<XF86Back>" . previous-buffer
)
520 ("<mouse-8>" . previous-buffer
)
521 ;; ("<drag-mouse-8>" . previous-buffer)
522 ("<XF86Forward>" . next-buffer
)
523 ("<mouse-9>" . next-buffer
)
524 ;; ("<drag-mouse-9>" . next-buffer)
525 ;; ("<drag-mouse-2>" . kill-this-buffer)
526 ;; ("<drag-mouse-3>" . switch-to-buffer)
530 ;;; Essential packages
536 ;; make class name the buffer name, truncating beyond 60 characters
537 (defun b/exwm-rename-buffer
()
539 (exwm-workspace-rename-buffer
540 (concat exwm-class-name
":"
541 (if (<= (length exwm-title
) 60) exwm-title
542 (concat (substring exwm-title
0 59) "...")))))
545 :hook
((exwm-update-class . b
/exwm-rename-buffer
)
546 (exwm-update-title . b
/exwm-rename-buffer
)))
548 (use-package exwm-config
551 :hook
(exwm-init . exwm-config--fix
/ido-buffer-window-other-frame
))
553 (use-package exwm-input
557 (defun b/exwm-ws-prev-index
()
558 "Return the index for the previous EXWM workspace, wrapping
560 (if (= exwm-workspace-current-index
0)
561 (1- exwm-workspace-number
)
562 (1- exwm-workspace-current-index
)))
564 (defun b/exwm-ws-next-index
()
565 "Return the index for the next EXWM workspace, wrapping
567 (if (= exwm-workspace-current-index
568 (1- exwm-workspace-number
))
570 (1+ exwm-workspace-current-index
)))
572 ;; shorten 'C-c C-q' to 'C-q'
573 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
575 (setq exwm-workspace-number
4
576 exwm-input-global-keys
577 `(([?\s-R
] . exwm-reset
)
578 ([?\s-
\\] . exwm-workspace-switch
)
580 ([?\S-\s-\s
] .
(lambda (command)
582 (list (read-shell-command "➜ ")))
583 (start-process-shell-command
584 command nil command
)))
585 ([s-return
] .
(lambda ()
587 (start-process "" nil
"urxvt")))
588 ([?\C-\s-\s
] . counsel-linux-app
)
589 ([?\M-\s-\s
] .
(lambda ()
591 (start-process-shell-command
592 "rofi-pass" nil
"rofi-pass")))
593 ([?\s-h
] . windmove-left
)
594 ([?\s-j
] . windmove-down
)
595 ([?\s-k
] . windmove-up
)
596 ([?\s-l
] . windmove-right
)
597 ([?\s-H
] . windmove-swap-states-left
)
598 ([?\s-J
] . windmove-swap-states-down
)
599 ([?\s-K
] . windmove-swap-states-up
)
600 ([?\s-L
] . windmove-swap-states-right
)
601 ([?\M-\s-h
] . shrink-window-horizontally
)
602 ([?\M-\s-l
] . enlarge-window-horizontally
)
603 ([?\M-\s-k
] . shrink-window
)
604 ([?\M-\s-j
] . enlarge-window
)
605 ([?\s-\
[] .
(lambda ()
607 (exwm-workspace-switch-create
608 (b/exwm-ws-prev-index
))))
609 ([?\s-\
]] .
(lambda ()
611 (exwm-workspace-switch-create
612 (b/exwm-ws-next-index
))))
613 ([?\s-
{] .
(lambda ()
615 (exwm-workspace-move-window
616 (b/exwm-ws-prev-index
))))
617 ([?\s-
}] .
(lambda ()
619 (exwm-workspace-move-window
620 (b/exwm-ws-next-index
))))
621 ,@(mapcar (lambda (i)
622 `(,(kbd (format "s-%d" i
)) .
625 (exwm-workspace-switch-create ,i
))))
626 (number-sequence 0 (1- exwm-workspace-number
)))
627 ([?\s-t
] . exwm-floating-toggle-floating
)
628 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
629 ([?\s-W
] .
(lambda ()
631 (kill-buffer (current-buffer))))
632 ([?\s-Q
] .
(lambda ()
634 (exwm-manage--kill-client)))
635 ([?\s-
\'] .
(lambda ()
637 (start-process-shell-command
638 "rofi-light" nil
"rofi-light")))
642 (start-process "" nil "pamixer" "--toggle-mute")))
643 ([XF86AudioLowerVolume] .
647 "" nil "pamixer" "--allow-boost" "--decrease" "5")))
648 ([XF86AudioRaiseVolume] .
652 "" nil "pamixer" "--allow-boost" "--increase" "5")))
656 (start-process "" nil "mpc" "toggle")))
660 (start-process "" nil "mpc" "prev")))
664 (start-process "" nil "mpc" "next")))
668 (start-process "" nil "dm-tool" "lock")))
669 ([\s-XF86Back] . previous-buffer)
670 ([\s-XF86Forward] . next-buffer)))
672 ;; Line-editing shortcuts
673 (setq exwm-input-simulation-keys
678 ([?\M-f] . [C-right])
686 ([?\C-k] . [S-end ?\C-x])
693 ([?\M-d] . [C-S-right ?\C-x])
694 ([?\M-\d] . [C-S-left ?\C-x])
701 ([?\C-g] . [escape]))))
703 (use-package exwm-manage
707 (exwm-manage-finish . (lambda ()
708 (when exwm-class-name
710 ((string= exwm-class-name "Abrowser")
711 (exwm-input-set-local-simulation-keys
712 `(,@exwm-input-simulation-keys
713 ([?\C-\S-d] . [?\C-d]))))
714 ((string= exwm-class-name "URxvt")
715 (exwm-input-set-local-simulation-keys
716 '(([?\C-c ?\C-c] . [?\C-c])
717 ([?\C-c ?\C-u] . [?\C-u]))))
718 ((string= exwm-class-name "Zathura")
719 (exwm-input-set-local-simulation-keys
721 ([?\C-n] . [C-down])))))))))
723 (use-package exwm-randr
729 (exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
731 (use-package exwm-systemtray
735 (exwm-systemtray-enable))
737 (use-package exwm-workspace)
739 (use-package exwm-edit
743 ;; use the org-plus-contrib package to get the whole deal
744 (use-package org-plus-contrib)
749 (setq org-src-tab-acts-natively t
750 org-src-preserve-indentation nil
751 org-edit-src-content-indentation 0
752 org-link-email-description-format "Email %c: %s" ; %.30s
753 org-highlight-latex-and-related '(entities)
754 org-use-speed-commands t
755 org-startup-folded 'content
756 org-catch-invisible-edits 'show-and-error
758 (when (version< org-version "9.3")
759 (setq org-email-link-description-format
760 org-link-email-description-format))
761 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
762 (add-to-list 'org-modules 'org-habit)
764 (("C-c a o a" . org-agenda)
766 ("M-L" . org-insert-last-stored-link)
767 ("M-O" . org-toggle-link-display))
768 :hook ((org-mode . org-indent-mode)
769 (org-mode . auto-fill-mode)
770 (org-mode . flyspell-mode))
772 (org-pretty-entities t)
773 (org-agenda-files '("~/usr/org/todos/personal.org"
774 "~/usr/org/todos/habits.org"
775 "~/src/git/masters-thesis/todo.org"))
776 (org-agenda-start-on-weekday 0)
777 (org-agenda-time-leading-zero t)
778 (org-habit-graph-column 44)
779 (org-latex-packages-alist '(("" "listings") ("" "color")))
781 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
782 '(org-block ((t (:background "#1d1f21"))))
783 '(org-latex-and-related ((t (:foreground "#b294bb")))))
785 (use-package ox-latex
788 (setq org-latex-listings 'listings
789 ;; org-latex-prefer-user-labels t
791 (add-to-list 'org-latex-classes
792 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
793 ("\\section{%s}" . "\\section*{%s}")
794 ("\\subsection{%s}" . "\\subsection*{%s}")
795 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
796 ("\\paragraph{%s}" . "\\paragraph*{%s}")
797 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
799 (require 'ox-beamer))
801 (use-package ox-extra
803 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
805 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
806 ;; org file. closely inspired by
807 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
808 (with-eval-after-load 'org
809 (defvar b/show-async-tangle-results nil
810 "Keep *emacs* async buffers around for later inspection.")
812 (defvar b/show-async-tangle-time nil
813 "Show the time spent tangling the file.")
815 (defun b/async-babel-tangle ()
816 "Tangle org file asynchronously."
818 (let* ((file-tangle-start-time (current-time))
819 (file (buffer-file-name))
820 (file-nodir (file-name-nondirectory file))
821 ;; (async-quiet-switch "-q")
822 (file-noext (file-name-sans-extension file)))
826 (org-babel-tangle-file ,file))
827 (unless b/show-async-tangle-results
830 (message "Tangled %s%s"
832 (if b/show-async-tangle-time
834 (float-time (time-subtract (current-time)
835 ',file-tangle-start-time)))
837 (message "Tangling %s failed" ,file-nodir))))))))
840 'safe-local-variable-values
841 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
843 ;; *the* right way to do git
846 :bind (("C-x g" . magit-status)
847 ("C-c g g" . magit-status)
848 ("C-c g b" . magit-blame-addition)
849 ("C-c g l" . magit-log-buffer-file))
851 (magit-add-section-hook 'magit-status-sections-hook
852 'magit-insert-modules
853 'magit-insert-stashes
855 ;; (magit-add-section-hook 'magit-status-sections-hook
856 ;; 'magit-insert-ignored-files
857 ;; 'magit-insert-untracked-files
859 (setq magit-repository-directories '(("~/" . 0)
861 (nconc magit-section-initial-visibility-alist
862 '(([unpulled status] . show)
863 ([unpushed status] . show)))
865 (magit-diff-refine-hunk t)
866 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
867 ;; (magit-completing-read-function 'magit-ido-completing-read)
868 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
870 ;; recently opened files
874 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
878 (recentf-max-saved-items 2000))
880 ;; smart M-x enhancement (needed by counsel for history)
881 ;; (use-package smex)
884 ("C-c f ." . find-file)
885 ("C-c f l" . find-library)
886 ("C-c f r" . recentf-open-files)
887 ("C-c x" . execute-extended-command))
893 (:map ido-common-completion-map
894 ([escape] . minibuffer-keyboard-quit)
895 ("DEL" . b/ido-backspace))
898 (defun b/ido-backspace ()
899 "Forward to `backward-delete-char'. On error (read-only), quit."
902 (backward-delete-char 1)
904 (minibuffer-keyboard-quit))))
908 (ido-enable-flex-matching t)
909 ;; (ido-enable-regexp t)
910 ;; (ido-enable-prefix t)
911 (ido-max-window-height 10)
912 (ido-use-virtual-buffers t))
914 (use-package ido-vertical-mode
917 (ido-vertical-mode 1)
919 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
920 (ido-vertical-show-count t))
922 (use-package ido-completing-read+
926 (ido-ubiquitous-mode 1))
928 (use-package crm-custom
933 (use-package icomplete
946 (:map ivy-minibuffer-map
947 ([escape] . keyboard-escape-quit)
948 ([S-up] . ivy-previous-history-element)
949 ([S-down] . ivy-next-history-element)
950 ("DEL" . ivy-backward-delete-char))
954 ivy-use-virtual-buffers t
955 ivy-virtual-abbreviate 'abbreviate
956 ivy-count-format "%d/%d ")
958 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
959 (defun b/ivy-ignore-buffer-p (str)
960 "Return non-nil if str names a buffer with a major mode
961 derived from one of `b/ivy-ignore-buffer-modes'.
963 This function is intended for use with `ivy-ignore-buffers'."
964 (let* ((buf (get-buffer str))
965 (mode (and buf (buffer-local-value 'major-mode buf))))
967 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
968 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
972 (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
973 (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
974 (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
975 (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
976 (ivy-current-match ((((class color) (background light))
977 :background "#d7d7d7" :foreground "black")
978 (((class color) (background dark))
979 :background "#65a7e2" :foreground "black"))))
984 :bind (("C-S-s" . swiper-isearch)))
989 :bind (("C-c f r" . counsel-recentf)
990 :map minibuffer-local-map
991 ("C-r" . counsel-minibuffer-history))
994 (defalias 'locate #'counsel-locate))
998 :commands (helm-M-x helm-mini helm-resume)
999 :bind (("M-x" . helm-M-x)
1000 ("M-y" . helm-show-kill-ring)
1001 ("C-x b" . helm-mini)
1002 ("C-x C-b" . helm-buffers-list)
1003 ("C-x C-f" . helm-find-files)
1004 ("C-h r" . helm-info-emacs)
1005 ("C-s-r" . helm-resume)
1007 ("<tab>" . helm-execute-persistent-action)
1008 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
1009 ("C-z" . helm-select-action)) ; List actions
1010 :config (helm-mode 1)))
1015 :bind ("C-c a s e" . eshell)
1017 (eval-when-compile (defvar eshell-prompt-regexp))
1018 (defun b/eshell-quit-or-delete-char (arg)
1020 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
1021 (eshell-life-is-too-much)
1024 (defun b/eshell-clear ()
1026 (let ((inhibit-read-only t))
1028 (eshell-send-input))
1030 (defun b/eshell-setup ()
1031 (make-local-variable 'company-idle-delay)
1032 (defvar company-idle-delay)
1033 (setq company-idle-delay nil)
1034 (bind-keys :map eshell-mode-map
1035 ("C-d" . b/eshell-quit-or-delete-char)
1036 ("C-S-l" . b/eshell-clear)
1037 ("M-r" . counsel-esh-history)
1038 ;; ([tab] . company-complete)
1039 :map eshell-hist-mode-map
1040 ("M-r" . counsel-esh-history)))
1042 :hook (eshell-mode . b/eshell-setup)
1044 (eshell-hist-ignoredups t)
1045 (eshell-input-filter 'eshell-input-filter-initial-space))
1047 (use-package ibuffer
1049 (("C-x C-b" . ibuffer)
1050 :map ibuffer-mode-map
1051 ("P" . ibuffer-backward-filter-group)
1052 ("N" . ibuffer-forward-filter-group)
1053 ("M-p" . ibuffer-do-print)
1054 ("M-n" . ibuffer-do-shell-command-pipe-replace))
1056 ;; Use human readable Size column instead of original one
1057 (define-ibuffer-column size-h
1058 (:name "Size" :inline t)
1060 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1061 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
1062 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
1063 (t (format "%8d" (buffer-size)))))
1065 (ibuffer-saved-filter-groups
1067 ("dired" (mode . dired-mode))
1068 ("org" (mode . org-mode))
1071 (mode . gnus-group-mode)
1072 (mode . gnus-summary-mode)
1073 (mode . gnus-article-mode)
1074 ;; not really, but...
1075 (mode . message-mode)))
1084 (mode . eshell-mode)
1086 (mode . term-mode)))
1089 (mode . python-mode)
1093 (mode . emacs-lisp-mode)
1094 (mode . scheme-mode)
1095 (mode . haskell-mode)
1098 (mode . alloy-mode)))
1101 (mode . bibtex-mode)
1102 (mode . latex-mode)))
1105 (name . "^\\*scratch\\*$")
1106 (name . "^\\*Messages\\*$")))
1107 ("exwm" (mode . exwm-mode))
1108 ("erc" (mode . erc-mode)))))
1110 '((mark modified read-only locked " "
1111 (name 72 72 :left :elide)
1113 (size-h 9 -1 :right)
1115 (mode 16 16 :left :elide)
1116 " " filename-and-process)
1120 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1122 (use-package outline
1124 :hook (prog-mode . outline-minor-mode)
1127 outline-minor-mode-map
1128 ("<s-tab>" . outline-toggle-children)
1129 ("M-p" . outline-previous-visible-heading)
1130 ("M-n" . outline-next-visible-heading)
1131 :prefix-map b/outline-prefix-map
1133 ("TAB" . outline-toggle-children)
1134 ("a" . outline-hide-body)
1135 ("H" . outline-hide-body)
1136 ("S" . outline-show-all)
1137 ("h" . outline-hide-subtree)
1138 ("s" . outline-show-subtree)))
1140 (use-package ls-lisp
1141 :custom (ls-lisp-dirs-first t))
1145 (setq dired-dwim-target t
1146 dired-listing-switches "-alh"
1147 ls-lisp-use-insert-directory-program nil)
1149 ;; easily diff 2 marked files
1150 ;; https://oremacs.com/2017/03/18/dired-ediff/
1151 (defun dired-ediff-files ()
1153 (require 'dired-aux)
1154 (defvar ediff-after-quit-hook-internal)
1155 (let ((files (dired-get-marked-files))
1156 (wnd (current-window-configuration)))
1157 (if (<= (length files) 2)
1158 (let ((file1 (car files))
1159 (file2 (if (cdr files)
1163 (dired-dwim-target-directory)))))
1164 (if (file-newer-than-file-p file1 file2)
1165 (ediff-files file2 file1)
1166 (ediff-files file1 file2))
1167 (add-hook 'ediff-after-quit-hook-internal
1169 (setq ediff-after-quit-hook-internal nil)
1170 (set-window-configuration wnd))))
1171 (error "no more than 2 files should be marked"))))
1174 (setq dired-guess-shell-alist-user
1175 '(("\\.pdf\\'" "evince" "zathura" "okular")
1176 ("\\.doc\\'" "libreoffice")
1177 ("\\.docx\\'" "libreoffice")
1178 ("\\.ppt\\'" "libreoffice")
1179 ("\\.pptx\\'" "libreoffice")
1180 ("\\.xls\\'" "libreoffice")
1181 ("\\.xlsx\\'" "libreoffice")
1182 ("\\.flac\\'" "mpv")))
1183 :bind (:map dired-mode-map
1184 ("b" . dired-up-directory)
1185 ("e" . dired-ediff-files)
1186 ("E" . dired-toggle-read-only)
1187 ("\\" . dired-hide-details-mode)
1190 (b/dired-start-process "zathura"))))
1191 :hook (dired-mode . dired-hide-details-mode))
1195 (temp-buffer-resize-mode)
1196 (setq help-window-select t))
1200 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1201 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1202 (add-to-list 'tramp-default-proxies-alist
1203 (list (regexp-quote (system-name)) nil nil)))
1206 :config (dash-enable-font-lock))
1208 (use-package doc-view
1209 :bind (:map doc-view-mode-map
1210 ("M-RET" . image-previous-line)))
1215 ;; highlight uncommitted changes in the left fringe
1216 (use-package diff-hl
1219 (setq diff-hl-draw-borders nil)
1220 (global-diff-hl-mode)
1221 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
1223 ;; display Lisp objects at point in the echo area
1225 :when (version< "25" emacs-version)
1226 :config (global-eldoc-mode))
1228 ;; highlight matching parens
1231 :config (show-paren-mode))
1233 (use-package elec-pair
1235 :config (electric-pair-mode))
1238 :config (column-number-mode)
1240 ;; Save what I copy into clipboard from other applications into Emacs'
1241 ;; kill-ring, which would allow me to still be able to easily access
1242 ;; it in case I kill (cut or copy) something else inside Emacs before
1243 ;; yanking (pasting) what I'd originally intended to.
1244 (save-interprogram-paste-before-kill t))
1246 ;; save minibuffer history
1247 (use-package savehist
1251 (add-to-list 'savehist-additional-variables 'kill-ring))
1253 ;; automatically save place in files
1254 (use-package saveplace
1255 :when (version< "25" emacs-version)
1256 :config (save-place-mode))
1258 (use-package prog-mode
1259 :config (global-prettify-symbols-mode)
1260 (defun indicate-buffer-boundaries-left ()
1261 (setq indicate-buffer-boundaries 'left))
1262 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1264 (use-package text-mode
1265 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
1266 :hook ((text-mode . indicate-buffer-boundaries-left)
1267 (text-mode . flyspell-mode)))
1269 (use-package conf-mode
1272 (use-package sh-mode
1275 (use-package company
1277 (:map company-active-map
1278 ([tab] . company-complete-common-or-cycle)
1279 ([escape] . company-abort)
1280 ("C-p" . company-select-previous-or-abort)
1281 ("C-n" . company-select-next-or-abort))
1283 (company-minimum-prefix-length 1)
1284 (company-selection-wrap-around t)
1285 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1286 (company-dabbrev-downcase nil)
1287 (company-dabbrev-ignore-case nil)
1289 ;; (global-company-mode t)
1292 (use-package flycheck
1294 :hook (prog-mode . flycheck-mode)
1296 (:map flycheck-mode-map
1297 ("M-P" . flycheck-previous-error)
1298 ("M-N" . flycheck-next-error))
1300 ;; Use the load-path from running Emacs when checking elisp files
1301 (setq flycheck-emacs-lisp-load-path 'inherit)
1303 ;; Only flycheck when I actually save the buffer
1304 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1305 :custom (flycheck-mode-line-prefix "flyc"))
1307 (use-package flyspell)
1309 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1313 ;; ’ can be part of a word
1314 (setq ispell-local-dictionary-alist
1315 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1316 "['\x2019]" nil ("-B") nil utf-8))
1317 ispell-program-name (executable-find "hunspell"))
1318 ;; don't send ’ to the subprocess
1319 (defun endless/replace-apostrophe (args)
1320 (cons (replace-regexp-in-string
1323 (advice-add #'ispell-send-string :filter-args
1324 #'endless/replace-apostrophe)
1326 ;; convert ' back to ’ from the subprocess
1327 (defun endless/replace-quote (args)
1328 (if (not (derived-mode-p 'org-mode))
1330 (cons (replace-regexp-in-string
1333 (advice-add #'ispell-parse-output :filter-args
1334 #'endless/replace-quote))
1337 :hook (text-mode . abbrev-mode))
1340 ;;; Programming modes
1342 (use-package lisp-mode
1344 (defun indent-spaces-mode ()
1345 (setq indent-tabs-mode nil))
1346 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1349 :hook (emacs-lisp-mode . reveal-mode))
1351 (use-package elisp-mode)
1353 ;; (use-package alloy-mode
1354 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1355 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1357 ;; (setq alloy-basic-offset 2)
1358 ;; ;; (defun b/alloy-simple-indent (start end)
1359 ;; ;; (interactive "r")
1360 ;; ;; ;; (if (region-active-p)
1361 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1363 ;; ;; ;; (indent-rigidly (line-beginning-position)
1364 ;; ;; ;; (line-end-position)
1365 ;; ;; ;; alloy-basic-offset)))
1366 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1367 ;; :bind (:map alloy-mode-map
1368 ;; ("RET" . electric-newline-and-maybe-indent)
1369 ;; ;; ("TAB" . b/alloy-simple-indent)
1370 ;; ("TAB" . indent-for-tab-command))
1371 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1373 (eval-when-compile (defvar lean-mode-map))
1374 (use-package lean-mode
1376 :bind (:map lean-mode-map
1377 ("S-SPC" . company-complete))
1379 (require 'lean-input)
1380 (setq default-input-method "Lean"
1381 lean-input-tweak-all '(lean-input-compose
1382 (lean-input-prepend "/")
1383 (lean-input-nonempty))
1384 lean-input-user-translations '(("/" "/")))
1388 (use-package proof-site ; for Coq
1389 :straight proof-general)
1391 (use-package haskell-mode
1393 (setq haskell-indentation-layout-offset 4
1394 haskell-indentation-left-offset 4
1395 flycheck-checker 'haskell-hlint
1396 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1400 :commands dante-mode
1401 :hook (haskell-mode . dante-mode))
1403 (use-package hlint-refactor
1405 :bind (:map hlint-refactor-mode-map
1406 ("C-c l b" . hlint-refactor-refactor-buffer)
1407 ("C-c l r" . hlint-refactor-refactor-at-point))
1408 :hook (haskell-mode . hlint-refactor-mode))
1410 (use-package flycheck-haskell
1411 :after haskell-mode)
1412 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1415 (use-package sgml-mode
1417 (setq sgml-basic-offset 2))
1419 (use-package css-mode
1421 (setq css-indent-offset 2))
1423 (use-package web-mode
1427 web-mode-code-indent-offset
1428 web-mode-css-indent-offset
1429 web-mode-markup-indent-offset)
1431 (web-mode-enable-auto-indentation nil))
1433 (use-package emmet-mode
1434 :after (:any web-mode css-mode sgml-mode)
1435 :bind* (("C-)" . emmet-next-edit-point)
1436 ("C-(" . emmet-prev-edit-point))
1438 (unbind-key "C-j" emmet-mode-keymap)
1439 (setq emmet-move-cursor-between-quotes t)
1440 :hook (web-mode css-mode html-mode sgml-mode))
1443 (use-package meghanada
1445 (:map meghanada-mode-map
1446 (("C-M-o" . meghanada-optimize-import)
1447 ("C-M-t" . meghanada-import-all)))
1448 :hook (java-mode . meghanada-mode)))
1451 (use-package treemacs
1452 :config (setq treemacs-never-persist t))
1454 (use-package yasnippet
1456 ;; (yas-global-mode)
1459 (use-package lsp-mode
1460 :init (setq lsp-eldoc-render-all nil
1461 lsp-highlight-symbol-at-point nil)
1466 (use-package company-lsp
1469 (setq company-lsp-cache-candidates t
1470 company-lsp-async t))
1474 (setq lsp-ui-sideline-update-mode 'point))
1476 (use-package lsp-java
1478 (add-hook 'java-mode-hook
1480 (setq-local company-backends (list 'company-lsp))))
1482 (add-hook 'java-mode-hook 'lsp-java-enable)
1483 (add-hook 'java-mode-hook 'flycheck-mode)
1484 (add-hook 'java-mode-hook 'company-mode)
1485 (add-hook 'java-mode-hook 'lsp-ui-mode))
1487 (use-package dap-mode
1493 (use-package dap-java
1496 (use-package lsp-java-treemacs
1501 :bind (:map eclim-mode-map ("S-SPC" . company-complete))
1502 :hook ((java-mode . eclim-mode)
1503 (eclim-mode . (lambda ()
1504 (make-local-variable 'company-idle-delay)
1505 (defvar company-idle-delay)
1506 ;; (setq company-idle-delay 0.7)
1507 (setq company-idle-delay nil))))
1509 (eclim-auto-save nil)
1510 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1511 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1512 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1514 (use-package geiser)
1516 (use-package geiser-guile
1518 (setq geiser-guile-load-path "~/src/git/guix"))
1525 (font-latex-fontify-sectioning 'color)))
1527 (use-package go-mode
1530 (use-package po-mode
1532 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1534 (use-package tex-mode
1537 (lambda (p) (string-match "^---?" (car p)))
1538 tex--prettify-symbols-alist)
1539 :hook ((tex-mode . auto-fill-mode)
1540 (tex-mode . flyspell-mode)))
1542 ;; (use-package george-mode
1543 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1544 ;; :mode "\\.grg\\'")
1549 (add-to-list 'custom-theme-load-path
1551 (convert-standard-filename "lisp") user-emacs-directory))
1552 (load-theme 'tangomod t)
1554 (use-package smart-mode-line
1555 :commands (sml/apply-theme)
1558 (setq sml/theme 'tangomod)
1560 (smart-mode-line-enable))
1562 (use-package doom-modeline
1565 :hook (after-init . doom-modeline-init)
1567 (doom-modeline-buffer-file-name-style 'relative-to-project))
1569 (use-package doom-themes)
1571 (use-package solarized-theme
1574 (load-theme 'solarized-light t))
1580 (setq x-underline-at-descent-line t)
1581 (let ((line (face-attribute 'mode-line :underline)))
1582 (set-face-attribute 'mode-line nil :overline line)
1583 (set-face-attribute 'mode-line-inactive nil :overline line)
1584 (set-face-attribute 'mode-line-inactive nil :underline line)
1585 (set-face-attribute 'mode-line nil :box nil)
1586 (set-face-attribute 'mode-line-inactive nil :box nil)
1587 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1588 (moody-replace-mode-line-buffer-identification)
1589 (moody-replace-vc-mode))
1591 (use-package mini-modeline
1594 :config (mini-modeline-mode))
1596 (defvar b/org-mode-font-lock-keywords
1597 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1598 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1599 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1600 (4 '(:foreground "#c5c8c6") t))) ; title
1601 "For use with the `doom-tomorrow-night' theme.")
1603 (defun b/lights-on ()
1604 "Enable my favourite light theme."
1606 (mapc #'disable-theme custom-enabled-themes)
1607 (load-theme 'tangomod t)
1608 (sml/apply-theme 'tangomod)
1609 (font-lock-remove-keywords
1610 'org-mode b/org-mode-font-lock-keywords)
1611 (when (featurep 'erc-hl-nicks)
1612 (erc-hl-nicks-reset-face-table))
1613 (when (featurep 'exwm-systemtray)
1614 (exwm-systemtray--refresh)))
1616 (defun b/lights-off ()
1619 (mapc #'disable-theme custom-enabled-themes)
1620 (load-theme 'doom-one t)
1621 (sml/apply-theme 'automatic)
1622 (font-lock-add-keywords
1623 'org-mode b/org-mode-font-lock-keywords t)
1624 (when (featurep 'erc-hl-nicks)
1625 (erc-hl-nicks-reset-face-table))
1626 (when (featurep 'exwm-systemtray)
1627 (exwm-systemtray--refresh)))
1630 ("C-c t d" . b/lights-off)
1631 ("C-c t l" . b/lights-on))
1634 ;;; Emacs enhancements & auxiliary packages
1637 :config (setq Man-width 80))
1639 (use-package which-key
1642 (which-key-add-key-based-replacements
1643 ;; prefixes for global prefixes and minor modes
1646 "C-x RET" "coding system"
1648 "C-x @" "event modifiers"
1649 "C-x a" "abbrev/expand"
1650 "C-x r" "rectangle/register/bookmark"
1652 "C-x v" "version control"
1656 ;; prefixes for my personal bindings
1658 "C-c a" "applications"
1663 "C-c c" "compile-and-comments"
1669 "C-c m" "multiple-cursors"
1670 "C-c p" "projectile"
1671 "C-c p s" "projectile/search"
1672 "C-c p x" "projectile/execute"
1673 "C-c p 4" "projectile/other-window"
1679 ;; prefixes for major modes
1680 (which-key-add-major-mode-key-based-replacements 'message-mode
1681 "C-c f n" "footnote")
1682 (which-key-add-major-mode-key-based-replacements 'org-mode
1683 "C-c C-v" "org-babel")
1684 (which-key-add-major-mode-key-based-replacements 'web-mode
1685 "C-c C-a" "web/attributes"
1686 "C-c C-b" "web/blocks"
1688 "C-c C-e" "web/element"
1689 "C-c C-t" "web/tags")
1693 (which-key-add-column-padding 5)
1694 (which-key-max-description-length 32))
1696 (use-package crux ; results in Waiting for git... [2 times]
1698 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1699 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1700 ("C-c f C" . crux-copy-file-preserve-attributes)
1701 ("C-c f D" . crux-delete-file-and-buffer)
1702 ("C-c f R" . crux-rename-file-and-buffer)
1703 ("C-c j" . crux-top-join-line)
1704 ("C-S-j" . crux-top-join-line)))
1707 :bind (("C-a" . mwim-beginning-of-code-or-line)
1708 ("C-e" . mwim-end-of-code-or-line)
1709 ("<home>" . mwim-beginning-of-line-or-code)
1710 ("<end>" . mwim-end-of-line-or-code)))
1712 (use-package projectile
1714 :bind-keymap ("C-c p" . projectile-command-map)
1718 (defun b/projectile-mode-line-fun ()
1719 "Report project name and type in the modeline."
1720 (let ((project-name (projectile-project-name))
1721 (project-type (projectile-project-type)))
1723 projectile-mode-line-prefix
1725 (format ":%s" project-type)
1727 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1729 (defun my-projectile-invalidate-cache (&rest _args)
1730 ;; ignore the args to `magit-checkout'
1731 (projectile-invalidate-cache nil))
1733 (eval-after-load 'magit-branch
1735 (advice-add 'magit-checkout
1736 :after #'my-projectile-invalidate-cache)
1737 (advice-add 'magit-branch-and-checkout
1738 :after #'my-projectile-invalidate-cache)))
1740 (projectile-completion-system 'ivy)
1741 (projectile-mode-line-prefix " proj"))
1743 (use-package helpful
1746 (("C-S-h c" . helpful-command)
1747 ("C-S-h f" . helpful-callable) ; helpful-function
1748 ("C-S-h v" . helpful-variable)
1749 ("C-S-h k" . helpful-key)
1750 ("C-S-h p" . helpful-at-point)))
1752 (use-package unkillable-scratch
1755 (unkillable-scratch 1)
1757 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1760 ;; | make pretty boxed quotes like this
1762 (use-package boxquote
1765 (:prefix-map b/boxquote-prefix-map
1767 ("b" . boxquote-buffer)
1768 ("B" . boxquote-insert-buffer)
1769 ("d" . boxquote-defun)
1770 ("F" . boxquote-insert-file)
1771 ("hf" . boxquote-describe-function)
1772 ("hk" . boxquote-describe-key)
1773 ("hv" . boxquote-describe-variable)
1774 ("hw" . boxquote-where-is)
1775 ("k" . boxquote-kill)
1776 ("p" . boxquote-paragraph)
1777 ("q" . boxquote-boxquote)
1778 ("r" . boxquote-region)
1779 ("s" . boxquote-shell-command)
1780 ("t" . boxquote-text)
1781 ("T" . boxquote-title)
1782 ("u" . boxquote-unbox)
1783 ("U" . boxquote-unbox-region)
1784 ("y" . boxquote-yank)
1785 ("M-q" . boxquote-fill-paragraph)
1786 ("M-w" . boxquote-kill-ring-save)))
1788 (use-package orgalist
1789 ;; breaks auto-fill-mode, showing this error:
1790 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1793 :hook (message-mode . orgalist-mode))
1795 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1799 :hook (((text-mode erc-mode web-mode) . typo-mode)
1800 ((tex-mode git-commit-mode) . (lambda ()(typo-mode -1)))))
1802 (use-package electric
1806 (electric-quote-mode))
1808 ;; highlight TODOs in buffers
1809 (use-package hl-todo
1812 (global-hl-todo-mode))
1814 (use-package shrink-path
1818 (defvar user-@-host (concat (user-login-name) "@" (system-name) ":"))
1819 (defun +eshell/prompt ()
1820 (concat (propertize user-@-host 'face 'default)
1821 (propertize (abbreviate-file-name default-directory)
1822 'face 'font-lock-comment-face)
1823 (propertize "\n" 'face 'default)
1824 (if (= (user-uid) 0)
1825 (propertize "#" 'face 'red)
1826 (propertize "$" 'face 'default))
1827 (propertize " " 'face 'default)))
1828 (setq eshell-prompt-regexp "\\(.*\n\\)*[$#] "
1829 eshell-prompt-function #'+eshell/prompt))
1831 (use-package eshell-up
1833 :commands eshell-up)
1835 (use-package multi-term
1838 :bind (("C-c a s m m" . multi-term)
1839 ("C-c a s m d" . multi-term-dedicated-toggle)
1840 ("C-c a s m p" . multi-term-prev)
1841 ("C-c a s m n" . multi-term-next)
1843 ("C-c C-j" . term-char-mode))
1845 (setq multi-term-program "screen"
1846 multi-term-program-switches (concat "-c"
1847 (getenv "XDG_CONFIG_HOME")
1849 ;; TODO: add separate bindings for connecting to existing
1850 ;; session vs. always creating a new one
1851 multi-term-dedicated-select-after-open-p t
1852 multi-term-dedicated-window-height 20
1853 multi-term-dedicated-max-window-height 30
1855 '(("C-c C-c" . term-interrupt-subjob)
1856 ("C-c C-e" . term-send-esc)
1857 ("C-c C-j" . term-line-mode)
1859 ;; ("C-y" . term-paste)
1860 ("C-y" . term-send-raw)
1861 ("M-f" . term-send-forward-word)
1862 ("M-b" . term-send-backward-word)
1863 ("M-p" . term-send-up)
1864 ("M-n" . term-send-down)
1865 ("M-j" . term-send-raw-meta)
1866 ("M-y" . term-send-raw-meta)
1867 ("M-/" . term-send-raw-meta)
1868 ("M-0" . term-send-raw-meta)
1869 ("M-1" . term-send-raw-meta)
1870 ("M-2" . term-send-raw-meta)
1871 ("M-3" . term-send-raw-meta)
1872 ("M-4" . term-send-raw-meta)
1873 ("M-5" . term-send-raw-meta)
1874 ("M-6" . term-send-raw-meta)
1875 ("M-7" . term-send-raw-meta)
1876 ("M-8" . term-send-raw-meta)
1877 ("M-9" . term-send-raw-meta)
1878 ("<C-backspace>" . term-send-backward-kill-word)
1879 ("<M-DEL>" . term-send-backward-kill-word)
1880 ("M-d" . term-send-delete-word)
1881 ("M-," . term-send-raw)
1882 ("M-." . comint-dynamic-complete))
1883 term-unbind-key-alist
1884 '("C-z" "C-x" "C-c" "C-h"
1888 (use-package page-break-lines
1891 (page-break-lines-max-width fill-column)
1893 (global-page-break-lines-mode))
1895 (use-package expand-region
1896 :bind ("C-=" . er/expand-region))
1898 (use-package multiple-cursors
1900 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1901 (:prefix-map b/mc-prefix-map
1903 ("c" . mc/edit-lines)
1904 ("n" . mc/mark-next-like-this)
1905 ("p" . mc/mark-previous-like-this)
1906 ("a" . mc/mark-all-like-this))))
1913 (use-package yasnippet
1916 (defconst yas-verbosity-cur yas-verbosity)
1917 (setq yas-verbosity 2)
1918 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1920 (setq yas-verbosity yas-verbosity-cur)
1922 (defun b/yas--maybe-expand-key-filter (cmd)
1923 (when (and (yas--maybe-expand-key-filter cmd)
1924 (not (bound-and-true-p git-commit-mode)))
1926 (defconst b/yas-maybe-expand
1927 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1928 (define-key yas-minor-mode-map
1929 (kbd "SPC") b/yas-maybe-expand)
1933 (use-package debbugs
1935 (("C-c D d" . debbugs-gnu)
1936 ("C-c D b" . debbugs-gnu-bugs)
1940 (setq debbugs-gnu-current-suppress t)
1941 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1945 (setq debbugs-gnu-current-suppress t)
1946 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1950 (setq debbugs-gnu-current-suppress t)
1951 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))))
1953 (use-package org-ref
1955 (b/setq-every '("~/usr/org/references.bib")
1956 reftex-default-bibliography
1957 org-ref-default-bibliography)
1959 org-ref-bibliography-notes "~/usr/org/notes.org"
1960 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1964 :init (setq alert-default-style 'notifications))
1966 ;; (use-package fill-column-indicator)
1968 (use-package emojify
1970 :hook (erc-mode . emojify-mode))
1974 (("C-c w e" . (lambda ()
1976 (split-window-right)
1978 (erc-switch-to-buffer)))
1979 ("C-c w s l" . (lambda ()
1981 (split-window-right)
1983 ("C-c w s j" . (lambda ()
1985 (split-window-below)
1987 ("C-c w q" . quit-window))
1989 (split-width-threshold 150))
1991 (use-package windmove
1994 (("C-c w h" . windmove-left)
1995 ("C-c w j" . windmove-down)
1996 ("C-c w k" . windmove-up)
1997 ("C-c w l" . windmove-right)
1998 ("C-c w H" . windmove-swap-states-left)
1999 ("C-c w J" . windmove-swap-states-down)
2000 ("C-c w K" . windmove-swap-states-up)
2001 ("C-c w L" . windmove-swap-states-right)))
2005 :bind ("C-c a p" . pass)
2006 :hook (pass-mode . View-exit))
2008 (use-package pdf-tools
2010 :bind (:map pdf-view-mode-map
2011 ("<C-XF86Back>" . pdf-history-backward)
2012 ("<mouse-8>" . pdf-history-backward)
2013 ("<drag-mouse-8>" . pdf-history-backward)
2014 ("<C-XF86Forward>" . pdf-history-forward)
2015 ("<mouse-9>" . pdf-history-forward)
2016 ("<drag-mouse-9>" . pdf-history-forward)
2017 ("M-RET" . image-previous-line)
2018 ("C-s" . isearch-forward)
2019 ("s s" . isearch-forward))
2020 :config (pdf-tools-install nil t)
2021 :custom (pdf-view-resize-factor 1.05))
2023 (use-package org-pdftools
2025 :straight (:host github :repo "fuxialexander/org-pdftools")
2029 (with-eval-after-load 'org
2030 (require 'org-pdftools)))
2032 (use-package biblio)
2035 :hook (latex-mode . reftex-mode))
2037 (use-package reftex-cite
2039 :disabled ; enable to disable
2040 ; reftex-cite's default choice
2043 (defun reftex-get-bibkey-default ()
2044 "If the cursor is in a citation macro, return the word before the macro."
2045 (let* ((macro (reftex-what-macro 1)))
2047 (when (and macro (string-match "cite" (car macro)))
2048 (goto-char (cdr macro)))
2049 (reftex-this-word)))))
2051 (use-package minions
2053 :config (minions-mode))
2057 (dmenu-prompt-string "run: ")
2058 (dmenu-save-file (b/var "dmenu-items")))
2061 ;; TODO: fix build by properly building the eosd-pixbuf.c module
2062 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
2064 :straight (:host github :repo "clarete/eosd")
2070 (use-package nnreddit
2075 (nnreddit-python-command "python3"))
2077 (use-package hyperbole
2079 :straight (hyperbole
2080 :host github :repo "rswgnu/hyperbole"
2081 :files ("*.el" ("kotl" "kotl/*.el")
2082 "DEMO" "man/*.info" "man/*.texi")))
2084 ;; (use-package oddmuse-curl
2085 ;; :straight (:host github :repo "kensanata/oddmuse-curl")
2090 ;; '(("EmacsConf" "https://emacsconf.org" utf-8 "question" nil)
2091 ;; ("EmacsConf 2019" "https://emacsconf.org/2019" utf-8 "question" nil))
2094 ;; (oddmuse-username "bandali"))
2096 (use-package debpaste
2098 (debpaste-paste-is-hidden t))
2100 (use-package scpaste
2103 (setq scpaste-http-destination "https://p.bndl.org"
2104 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
2107 ;;; Email (with Gnus)
2109 (defvar b/maildir (expand-file-name "~/mail/"))
2110 (with-eval-after-load 'recentf
2111 (add-to-list 'recentf-exclude b/maildir))
2114 b/gnus-init-file (b/etc "gnus")
2115 mail-user-agent 'gnus-user-agent
2116 read-mail-command 'gnus)
2119 :bind (("s-m" . gnus)
2120 ("s-M" . gnus-unplugged)
2122 ("C-c a M" . gnus-unplugged))
2125 gnus-select-method '(nnnil "")
2126 gnus-secondary-select-methods
2127 '((nnimap "shemshak"
2128 (nnimap-stream plain)
2129 (nnimap-address "127.0.0.1")
2130 (nnimap-server-port 143)
2131 (nnimap-authenticator plain)
2132 (nnimap-user "amin@shemshak.local"))
2134 (nnimap-stream plain)
2135 (nnimap-address "127.0.0.1")
2136 (nnimap-server-port 143)
2137 (nnimap-authenticator plain)
2138 (nnimap-user "mab@gnu.local")
2139 (nnimap-inbox "INBOX")
2140 (nnimap-split-methods 'nnimap-split-fancy)
2141 (nnimap-split-fancy (|
2142 ;; (: gnus-registry-split-fancy-with-parent)
2143 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
2145 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
2147 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
2149 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
2150 ;; *.lists.sr.ht, omitting one dot if present
2151 ;; add more \\.?\\([^.]*\\) if needed
2152 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
2154 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
2156 (list ".*atreus.freelists.org" "l.atreus")
2157 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
2158 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
2159 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
2160 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
2161 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
2162 ;; ----------------------------------
2163 ;; legend: (u)nsubscribed | (d)ead
2164 ;; ----------------------------------
2165 ;; otherwise, leave mail in INBOX
2168 (nnimap-stream plain)
2169 (nnimap-address "127.0.0.1")
2170 (nnimap-server-port 143)
2171 (nnimap-authenticator plain)
2172 (nnimap-user "abandali@uw.local")
2173 (nnimap-inbox "INBOX")
2174 (nnimap-split-methods 'nnimap-split-fancy)
2175 (nnimap-split-fancy (|
2176 ;; (: gnus-registry-split-fancy-with-parent)
2178 ("subject" "SE\\s-?212" "course.se212-f19")
2179 (from "SE\\s-?212" "course.se212-f19")
2183 (nnimap-stream plain)
2184 (nnimap-address "127.0.0.1")
2185 (nnimap-server-port 143)
2186 (nnimap-authenticator plain)
2187 (nnimap-user "abandali@csc.uw.local")))
2188 gnus-message-archive-group "nnimap+gnu:INBOX"
2191 (to-address . "atreus@freelists.org")
2192 (to-list . "atreus@freelists.org"))
2194 (to-address . "deepspec@lists.cs.princeton.edu")
2195 (to-list . "deepspec@lists.cs.princeton.edu")
2196 (list-identifier . "\\[deepspec\\]"))
2198 (to-address . "emacs-devel@gnu.org")
2199 (to-list . "emacs-devel@gnu.org"))
2200 ("l\\.help-gnu-emacs"
2201 (to-address . "help-gnu-emacs@gnu.org")
2202 (to-list . "help-gnu-emacs@gnu.org"))
2203 ("l\\.info-gnu-emacs"
2204 (to-address . "info-gnu-emacs@gnu.org")
2205 (to-list . "info-gnu-emacs@gnu.org"))
2206 ("l\\.emacs-orgmode"
2207 (to-address . "emacs-orgmode@gnu.org")
2208 (to-list . "emacs-orgmode@gnu.org")
2209 (list-identifier . "\\[O\\]"))
2210 ("l\\.emacs-tangents"
2211 (to-address . "emacs-tangents@gnu.org")
2212 (to-list . "emacs-tangents@gnu.org"))
2213 ("l\\.emacsconf-committee"
2214 (to-address . "emacsconf-committee@gnu.org")
2215 (to-list . "emacsconf-committee@gnu.org"))
2216 ("l\\.emacsconf-discuss"
2217 (to-address . "emacsconf-discuss@gnu.org")
2218 (to-list . "emacsconf-discuss@gnu.org"))
2219 ("l\\.emacsconf-register"
2220 (to-address . "emacsconf-register@gnu.org")
2221 (to-list . "emacsconf-register@gnu.org"))
2222 ("l\\.emacsconf-submit"
2223 (to-address . "emacsconf-submit@gnu.org")
2224 (to-list . "emacsconf-submit@gnu.org"))
2225 ("l\\.fencepost-users"
2226 (to-address . "fencepost-users@gnu.org")
2227 (to-list . "fencepost-users@gnu.org")
2228 (list-identifier . "\\[Fencepost-users\\]"))
2229 ("l\\.gnewsense-art"
2230 (to-address . "gnewsense-art@nongnu.org")
2231 (to-list . "gnewsense-art@nongnu.org")
2232 (list-identifier . "\\[gNewSense-art\\]"))
2233 ("l\\.gnewsense-dev"
2234 (to-address . "gnewsense-dev@nongnu.org")
2235 (to-list . "gnewsense-dev@nongnu.org")
2236 (list-identifier . "\\[Gnewsense-dev\\]"))
2237 ("l\\.gnewsense-users"
2238 (to-address . "gnewsense-users@nongnu.org")
2239 (to-list . "gnewsense-users@nongnu.org")
2240 (list-identifier . "\\[gNewSense-users\\]"))
2241 ("l\\.gnunet-developers"
2242 (to-address . "gnunet-developers@gnu.org")
2243 (to-list . "gnunet-developers@gnu.org")
2244 (list-identifier . "\\[GNUnet-developers\\]"))
2246 (to-address . "help-gnunet@gnu.org")
2247 (to-list . "help-gnunet@gnu.org")
2248 (list-identifier . "\\[Help-gnunet\\]"))
2250 (to-address . "bug-gnuzilla@gnu.org")
2251 (to-list . "bug-gnuzilla@gnu.org")
2252 (list-identifier . "\\[Bug-gnuzilla\\]"))
2254 (to-address . "gnuzilla-dev@gnu.org")
2255 (to-list . "gnuzilla-dev@gnu.org")
2256 (list-identifier . "\\[Gnuzilla-dev\\]"))
2258 (to-address . "guile-devel@gnu.org")
2259 (to-list . "guile-devel@gnu.org"))
2261 (to-address . "guile-user@gnu.org")
2262 (to-list . "guile-user@gnu.org"))
2264 (to-address . "guix-devel@gnu.org")
2265 (to-list . "guix-devel@gnu.org"))
2267 (to-address . "help-guix@gnu.org")
2268 (to-list . "help-guix@gnu.org"))
2270 (to-address . "info-guix@gnu.org")
2271 (to-list . "info-guix@gnu.org"))
2272 ("l\\.savannah-hackers-public"
2273 (to-address . "savannah-hackers-public@gnu.org")
2274 (to-list . "savannah-hackers-public@gnu.org"))
2275 ("l\\.savannah-users"
2276 (to-address . "savannah-users@gnu.org")
2277 (to-list . "savannah-users@gnu.org"))
2279 (to-address . "www-commits@gnu.org")
2280 (to-list . "www-commits@gnu.org"))
2282 (to-address . "www-discuss@gnu.org")
2283 (to-list . "www-discuss@gnu.org"))
2285 (to-address . "haskell-art@we.lurk.org")
2286 (to-list . "haskell-art@we.lurk.org")
2287 (list-identifier . "\\[haskell-art\\]"))
2289 (to-address . "haskell-cafe@haskell.org")
2290 (to-list . "haskell-cafe@haskell.org")
2291 (list-identifier . "\\[Haskell-cafe\\]"))
2293 (to-address . "notmuch@notmuchmail.org")
2294 (to-list . "notmuch@notmuchmail.org"))
2296 (to-address . "dev@lists.parabola.nu")
2297 (to-list . "dev@lists.parabola.nu")
2298 (list-identifier . "\\[Dev\\]"))
2299 ("l\\.~bandali\\.public-inbox"
2300 (to-address . "~bandali/public-inbox@lists.sr.ht")
2301 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2302 ("l\\.~sircmpwn\\.free-writers-club"
2303 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2304 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2305 ("l\\.~sircmpwn\\.srht-admins"
2306 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2307 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2308 ("l\\.~sircmpwn\\.srht-announce"
2309 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2310 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2311 ("l\\.~sircmpwn\\.srht-dev"
2312 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2313 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2314 ("l\\.~sircmpwn\\.srht-discuss"
2315 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2316 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2318 (to-address . "webmasters@gnu.org")
2319 (to-list . "webmasters@gnu.org"))
2326 gnus-large-newsgroup 50
2327 gnus-home-directory (b/var "gnus/")
2328 gnus-directory (concat gnus-home-directory "news/")
2329 message-directory (concat gnus-home-directory "mail/")
2330 nndraft-directory (concat gnus-home-directory "drafts/")
2331 gnus-save-newsrc-file nil
2332 gnus-read-newsrc-file nil
2333 gnus-interactive-exit nil
2334 gnus-gcc-mark-as-read t)
2336 (when (version< emacs-version "27")
2337 (with-eval-after-load 'nnmail
2339 'nnmail-split-abbrev-alist
2340 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2343 ;; (gnus-registry-initialize)
2345 (with-eval-after-load 'recentf
2346 (add-to-list 'recentf-exclude gnus-home-directory)))
2348 (use-package gnus-art
2351 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2352 gnus-sorted-header-list '("^From:"
2368 "^Mail-Followup-To:"
2372 "^X-detected-operating-system:"
2377 gnus-visible-headers (mapconcat 'identity
2378 gnus-sorted-header-list
2380 ;; local-lapsed article dates
2381 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2382 gnus-article-date-headers '(user-defined)
2383 gnus-article-time-format
2385 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2386 (local (article-make-date-line date 'local))
2387 (combined-lapsed (article-make-date-line date
2390 (string-match " (.+" combined-lapsed)
2391 (match-string 0 combined-lapsed))))
2392 (concat local lapsed))))
2394 :map gnus-article-mode-map
2395 ("M-L" . org-store-link)))
2397 (use-package gnus-sum
2398 :bind (:map gnus-summary-mode-map
2399 :prefix-map b/gnus-summary-prefix-map
2401 ("r" . gnus-summary-reply)
2402 ("w" . gnus-summary-wide-reply)
2403 ("v" . gnus-summary-show-raw-article))
2406 :map gnus-summary-mode-map
2407 ("M-L" . org-store-link))
2408 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2410 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2411 gnus-thread-sort-by-subject
2412 gnus-thread-sort-by-date)))
2414 (use-package gnus-msg
2416 (defvar b/shemshak-signature "Amin Bandali
2417 https://shemshak.org/~amin")
2418 (defvar b/uw-signature "Amin Bandali, MMath Student
2419 Cheriton School of Computer Science
2420 University of Waterloo
2421 https://bandali.eu.org")
2422 (defvar b/csc-signature "Amin Bandali
2424 Computer Science Club, University of Waterloo
2425 https://csclub.uwaterloo.ca/~abandali")
2426 (setq gnus-message-replysign t
2429 (address "mab@gnu.org"))
2430 ("nnimap\\+gnu:l\\..*"
2433 (organization "GNU"))
2434 ((header "subject" "ThankCRM")
2435 (to "webmasters-comment@gnu.org")
2437 (eval (setq b/message-cite-say-hi nil)))
2438 ("nnimap\\+shemshak:.*"
2439 (address "amin@shemshak.org")
2441 (signature b/shemshak-signature)
2442 (gcc "nnimap+shemshak:Sent")
2443 (eval (setq b/message-cite-say-hi t)))
2445 (address "bandali@uwaterloo.ca")
2447 (signature b/uw-signature))
2448 ("nnimap\\+uw:INBOX"
2449 (gcc "\"nnimap+uw:Sent Items\""))
2451 (address "bandali@csclub.uwaterloo.ca")
2452 (signature b/csc-signature)
2453 (gcc "nnimap+csc:Sent"))))
2454 :hook (gnus-message-setup . (lambda ()
2455 (unless (mml-secure-is-encrypted-p)
2456 (mml-secure-message-sign)))))
2458 (use-package gnus-topic
2459 :hook (gnus-group-mode . gnus-topic-mode)
2460 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2462 (use-package gnus-agent
2464 (setq gnus-agent-synchronize-flags 'ask)
2465 :hook (gnus-group-mode . gnus-agent-mode))
2467 (use-package gnus-group
2469 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2472 ;; problematic with ebdb's popup, *EBDB-Gnus*
2473 (use-package gnus-win
2475 (setq gnus-use-full-window nil)))
2477 (use-package gnus-dired
2478 :commands gnus-dired-mode
2480 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2483 (use-package gnus-utils
2485 (gnus-completing-read-function 'gnus-ido-completing-read)))
2487 (use-package mm-decode
2489 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2490 mm-decrypt-option 'known
2491 mm-verify-option 'known))
2495 (set-face-attribute 'mm-uu-extract nil :extend t)
2497 (mm-uu-diff-groups-regexp
2498 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2500 (use-package sendmail
2502 (setq sendmail-program (executable-find "msmtp")
2503 ;; message-sendmail-extra-arguments '("-v" "-d")
2504 mail-specify-envelope-from t
2505 mail-envelope-from 'header))
2507 (use-package message
2508 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2510 ;; redefine for a simplified In-Reply-To header
2511 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2512 (defun message-make-in-reply-to ()
2513 "Return the In-Reply-To header for this message."
2514 (when message-reply-headers
2515 (let ((from (mail-header-from message-reply-headers))
2516 (msg-id (mail-header-id message-reply-headers)))
2520 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2521 (defconst message-cite-style-bandali
2522 '((message-cite-function 'message-cite-original)
2523 (message-citation-line-function 'message-insert-formatted-citation-line)
2524 (message-cite-reply-position 'traditional)
2525 (message-yank-prefix "> ")
2526 (message-yank-cited-prefix ">")
2527 (message-yank-empty-prefix ">")
2528 (message-citation-line-format
2529 (if b/message-cite-say-hi
2530 (concat "Hi %F,\n\n" b/message-cite-style-format)
2531 b/message-cite-style-format)))
2532 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2533 (setq ;; message-cite-style 'message-cite-style-bandali
2534 message-kill-buffer-on-exit t
2535 message-send-mail-function 'message-send-mail-with-sendmail
2536 message-sendmail-envelope-from 'header
2537 message-subscribed-address-functions
2538 '(gnus-find-subscribed-addresses)
2539 message-dont-reply-to-names
2540 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(mab\\|bandali\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2541 ;; (require 'company-ebdb)
2542 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2543 (message-mode . flyspell-mode)
2544 (message-mode . (lambda ()
2545 ;; (setq-local fill-column b/fill-column
2546 ;; message-fill-column b/fill-column)
2547 (make-local-variable 'company-idle-delay)
2548 (setq company-idle-delay 0.2))))
2550 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2551 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2552 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2554 (message-elide-ellipsis "[...]\n"))
2558 (use-package mml-sec
2560 (mml-secure-openpgp-encrypt-to-self t)
2561 (mml-secure-openpgp-sign-with-sender t))
2563 (use-package footnote
2566 ;; (setq footnote-start-tag ""
2567 ;; footnote-end-tag ""
2568 ;; footnote-style 'unicode)
2570 (:map message-mode-map
2571 :prefix-map b/footnote-prefix-map
2573 ("a" . footnote-add-footnote)
2574 ("b" . footnote-back-to-message)
2575 ("c" . footnote-cycle-style)
2576 ("d" . footnote-delete-footnote)
2577 ("g" . footnote-goto-footnote)
2578 ("r" . footnote-renumber-footnotes)
2579 ("s" . footnote-set-style)))
2585 :bind (:map gnus-group-mode-map ("e" . bbdb))
2587 (bbdb-initialize 'gnus 'message)
2589 (bbdb-complete-mail-allow-cycling t)
2590 (bbdb-user-mail-address-re message-dont-reply-to-names))
2595 :bind (:map gnus-group-mode-map ("e" . ebdb))
2597 (setq ebdb-sources (b/var "ebdb"))
2598 (with-eval-after-load 'swiper
2599 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2601 (use-package ebdb-com
2604 (use-package ebdb-complete
2607 ;; (setq ebdb-complete-mail 'capf)
2608 (ebdb-complete-enable))
2610 (use-package ebdb-message
2614 ;; (use-package company-ebdb
2616 ;; (defun company-ebdb--post-complete (_) nil))
2618 (use-package ebdb-gnus
2621 (ebdb-gnus-window-size 0.3))
2623 (use-package ebdb-mua
2626 :custom (ebdb-mua-pop-up t))
2628 ;; (use-package ebdb-message
2631 ;; (use-package ebdb-vcard
2634 (use-package message-x)
2637 (use-package message-x
2639 (message-x-completion-alist
2641 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2644 (quote message-newgroups-header-regexp))
2645 message-newgroups-header-regexp message-newsgroups-header-regexp)
2646 . message-expand-group))))))
2649 (use-package gnus-harvest
2650 :commands gnus-harvest-install
2653 (if (featurep 'message-x)
2654 (gnus-harvest-install 'message-x)
2655 (gnus-harvest-install))))
2657 (use-package gnus-article-treat-patch
2662 ;; note: be sure to customize faces with `:foreground "white"' when
2663 ;; using a theme with a white/light background :)
2664 (setq ft/gnus-article-patch-conditions
2665 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2668 ;;; IRC (with ERC and ZNC)
2671 :bind (("C-c b b" . erc-switch-to-buffer)
2673 ("M-a" . erc-track-switch-buffer))
2675 (erc-join-buffer 'bury)
2676 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2677 (erc-nick "bandali")
2679 (erc-rename-buffers t)
2680 (erc-server-reconnect-attempts 5)
2681 (erc-server-reconnect-timeout 3)
2683 (defun erc-cmd-OPME ()
2684 "Request chanserv to op me."
2685 (erc-message "PRIVMSG"
2686 (format "chanserv op %s %s"
2687 (erc-default-target)
2688 (erc-current-nick)) nil))
2689 (defun erc-cmd-DEOPME ()
2690 "Deop myself from current channel."
2691 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2692 (add-to-list 'erc-modules 'keep-place)
2693 (add-to-list 'erc-modules 'notifications)
2694 (add-to-list 'erc-modules 'smiley)
2695 (add-to-list 'erc-modules 'spelling)
2696 (add-to-list 'erc-modules 'scrolltoplace)
2697 (erc-update-modules))
2699 (use-package erc-fill
2702 (erc-fill-column 77)
2703 (erc-fill-function 'erc-fill-static)
2704 (erc-fill-static-center 18))
2706 (use-package erc-pcomplete
2709 (erc-pcomplete-nick-postfix ", "))
2711 (use-package erc-track
2713 :bind (("C-c a e t d" . erc-track-disable)
2714 ("C-c a e t e" . erc-track-enable))
2716 (erc-track-enable-keybindings nil)
2717 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2718 "324" "329" "332" "333" "353" "477"))
2719 (erc-track-position-in-mode-line t)
2720 (erc-track-priority-faces-only 'all)
2721 (erc-track-shorten-function nil))
2723 (use-package erc-hl-nicks
2726 (use-package erc-scrolltoplace
2730 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/znc.el")
2731 ;; :bind (("C-c a e e" . znc-erc)
2732 ;; ("C-c a e a" . znc-all))
2734 ;; (let ((pwd (let ((auth (auth-source-search :host "znca")))
2736 ;; ((null auth) (error "Couldn't find znca's authinfo"))
2737 ;; (t (funcall (plist-get (car auth) :secret)))))))
2738 ;; (setq znc-servers
2739 ;; `(("znc.shemshak.org" 1337 t
2740 ;; ((freenode "amin/freenode" ,pwd)))
2741 ;; ("znc.shemshak.org" 1337 t
2742 ;; ((moznet "amin/moznet" ,pwd)))
2743 ;; ("znc.shemshak.org" 1337 t
2744 ;; ((oftc "amin/oftc" ,pwd)))))))
2747 ;;; Post initialization
2749 (message "Loading %s...done (%.3fs)" user-init-file
2750 (float-time (time-subtract (current-time)
2751 b/before-user-init-time)))
2753 ;;; init.el ends here