22b7b688c06068352fa9d3d3c7b427b23b37d1dd
[~bandali/configs] / init.el
1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
2
3 ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org>
4
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.
9
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.
14
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/>.
17
18 ;;; Commentary:
19
20 ;; GNU Emacs configuration of Amin Bandali, computer scientist,
21 ;; Free Software activist, and GNU maintainer & webmaster. Packages
22 ;; are installed through GNU Guix for a fully reproducible setup.
23 ;; Before switching to Guix, I used straight.el, and before that Borg.
24
25 ;; Over the years, I've taken inspiration from configurations of many
26 ;; great people. Some that I can remember off the top of my head are:
27 ;;
28 ;; - https://github.com/dieggsy/dotfiles
29 ;; - https://github.com/dakra/dmacs
30 ;; - http://pages.sachachua.com/.emacs.d/Sacha.html
31 ;; - https://github.com/dakrone/eos
32 ;; - http://doc.rix.si/cce/cce.html
33 ;; - https://github.com/jwiegley/dot-emacs
34 ;; - https://github.com/wasamasa/dotemacs
35 ;; - https://github.com/hlissner/doom-emacs
36
37 ;;; Code:
38
39 ;;; Emacs initialization
40
41 (defvar b/before-user-init-time (current-time)
42 "Value of `current-time' when Emacs begins loading `user-init-file'.")
43 (defvar b/emacs-initialized nil
44 "Whether Emacs has been initialized.")
45
46 (when (not (bound-and-true-p b/emacs-initialized))
47 (message "Loading Emacs...done (%.3fs)"
48 (float-time (time-subtract b/before-user-init-time
49 before-init-time))))
50
51 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
52 ;; during startup to reduce garbage collection frequency. clearing
53 ;; `file-name-handler-alist' seems to help reduce startup time too.
54 (defvar b/gc-cons-threshold gc-cons-threshold)
55 (defvar b/gc-cons-percentage gc-cons-percentage)
56 (defvar b/file-name-handler-alist file-name-handler-alist)
57 (setq gc-cons-threshold (* 30 1024 1024) ; 30 MiB
58 gc-cons-percentage 0.6
59 file-name-handler-alist nil
60 ;; sidesteps a bug when profiling with esup
61 esup-child-profile-require-level 0)
62
63 ;; set them back to their defaults once we're done initializing
64 (defun b/post-init ()
65 "My post-initialize function, run after loading `user-init-file'."
66 (setq b/emacs-initialized t
67 gc-cons-threshold b/gc-cons-threshold
68 gc-cons-percentage b/gc-cons-percentage
69 file-name-handler-alist b/file-name-handler-alist)
70 (with-eval-after-load 'exwm-workspace
71 (setq-default
72 mode-line-format
73 (append
74 mode-line-format
75 '((:eval
76 (format
77 "[%s]" (number-to-string
78 exwm-workspace-current-index))))))))
79 (add-hook 'after-init-hook #'b/post-init)
80
81 ;; increase number of lines kept in *Messages* log
82 (setq message-log-max 20000)
83
84 ;; optionally, uncomment to supress some byte-compiler warnings
85 ;; (see C-h v byte-compile-warnings RET for more info)
86 ;; (setq byte-compile-warnings
87 ;; '(not free-vars unresolved noruntime lexical make-local))
88
89 \f
90 ;;; whoami
91
92 (setq user-full-name "Amin Bandali"
93 user-mail-address "bandali@gnu.org")
94
95 \f
96 ;;; comment macro
97
98 ;; useful for commenting out multiple sexps at a time
99 (defmacro comment (&rest _)
100 "Comment out one or more s-expressions."
101 (declare (indent defun))
102 nil)
103
104 \f
105 ;;; Package management
106
107 ;; No package.el (for emacs 26 and before)
108 (when (version< emacs-version "27")
109 (setq package-enable-at-startup nil)
110 ;; (package-initialize)
111 )
112 ;; for emacs 27 and later, we use early-init.el. see
113 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
114
115 (progn ; `borg'
116 (add-to-list 'load-path
117 (expand-file-name "lib/borg" user-emacs-directory))
118 (require 'borg)
119 (borg-initialize)
120 (setq borg-rewrite-urls-alist
121 '(("git@github.com:" . "https://github.com/")
122 ("git@gitlab.com:" . "https://gitlab.com/"))))
123
124 ;; use-package
125 (if nil ; set to t when need to debug init
126 (progn
127 (setq use-package-verbose t
128 use-package-expand-minimally nil
129 use-package-compute-statistics t
130 debug-on-error t)
131 (require 'use-package))
132 (setq use-package-verbose nil
133 use-package-expand-minimally t))
134
135 (setq use-package-always-defer t)
136 (require 'bind-key)
137
138 \f
139 ;;; Initial setup
140
141 (defvar b/exwm-p (string= (system-name) "chaman")
142 "Whether or not we will be using `exwm'.")
143
144 ;; keep ~/.emacs.d clean
145 (use-package no-littering
146 :demand
147 :config
148 (defalias 'b/etc 'no-littering-expand-etc-file-name)
149 (defalias 'b/var 'no-littering-expand-var-file-name))
150
151 (use-package auto-compile
152 :demand
153 :config
154 (auto-compile-on-load-mode)
155 (auto-compile-on-save-mode)
156 (setq auto-compile-display-buffer nil)
157 (setq auto-compile-mode-line-counter t)
158 (setq auto-compile-source-recreate-deletes-dest t)
159 (setq auto-compile-toggle-deletes-nonlib-dest t)
160 (setq auto-compile-update-autoloads t))
161
162 ;; separate custom file (don't want it mixing with init.el)
163 (use-package custom
164 :no-require
165 :config
166 (setq custom-file (b/etc "custom.el"))
167 (when (file-exists-p custom-file)
168 (load custom-file))
169 ;; while at it, treat themes as safe
170 (setf custom-safe-themes t)
171 ;; only one custom theme at a time
172 (comment
173 (defadvice load-theme (before clear-previous-themes activate)
174 "Clear existing theme settings instead of layering them"
175 (mapc #'disable-theme custom-enabled-themes))))
176
177 ;; load the secrets file if it exists, otherwise show a warning
178 (comment
179 (with-demoted-errors
180 (load (b/etc "secrets"))))
181
182 ;; start up emacs server. see
183 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
184 (use-package server
185 :defer 0.4
186 :config (or (server-running-p) (server-mode)))
187
188 \f
189 ;;; Useful utilities
190
191 ;; useful libraries
192 (require 'cl-lib)
193 (require 'subr-x)
194
195 (defmacro b/setq-every (value &rest vars)
196 "Set all the variables from VARS to value VALUE."
197 (declare (indent defun) (debug t))
198 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
199
200 (defun b/start-process (program &rest args)
201 "Same as `start-process', but doesn't bother about name and buffer."
202 (let ((process-name (concat program "_process"))
203 (buffer-name (generate-new-buffer-name
204 (concat program "_output"))))
205 (apply #'start-process
206 process-name buffer-name program args)))
207
208 (defun b/dired-start-process (program &optional args)
209 "Open current file with a PROGRAM."
210 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
211 ;; be nil, so remove it).
212 (apply #'b/start-process
213 program
214 (remove nil (list args (dired-get-file-for-visit)))))
215
216 (defun b/add-elisp-section ()
217 (interactive)
218 (insert "\n")
219 (previous-line)
220 (insert "\n\f\n;;; "))
221
222 ;; (defvar b/fill-column 47
223 ;; "My custom `fill-column'.")
224
225 (defconst b/asterism "* * *")
226
227 (defun b/insert-asterism ()
228 "Insert a centred asterism."
229 (interactive)
230 (insert
231 (concat
232 "\n\n"
233 (make-string (floor (/ (- fill-column (length b/asterism)) 2))
234 ?\s)
235 b/asterism
236 "\n\n")))
237
238 (defun b/no-mouse-autoselect-window ()
239 "Conveniently disable `focus-follows-mouse'.
240 For disabling the behaviour for certain buffers and/or modes."
241 (make-local-variable 'mouse-autoselect-window)
242 (setq mouse-autoselect-window nil))
243
244 (defun b/kill-current-buffer ()
245 "Kill the current buffer."
246 ;; also see https://redd.it/64xb3q
247 (interactive)
248 (kill-buffer (current-buffer)))
249
250 \f
251 ;;; Defaults
252
253 ;;;; C-level customizations
254
255 (setq
256 ;; minibuffer
257 enable-recursive-minibuffers t
258 resize-mini-windows t
259 ;; more useful frame titles
260 frame-title-format '("" invocation-name " - "
261 (:eval
262 (if (buffer-file-name)
263 (abbreviate-file-name (buffer-file-name))
264 "%b")))
265 ;; i don't feel like jumping out of my chair every now and again; so
266 ;; don't BEEP! at me, emacs
267 ring-bell-function 'ignore
268 ;; better scrolling
269 ;; scroll-margin 1
270 ;; scroll-conservatively 10000
271 scroll-step 1
272 scroll-conservatively 10
273 scroll-preserve-screen-position 1
274 ;; focus follows mouse
275 mouse-autoselect-window t)
276
277 (setq-default
278 ;; always use space for indentation
279 indent-tabs-mode nil
280 tab-width 4
281 ;; cursor shape
282 cursor-type 'bar)
283
284 ;; unicode support
285 (comment
286 (dolist (ft (fontset-list))
287 (set-fontset-font
288 ft
289 'unicode
290 (font-spec :name "Source Code Pro" :size 14))
291 (set-fontset-font
292 ft
293 'unicode
294 (font-spec :name "DejaVu Sans Mono")
295 nil
296 'append)
297 ;; (set-fontset-font
298 ;; ft
299 ;; 'unicode
300 ;; (font-spec
301 ;; :name "Symbola monospacified for DejaVu Sans Mono")
302 ;; nil
303 ;; 'append)
304 ;; (set-fontset-font
305 ;; ft
306 ;; #x2115 ; ℕ
307 ;; (font-spec :name "DejaVu Sans Mono")
308 ;; nil
309 ;; 'append)
310 (set-fontset-font
311 ft
312 (cons ?Α ?ω)
313 (font-spec :name "DejaVu Sans Mono" :size 14)
314 nil
315 'prepend)))
316
317 ;;;; Elisp-level customizations
318
319 (use-package startup
320 :no-require
321 :demand
322 :config
323 ;; don't need to see the startup echo area message
324 (advice-add #'display-startup-echo-area-message :override #'ignore)
325 :custom
326 ;; i want *scratch* as my startup buffer
327 (initial-buffer-choice t)
328 ;; i don't need the default hint
329 (initial-scratch-message nil)
330 ;; use customizable text-mode as major mode for *scratch*
331 ;; (initial-major-mode 'text-mode)
332 ;; inhibit buffer list when more than 2 files are loaded
333 (inhibit-startup-buffer-menu t)
334 ;; don't need to see the startup screen or echo area message
335 (inhibit-startup-screen t)
336 (inhibit-startup-echo-area-message user-login-name))
337
338 (use-package files
339 :no-require
340 :demand
341 :custom
342 ;; backups (C-h v make-backup-files RET)
343 (backup-by-copying t)
344 (version-control t)
345 (delete-old-versions t)
346
347 ;; auto-save
348 (auto-save-file-name-transforms
349 `((".*" ,(b/var "auto-save/") t)))
350
351 ;; insert newline at the end of files
352 (require-final-newline t)
353
354 ;; open read-only file buffers in view-mode
355 ;; (enables niceties like `q' for quit)
356 (view-read-only t))
357
358 ;; disable disabled commands
359 (setq disabled-command-function nil)
360
361 ;; lazy-person-friendly yes/no prompts
362 (defalias 'yes-or-no-p #'y-or-n-p)
363
364 ;; enable automatic reloading of changed buffers and files
365 (use-package autorevert
366 :demand
367 :config
368 (global-auto-revert-mode 1)
369 :custom
370 (auto-revert-verbose nil)
371 (global-auto-revert-non-file-buffers nil))
372
373 ;; time and battery in mode-line
374 (use-package time
375 :demand
376 :config
377 (display-time-mode)
378 :custom
379 (display-time-default-load-average nil)
380 (display-time-format "%a %b %-e %-l:%M%P")
381 (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center))
382 (display-time-use-mail-icon t))
383
384 (use-package battery
385 :demand
386 :config
387 (display-battery-mode)
388 :custom
389 (battery-mode-line-format " %p%% %t"))
390
391 (use-package fringe
392 :demand
393 :config
394 ;; smaller fringe
395 ;; (fringe-mode '(3 . 1))
396 (fringe-mode nil))
397
398 (use-package winner
399 :demand
400 :config
401 ;; enable winner-mode (C-h f winner-mode RET)
402 (winner-mode 1))
403
404 (use-package compile
405 :config
406 ;; don't display *compilation* buffer on success. based on
407 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
408 ;; instead of the now obsolete `flet'.
409 (defun b/compilation-finish-function (buffer outstr)
410 (unless (string-match "finished" outstr)
411 (switch-to-buffer-other-window buffer))
412 t)
413
414 (setq compilation-finish-functions #'b/compilation-finish-function)
415
416 (require 'cl-macs)
417
418 (defadvice compilation-start
419 (around inhibit-display
420 (command &optional mode name-function highlight-regexp))
421 (if (not (string-match "^\\(find\\|grep\\)" command))
422 (cl-letf (((symbol-function 'display-buffer) #'ignore))
423 (save-window-excursion ad-do-it))
424 ad-do-it))
425 (ad-activate 'compilation-start))
426
427 (use-package isearch
428 :custom
429 ;; allow scrolling in Isearch
430 (isearch-allow-scroll t)
431 ;; search for non-ASCII characters: i’d like non-ASCII characters such
432 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
433 ;; counterpart. shoutout to
434 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
435 (search-default-mode #'char-fold-to-regexp))
436
437 ;; uncomment to extend the above behaviour to query-replace
438 (comment
439 (use-package replace
440 :custom
441 (replace-char-fold t)))
442
443 (use-package vc
444 :bind ("C-x v C-=" . vc-ediff))
445
446 (use-package vc-git
447 :after vc
448 :custom
449 (vc-git-print-log-follow t))
450
451 (use-package ediff
452 :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo)
453 :custom ((ediff-window-setup-function 'ediff-setup-windows-plain)
454 (ediff-split-window-function 'split-window-horizontally)))
455
456 (use-package face-remap
457 :custom
458 ;; gentler font resizing
459 (text-scale-mode-step 1.05))
460
461 (use-package mwheel
462 :defer 0.4
463 :config
464 (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time
465 mouse-wheel-progressive-speed nil ; don't accelerate scrolling
466 mouse-wheel-follow-mouse t)) ; scroll window under mouse
467
468 (use-package pixel-scroll
469 :defer 0.4
470 :config (pixel-scroll-mode 1))
471
472 (use-package epg-config
473 :config
474 ;; ask for GPG passphrase in minibuffer
475 ;; this will fail if gpg>=2.1 is not available
476 (if (version< "27" emacs-version)
477 (setq epg-pinentry-mode 'loopback)
478 (setq epa-pinentry-mode 'loopback))
479 :custom
480 (epg-gpg-program (executable-find "gpg")))
481
482 (use-package epg
483 :after epg-config)
484
485 (use-package pinentry
486 :demand
487 :after (epa epg server)
488 :config
489 ;; workaround for systemd-based distros:
490 ;; (setq pinentry--socket-dir server-socket-dir)
491 (pinentry-start))
492
493 (use-package auth-source
494 :custom
495 (auth-sources '("~/.authinfo.gpg"))
496 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
497
498 \f
499 ;;; General bindings
500
501 (bind-keys
502 ("C-c a i" . ielm)
503
504 ("C-c e b" . eval-buffer)
505 ("C-c e e" . eval-last-sexp)
506 ("C-c e r" . eval-region)
507
508 ("C-c e i" . emacs-init-time)
509 ("C-c e u" . emacs-uptime)
510 ("C-c e v" . emacs-version)
511
512 ("C-c F m" . make-frame-command)
513 ("C-c F d" . delete-frame)
514 ("C-c F D" . server-edit)
515
516 ("C-S-h C" . describe-char)
517 ("C-S-h F" . describe-face)
518
519 ("C-x k" . b/kill-current-buffer)
520 ("C-x K" . kill-buffer)
521 ("C-x s" . save-buffer)
522 ("C-x S" . save-some-buffers)
523
524 :map emacs-lisp-mode-map
525 ("<C-return>" . b/add-elisp-section))
526
527 (when (display-graphic-p)
528 (unbind-key "C-z" global-map))
529
530 (bind-keys
531 ;; for back and forward mouse keys
532 ("<XF86Back>" . previous-buffer)
533 ("<mouse-8>" . previous-buffer)
534 ;; ("<drag-mouse-8>" . previous-buffer)
535 ("<XF86Forward>" . next-buffer)
536 ("<mouse-9>" . next-buffer)
537 ;; ("<drag-mouse-9>" . next-buffer)
538 ;; ("<drag-mouse-2>" . kill-this-buffer)
539 ;; ("<drag-mouse-3>" . switch-to-buffer)
540 )
541
542 \f
543 ;;; Essential packages
544
545 (use-package exwm
546 :if b/exwm-p
547 :demand
548 :config
549 ;; make class name the buffer name, truncating beyond 60 characters
550 (defun b/exwm-rename-buffer ()
551 (interactive)
552 (exwm-workspace-rename-buffer
553 (concat exwm-class-name ":"
554 (if (<= (length exwm-title) 60) exwm-title
555 (concat (substring exwm-title 0 59) "...")))))
556 ;; Enable EXWM
557 (exwm-enable)
558 :hook ((exwm-update-class . b/exwm-rename-buffer)
559 (exwm-update-title . b/exwm-rename-buffer)))
560
561 (use-package exwm-config
562 :demand
563 :after exwm
564 :hook (exwm-init . exwm-config--fix/ido-buffer-window-other-frame))
565
566 (use-package exwm-input
567 :demand
568 :after exwm
569 :config
570 (defun b/exwm-ws-prev-index ()
571 "Return the index for the previous EXWM workspace, wrapping
572 around if needed."
573 (if (= exwm-workspace-current-index 0)
574 (1- exwm-workspace-number)
575 (1- exwm-workspace-current-index)))
576
577 (defun b/exwm-ws-next-index ()
578 "Return the index for the next EXWM workspace, wrapping
579 around if needed."
580 (if (= exwm-workspace-current-index
581 (1- exwm-workspace-number))
582 0
583 (1+ exwm-workspace-current-index)))
584
585 ;; shorten 'C-c C-q' to 'C-q'
586 (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
587
588 (setq exwm-workspace-number 4
589 exwm-input-global-keys
590 `(([?\s-R] . exwm-reset)
591 ([?\s-\\] . exwm-workspace-switch)
592 ([?\s-\s] . dmenu)
593 ([?\S-\s-\s] . (lambda (command)
594 (interactive
595 (list (read-shell-command "➜ ")))
596 (start-process-shell-command
597 command nil command)))
598 ([s-return] . (lambda ()
599 (interactive)
600 (start-process "" nil "urxvt")))
601 ([?\C-\s-\s] . counsel-linux-app)
602 ([?\M-\s-\s] . (lambda ()
603 (interactive)
604 (start-process-shell-command
605 "rofi-pass" nil "rofi-pass")))
606 ([?\s-h] . windmove-left)
607 ([?\s-j] . windmove-down)
608 ([?\s-k] . windmove-up)
609 ([?\s-l] . windmove-right)
610 ([?\s-H] . windmove-swap-states-left)
611 ([?\s-J] . windmove-swap-states-down)
612 ([?\s-K] . windmove-swap-states-up)
613 ([?\s-L] . windmove-swap-states-right)
614 ([?\M-\s-h] . shrink-window-horizontally)
615 ([?\M-\s-l] . enlarge-window-horizontally)
616 ([?\M-\s-k] . shrink-window)
617 ([?\M-\s-j] . enlarge-window)
618 ([?\s-\[] . (lambda ()
619 (interactive)
620 (exwm-workspace-switch-create
621 (b/exwm-ws-prev-index))))
622 ([?\s-\]] . (lambda ()
623 (interactive)
624 (exwm-workspace-switch-create
625 (b/exwm-ws-next-index))))
626 ([?\s-{] . (lambda ()
627 (interactive)
628 (exwm-workspace-move-window
629 (b/exwm-ws-prev-index))))
630 ([?\s-}] . (lambda ()
631 (interactive)
632 (exwm-workspace-move-window
633 (b/exwm-ws-next-index))))
634 ,@(mapcar (lambda (i)
635 `(,(kbd (format "s-%d" i)) .
636 (lambda ()
637 (interactive)
638 (exwm-workspace-switch-create ,i))))
639 (number-sequence 0 (1- exwm-workspace-number)))
640 ([?\s-t] . exwm-floating-toggle-floating)
641 ([?\s-f] . exwm-layout-toggle-fullscreen)
642 ([?\s-W] . (lambda ()
643 (interactive)
644 (kill-buffer (current-buffer))))
645 ([?\s-Q] . (lambda ()
646 (interactive)
647 (exwm-manage--kill-client)))
648 ([?\s-\'] . (lambda ()
649 (interactive)
650 (start-process-shell-command
651 "rofi-light" nil "rofi-light")))
652 ([XF86AudioMute] .
653 (lambda ()
654 (interactive)
655 (start-process "" nil "amixer" "set" "'Master',0" "toggle")))
656 ([XF86AudioLowerVolume] .
657 (lambda ()
658 (interactive)
659 (start-process
660 "" nil "amixer" "set" "'Master',0" "5%-")))
661 ([XF86AudioRaiseVolume] .
662 (lambda ()
663 (interactive)
664 (start-process
665 "" nil "amixer" "set" "'Master',0" "5%+")))
666 ([XF86AudioPlay] .
667 (lambda ()
668 (interactive)
669 (start-process "" nil "mpc" "toggle")))
670 ([XF86AudioPrev] .
671 (lambda ()
672 (interactive)
673 (start-process "" nil "mpc" "prev")))
674 ([XF86AudioNext] .
675 (lambda ()
676 (interactive)
677 (start-process "" nil "mpc" "next")))
678 ([XF86ScreenSaver] .
679 (lambda ()
680 (interactive)
681 (start-process "" nil "dm-tool" "lock")))
682 ([\s-XF86Back] . previous-buffer)
683 ([\s-XF86Forward] . next-buffer)))
684
685 ;; Line-editing shortcuts
686 (setq exwm-input-simulation-keys
687 '(;; movement
688 ([?\C-b] . [left])
689 ([?\M-b] . [C-left])
690 ([?\C-f] . [right])
691 ([?\M-f] . [C-right])
692 ([?\C-p] . [up])
693 ([?\C-n] . [down])
694 ([?\C-a] . [home])
695 ([?\C-e] . [end])
696 ([?\M-v] . [prior])
697 ([?\C-v] . [next])
698 ([?\C-d] . [delete])
699 ([?\C-k] . [S-end ?\C-x])
700 ([?\M-<] . C-home)
701 ([?\M->] . C-end)
702 ;; cut/copy/paste
703 ([?\C-w] . [?\C-x])
704 ([?\M-w] . [?\C-c])
705 ([?\C-y] . [?\C-v])
706 ([?\M-d] . [C-S-right ?\C-x])
707 ([?\M-\d] . [C-S-left ?\C-x])
708 ;; window
709 ([?\s-w] . [?\C-w])
710 ([?\s-q] . [?\C-q])
711 ;; misc
712 ([?\C-s] . [?\C-f])
713 ([?\s-s] . [?\C-s])
714 ([?\C-g] . [escape]))))
715
716 (use-package exwm-manage
717 :demand
718 :after exwm
719 :hook
720 (exwm-manage-finish . (lambda ()
721 (when exwm-class-name
722 (cond
723 ((string= exwm-class-name "IceCat")
724 (exwm-input-set-local-simulation-keys
725 `(,@exwm-input-simulation-keys
726 ([?\C-\S-d] . [?\C-d]))))
727 ((string= exwm-class-name "URxvt")
728 (exwm-input-set-local-simulation-keys
729 '(([?\C-c ?\C-c] . [?\C-c])
730 ([?\C-c ?\C-u] . [?\C-u]))))
731 ((string= exwm-class-name "Zathura")
732 (exwm-input-set-local-simulation-keys
733 '(([?\C-p] . [C-up])
734 ([?\C-n] . [C-down])))))))))
735
736 (use-package exwm-randr
737 :demand
738 :after exwm
739 :config
740 (exwm-randr-enable)
741 :custom
742 (exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
743
744 (use-package exwm-systemtray
745 :demand
746 :after exwm
747 :config
748 (exwm-systemtray-enable))
749
750 (use-package exwm-workspace)
751
752 (use-package exwm-edit
753 :demand
754 :after exwm)
755
756 ;; use the org-plus-contrib package to get the whole deal
757 (use-package org-plus-contrib)
758
759 (use-package org
760 :defer 0.5
761 :config
762 (setq org-src-tab-acts-natively t
763 org-src-preserve-indentation nil
764 org-edit-src-content-indentation 0
765 org-link-email-description-format "Email %c: %s" ; %.30s
766 org-highlight-latex-and-related '(entities)
767 org-use-speed-commands t
768 org-startup-folded 'content
769 org-catch-invisible-edits 'show-and-error
770 org-log-done 'time)
771 (when (version< org-version "9.3")
772 (setq org-email-link-description-format
773 org-link-email-description-format))
774 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
775 (add-to-list 'org-modules 'org-habit)
776 :bind
777 (("C-c a o a" . org-agenda)
778 :map org-mode-map
779 ("M-L" . org-insert-last-stored-link)
780 ("M-O" . org-toggle-link-display))
781 :hook ((org-mode . org-indent-mode)
782 (org-mode . auto-fill-mode)
783 (org-mode . flyspell-mode))
784 :custom
785 (org-pretty-entities t)
786 (org-agenda-files '("~/usr/org/todos/personal.org"
787 "~/usr/org/todos/habits.org"
788 "~/src/git/masters-thesis/todo.org"))
789 (org-agenda-start-on-weekday 0)
790 (org-agenda-time-leading-zero t)
791 (org-habit-graph-column 44)
792 (org-latex-packages-alist '(("" "listings") ("" "color")))
793 :custom-face
794 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
795 '(org-block ((t (:background "#1d1f21"))))
796 '(org-latex-and-related ((t (:foreground "#b294bb")))))
797
798 (use-package ox-latex
799 :after ox
800 :config
801 (setq org-latex-listings 'listings
802 ;; org-latex-prefer-user-labels t
803 )
804 (add-to-list 'org-latex-classes
805 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
806 ("\\section{%s}" . "\\section*{%s}")
807 ("\\subsection{%s}" . "\\subsection*{%s}")
808 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
809 ("\\paragraph{%s}" . "\\paragraph*{%s}")
810 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
811 t)
812 (require 'ox-beamer))
813
814 (use-package ox-extra
815 :config
816 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
817
818 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
819 ;; org file. closely inspired by
820 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
821 (with-eval-after-load 'org
822 (defvar b/show-async-tangle-results nil
823 "Keep *emacs* async buffers around for later inspection.")
824
825 (defvar b/show-async-tangle-time nil
826 "Show the time spent tangling the file.")
827
828 (defun b/async-babel-tangle ()
829 "Tangle org file asynchronously."
830 (interactive)
831 (let* ((file-tangle-start-time (current-time))
832 (file (buffer-file-name))
833 (file-nodir (file-name-nondirectory file))
834 ;; (async-quiet-switch "-q")
835 (file-noext (file-name-sans-extension file)))
836 (async-start
837 `(lambda ()
838 (require 'org)
839 (org-babel-tangle-file ,file))
840 (unless b/show-async-tangle-results
841 `(lambda (result)
842 (if result
843 (message "Tangled %s%s"
844 ,file-nodir
845 (if b/show-async-tangle-time
846 (format " (%.3fs)"
847 (float-time (time-subtract (current-time)
848 ',file-tangle-start-time)))
849 ""))
850 (message "Tangling %s failed" ,file-nodir))))))))
851
852 (add-to-list
853 'safe-local-variable-values
854 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
855
856 ;; *the* right way to do git
857 (use-package magit
858 :defer 0.5
859 :bind (("C-x g" . magit-status)
860 ("C-c g g" . magit-status)
861 ("C-c g b" . magit-blame-addition)
862 ("C-c g l" . magit-log-buffer-file))
863 :config
864 (magit-add-section-hook 'magit-status-sections-hook
865 'magit-insert-modules
866 'magit-insert-stashes
867 'append)
868 ;; (magit-add-section-hook 'magit-status-sections-hook
869 ;; 'magit-insert-ignored-files
870 ;; 'magit-insert-untracked-files
871 ;; 'append)
872 (setq magit-repository-directories '(("~/.emacs.d/" . 0)
873 ("~/src/git/" . 2)))
874 (nconc magit-section-initial-visibility-alist
875 '(([unpulled status] . show)
876 ([unpushed status] . show)))
877 :custom
878 (magit-diff-refine-hunk t)
879 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
880 ;; (magit-completing-read-function 'magit-ido-completing-read)
881 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
882
883 ;; recently opened files
884 (use-package recentf
885 :defer 0.2
886 ;; :config
887 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
888 :config
889 (recentf-mode)
890 :custom
891 (recentf-max-saved-items 2000))
892
893 ;; smart M-x enhancement (needed by counsel for history)
894 ;; (use-package smex)
895
896 (bind-keys
897 ("C-c f ." . find-file)
898 ("C-c f d" . find-name-dired)
899 ("C-c f l" . find-library)
900 ;; ("C-c f r" . recentf-open-files)
901 ("C-c x" . execute-extended-command))
902
903 (comment
904 (use-package ido
905 :demand
906 :bind
907 (:map ido-common-completion-map
908 ([escape] . minibuffer-keyboard-quit)
909 ("DEL" . b/ido-backspace))
910 :config
911 (require 'delsel)
912 (defun b/ido-backspace ()
913 "Forward to `backward-delete-char'. On error (read-only), quit."
914 (interactive)
915 (condition-case nil
916 (backward-delete-char 1)
917 (error
918 (minibuffer-keyboard-quit))))
919 (ido-mode 1)
920 (ido-everywhere 1)
921 :custom
922 (ido-enable-flex-matching t)
923 ;; (ido-enable-regexp t)
924 ;; (ido-enable-prefix t)
925 (ido-max-window-height 10)
926 (ido-use-virtual-buffers t))
927
928 (use-package ido-vertical-mode
929 :defer 0.3
930 :config
931 (ido-vertical-mode 1)
932 :custom
933 (ido-vertical-define-keys 'C-n-C-p-up-and-down)
934 (ido-vertical-show-count t))
935
936 (use-package ido-completing-read+
937 :defer 0.3
938 :after ido
939 :config
940 (ido-ubiquitous-mode 1))
941
942 (use-package crm-custom
943 :defer 0.3
944 :config
945 (crm-custom-mode 1))
946
947 (use-package icomplete
948 :defer 0.3
949 :config
950 (icomplete-mode 1)))
951
952 (use-package amx
953 :defer 0.3
954 :config
955 (amx-mode))
956
957 (use-package ivy
958 :defer 0.3
959 :bind
960 (:map ivy-minibuffer-map
961 ([escape] . keyboard-escape-quit)
962 ([S-up] . ivy-previous-history-element)
963 ([S-down] . ivy-next-history-element)
964 ("DEL" . ivy-backward-delete-char))
965 :config
966 (setq ivy-wrap t
967 ;; ivy-height 14
968 ivy-use-virtual-buffers t
969 ivy-virtual-abbreviate 'abbreviate
970 ivy-count-format "%d/%d ")
971
972 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
973 (defun b/ivy-ignore-buffer-p (str)
974 "Return non-nil if str names a buffer with a major mode
975 derived from one of `b/ivy-ignore-buffer-modes'.
976
977 This function is intended for use with `ivy-ignore-buffers'."
978 (let* ((buf (get-buffer str))
979 (mode (and buf (buffer-local-value 'major-mode buf))))
980 (and mode
981 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
982 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
983
984 (ivy-mode 1)
985 :custom-face
986 (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
987 (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
988 (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
989 (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
990 (ivy-current-match ((((class color) (background light))
991 :background "#d7d7d7" :foreground "black")
992 (((class color) (background dark))
993 :background "#65a7e2" :foreground "black"))))
994
995 (use-package swiper
996 :demand
997 :after ivy
998 :bind (("C-S-s" . swiper-isearch)))
999
1000 (use-package counsel
1001 :demand
1002 :after ivy
1003 :bind (("C-c f r" . counsel-recentf)
1004 :map minibuffer-local-map
1005 ("C-r" . counsel-minibuffer-history))
1006 :config
1007 (counsel-mode 1)
1008 (defalias 'locate #'counsel-locate))
1009
1010 (use-package eshell
1011 :defer 0.5
1012 :commands eshell
1013 :bind ("C-c a s e" . eshell)
1014 :config
1015 (eval-when-compile (defvar eshell-prompt-regexp))
1016 (defun b/eshell-quit-or-delete-char (arg)
1017 (interactive "p")
1018 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
1019 (eshell-life-is-too-much)
1020 (delete-char arg)))
1021
1022 (defun b/eshell-clear ()
1023 (interactive)
1024 (let ((inhibit-read-only t))
1025 (erase-buffer))
1026 (eshell-send-input))
1027
1028 (defun b/eshell-setup ()
1029 (make-local-variable 'company-idle-delay)
1030 (defvar company-idle-delay)
1031 (setq company-idle-delay nil)
1032 (bind-keys :map eshell-mode-map
1033 ("C-d" . b/eshell-quit-or-delete-char)
1034 ("C-S-l" . b/eshell-clear)
1035 ("M-r" . counsel-esh-history)
1036 ;; ([tab] . company-complete)
1037 )
1038 (if (version< "27" emacs-version)
1039 (bind-keys :map eshell-hist-mode-map
1040 ("M-r" . counsel-esh-history))
1041 (bind-keys :map eshell-mode-map
1042 ("M-r" . counsel-esh-history))))
1043
1044 (setq
1045 eshell-prompt-regexp "\\(.*\n\\)*[$#] "
1046 eshell-prompt-function
1047 (lambda ()
1048 (concat
1049 (propertize (format "%s@%s:" (user-login-name) (system-name))
1050 'face 'default)
1051 (propertize (abbreviate-file-name default-directory)
1052 'face 'font-lock-comment-face)
1053 (propertize "\n" 'face 'default)
1054 (if (= (user-uid) 0)
1055 (propertize "#" 'face 'red)
1056 (propertize "$" 'face 'default))
1057 (propertize " " 'face 'default))))
1058
1059 :hook (eshell-mode . b/eshell-setup)
1060 :custom
1061 (eshell-hist-ignoredups t)
1062 (eshell-input-filter 'eshell-input-filter-initial-space))
1063
1064 (use-package ibuffer
1065 :bind
1066 (("C-x C-b" . ibuffer)
1067 :map ibuffer-mode-map
1068 ("P" . ibuffer-backward-filter-group)
1069 ("N" . ibuffer-forward-filter-group)
1070 ("M-p" . ibuffer-do-print)
1071 ("M-n" . ibuffer-do-shell-command-pipe-replace))
1072 :config
1073 ;; Use human readable Size column instead of original one
1074 (define-ibuffer-column size-h
1075 (:name "Size" :inline t)
1076 (cond
1077 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
1078 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
1079 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
1080 (t (format "%8d" (buffer-size)))))
1081 :custom
1082 (ibuffer-saved-filter-groups
1083 '(("default"
1084 ("dired" (mode . dired-mode))
1085 ("org" (mode . org-mode))
1086 ("gnus"
1087 (or
1088 (mode . gnus-group-mode)
1089 (mode . gnus-summary-mode)
1090 (mode . gnus-article-mode)
1091 ;; not really, but...
1092 (mode . message-mode)))
1093 ("web"
1094 (or
1095 ;; (mode . web-mode)
1096 (mode . mhtml-mode)
1097 (mode . css-mode)
1098 (mode . scss-mode)
1099 (mode . js2-mode)))
1100 ("shell"
1101 (or
1102 (mode . eshell-mode)
1103 (mode . shell-mode)
1104 (mode . term-mode)))
1105 ("programming"
1106 (or
1107 (mode . python-mode)
1108 (mode . c-mode)
1109 (mode . c++-mode)
1110 (mode . java-mode)
1111 (mode . emacs-lisp-mode)
1112 (mode . scheme-mode)
1113 (mode . haskell-mode)
1114 (mode . lean-mode)
1115 ;; (mode . go-mode)
1116 (mode . alloy-mode)))
1117 ("tex"
1118 (or
1119 (mode . bibtex-mode)
1120 (mode . latex-mode)))
1121 ("emacs"
1122 (or
1123 (name . "^\\*scratch\\*$")
1124 (name . "^\\*Messages\\*$")))
1125 ("exwm" (mode . exwm-mode))
1126 ("erc" (mode . erc-mode)))))
1127 (ibuffer-formats
1128 '((mark modified read-only locked " "
1129 (name 72 72 :left :elide)
1130 " "
1131 (size-h 9 -1 :right)
1132 " "
1133 (mode 16 16 :left :elide)
1134 " " filename-and-process)
1135 (mark " "
1136 (name 16 -1)
1137 " " filename)))
1138 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1139
1140 (use-package outline
1141 :disabled
1142 :hook (prog-mode . outline-minor-mode)
1143 :bind
1144 (:map
1145 outline-minor-mode-map
1146 ("<s-tab>" . outline-toggle-children)
1147 ("M-p" . outline-previous-visible-heading)
1148 ("M-n" . outline-next-visible-heading)
1149 :prefix-map b/outline-prefix-map
1150 :prefix "s-O"
1151 ("TAB" . outline-toggle-children)
1152 ("a" . outline-hide-body)
1153 ("H" . outline-hide-body)
1154 ("S" . outline-show-all)
1155 ("h" . outline-hide-subtree)
1156 ("s" . outline-show-subtree)))
1157
1158 (use-package ls-lisp
1159 :custom (ls-lisp-dirs-first t))
1160
1161 (use-package dired
1162 :config
1163 (setq dired-dwim-target t
1164 dired-listing-switches "-alh"
1165 ls-lisp-use-insert-directory-program nil)
1166
1167 ;; easily diff 2 marked files
1168 ;; https://oremacs.com/2017/03/18/dired-ediff/
1169 (defun dired-ediff-files ()
1170 (interactive)
1171 (require 'dired-aux)
1172 (defvar ediff-after-quit-hook-internal)
1173 (let ((files (dired-get-marked-files))
1174 (wnd (current-window-configuration)))
1175 (if (<= (length files) 2)
1176 (let ((file1 (car files))
1177 (file2 (if (cdr files)
1178 (cadr files)
1179 (read-file-name
1180 "file: "
1181 (dired-dwim-target-directory)))))
1182 (if (file-newer-than-file-p file1 file2)
1183 (ediff-files file2 file1)
1184 (ediff-files file1 file2))
1185 (add-hook 'ediff-after-quit-hook-internal
1186 (lambda ()
1187 (setq ediff-after-quit-hook-internal nil)
1188 (set-window-configuration wnd))))
1189 (error "no more than 2 files should be marked"))))
1190
1191 (require 'dired-x)
1192 (setq dired-guess-shell-alist-user
1193 '(("\\.pdf\\'" "evince" "zathura" "okular")
1194 ("\\.doc\\'" "libreoffice")
1195 ("\\.docx\\'" "libreoffice")
1196 ("\\.ppt\\'" "libreoffice")
1197 ("\\.pptx\\'" "libreoffice")
1198 ("\\.xls\\'" "libreoffice")
1199 ("\\.xlsx\\'" "libreoffice")
1200 ("\\.flac\\'" "mpv")))
1201 :bind (:map dired-mode-map
1202 ("b" . dired-up-directory)
1203 ("E" . dired-ediff-files)
1204 ("e" . dired-toggle-read-only)
1205 ("\\" . dired-hide-details-mode)
1206 ("z" . (lambda ()
1207 (interactive)
1208 (b/dired-start-process "zathura"))))
1209 :hook (dired-mode . dired-hide-details-mode))
1210
1211 (use-package help
1212 :config
1213 (temp-buffer-resize-mode)
1214 (setq help-window-select t))
1215
1216 (use-package tramp
1217 :config
1218 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1219 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1220 (add-to-list 'tramp-default-proxies-alist
1221 (list (regexp-quote (system-name)) nil nil)))
1222
1223 (use-package doc-view
1224 :bind (:map doc-view-mode-map
1225 ("M-RET" . image-previous-line)))
1226
1227 \f
1228 ;;; Editing
1229
1230 ;; highlight uncommitted changes in the left fringe
1231 (use-package diff-hl
1232 :defer 0.6
1233 :config
1234 (setq diff-hl-draw-borders nil)
1235 (global-diff-hl-mode)
1236 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
1237
1238 ;; display Lisp objects at point in the echo area
1239 (use-package eldoc
1240 :when (version< "25" emacs-version)
1241 :config (global-eldoc-mode))
1242
1243 ;; highlight matching parens
1244 (use-package paren
1245 :demand
1246 :config (show-paren-mode))
1247
1248 (use-package elec-pair
1249 :demand
1250 :config (electric-pair-mode))
1251
1252 (use-package simple
1253 :config (column-number-mode)
1254 :custom
1255 ;; Save what I copy into clipboard from other applications into Emacs'
1256 ;; kill-ring, which would allow me to still be able to easily access
1257 ;; it in case I kill (cut or copy) something else inside Emacs before
1258 ;; yanking (pasting) what I'd originally intended to.
1259 (save-interprogram-paste-before-kill t))
1260
1261 ;; save minibuffer history
1262 (use-package savehist
1263 :demand
1264 :config
1265 (savehist-mode)
1266 (add-to-list 'savehist-additional-variables 'kill-ring))
1267
1268 ;; automatically save place in files
1269 (use-package saveplace
1270 :when (version< "25" emacs-version)
1271 :config (save-place-mode))
1272
1273 (use-package prog-mode
1274 :config (global-prettify-symbols-mode)
1275 (defun indicate-buffer-boundaries-left ()
1276 (setq indicate-buffer-boundaries 'left))
1277 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1278
1279 (use-package text-mode
1280 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
1281 :hook ((text-mode . indicate-buffer-boundaries-left)
1282 (text-mode . flyspell-mode)))
1283
1284 (use-package conf-mode
1285 :mode "\\.*rc$")
1286
1287 (use-package sh-mode
1288 :mode "\\.bashrc$")
1289
1290 (use-package company
1291 :disabled
1292 :bind
1293 (:map company-active-map
1294 ([tab] . company-complete-common-or-cycle)
1295 ([escape] . company-abort)
1296 ("C-p" . company-select-previous-or-abort)
1297 ("C-n" . company-select-next-or-abort))
1298 :custom
1299 (company-minimum-prefix-length 1)
1300 (company-selection-wrap-around t)
1301 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1302 (company-dabbrev-downcase nil)
1303 (company-dabbrev-ignore-case nil)
1304 ;; :config
1305 ;; (global-company-mode t)
1306 )
1307
1308 (use-package flycheck
1309 :defer 0.6
1310 :hook (prog-mode . flycheck-mode)
1311 :bind
1312 (:map flycheck-mode-map
1313 ("M-P" . flycheck-previous-error)
1314 ("M-N" . flycheck-next-error))
1315 :config
1316 ;; Use the load-path from running Emacs when checking elisp files
1317 (setq flycheck-emacs-lisp-load-path 'inherit)
1318
1319 ;; Only flycheck when I actually save the buffer
1320 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1321 :custom (flycheck-mode-line-prefix "flyc"))
1322
1323 (use-package flyspell)
1324
1325 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1326 (use-package ispell
1327 :defer 0.6
1328 :config
1329 ;; ’ can be part of a word
1330 (setq ispell-local-dictionary-alist
1331 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1332 "['\x2019]" nil ("-B") nil utf-8))
1333 ispell-program-name (executable-find "hunspell"))
1334 ;; don't send ’ to the subprocess
1335 (defun endless/replace-apostrophe (args)
1336 (cons (replace-regexp-in-string
1337 "’" "'" (car args))
1338 (cdr args)))
1339 (advice-add #'ispell-send-string :filter-args
1340 #'endless/replace-apostrophe)
1341
1342 ;; convert ' back to ’ from the subprocess
1343 (defun endless/replace-quote (args)
1344 (if (not (derived-mode-p 'org-mode))
1345 args
1346 (cons (replace-regexp-in-string
1347 "'" "’" (car args))
1348 (cdr args))))
1349 (advice-add #'ispell-parse-output :filter-args
1350 #'endless/replace-quote))
1351
1352 (use-package abbrev
1353 :hook (text-mode . abbrev-mode))
1354
1355 \f
1356 ;;; Programming modes
1357
1358 (use-package lisp-mode
1359 :config
1360 (defun indent-spaces-mode ()
1361 (setq indent-tabs-mode nil))
1362 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1363
1364 (use-package reveal
1365 :hook (emacs-lisp-mode . reveal-mode))
1366
1367 (use-package elisp-mode)
1368
1369 ;; (use-package alloy-mode
1370 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
1371 ;; :mode "\\.\\(als\\|dsh\\)\\'"
1372 ;; :config
1373 ;; (setq alloy-basic-offset 2)
1374 ;; ;; (defun b/alloy-simple-indent (start end)
1375 ;; ;; (interactive "r")
1376 ;; ;; ;; (if (region-active-p)
1377 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
1378 ;; ;; ;; (if (bolp)
1379 ;; ;; ;; (indent-rigidly (line-beginning-position)
1380 ;; ;; ;; (line-end-position)
1381 ;; ;; ;; alloy-basic-offset)))
1382 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
1383 ;; :bind (:map alloy-mode-map
1384 ;; ("RET" . electric-newline-and-maybe-indent)
1385 ;; ;; ("TAB" . b/alloy-simple-indent)
1386 ;; ("TAB" . indent-for-tab-command))
1387 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
1388
1389 (eval-when-compile (defvar lean-mode-map))
1390 (use-package lean-mode
1391 :defer 0.4
1392 :bind (:map lean-mode-map
1393 ("S-SPC" . company-complete))
1394 :config
1395 (require 'lean-input)
1396 (setq default-input-method "Lean"
1397 lean-input-tweak-all '(lean-input-compose
1398 (lean-input-prepend "/")
1399 (lean-input-nonempty))
1400 lean-input-user-translations '(("/" "/")))
1401 (lean-input-setup))
1402
1403 (use-package mhtml-mode)
1404
1405 (use-package sgml-mode
1406 :config
1407 (setq sgml-basic-offset 0))
1408
1409 (use-package css-mode
1410 :config
1411 (setq css-indent-offset 2))
1412
1413 (use-package emmet-mode
1414 :after (:any mhtml-mode css-mode sgml-mode)
1415 :bind* (("C-)" . emmet-next-edit-point)
1416 ("C-(" . emmet-prev-edit-point))
1417 :config
1418 (unbind-key "C-j" emmet-mode-keymap)
1419 (setq emmet-move-cursor-between-quotes t)
1420 :hook (css-mode html-mode sgml-mode))
1421
1422 (use-package geiser)
1423
1424 (use-package geiser-guile
1425 :config
1426 (setq geiser-guile-load-path "~/src/git/guix"))
1427
1428 (use-package guix)
1429
1430 (comment
1431 (use-package auctex
1432 :custom
1433 (font-latex-fontify-sectioning 'color)))
1434
1435 (use-package go-mode
1436 :disabled)
1437
1438 (use-package po-mode
1439 :hook
1440 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1441
1442 (use-package tex-mode
1443 :config
1444 (cl-delete-if
1445 (lambda (p) (string-match "^---?" (car p)))
1446 tex--prettify-symbols-alist)
1447 :hook ((tex-mode . auto-fill-mode)
1448 (tex-mode . flyspell-mode)))
1449
1450 ;; (use-package george-mode
1451 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
1452 ;; :mode "\\.grg\\'")
1453
1454 \f
1455 ;;; Theme
1456
1457 (add-to-list 'custom-theme-load-path
1458 (expand-file-name
1459 (convert-standard-filename "lisp") user-emacs-directory))
1460 (load-theme 'tangomod t)
1461
1462 (use-package smart-mode-line
1463 :commands (sml/apply-theme)
1464 :demand
1465 :config
1466 ;; thanks, but no thnaks; don't make fixed-width fills.
1467 (defun sml/fill-for-buffer-identification () "")
1468 (setq sml/theme 'tangomod)
1469 (sml/setup)
1470 (smart-mode-line-enable))
1471
1472 (use-package doom-modeline
1473 :disabled
1474 :demand
1475 :hook (after-init . doom-modeline-init)
1476 :custom
1477 (doom-modeline-buffer-file-name-style 'relative-to-project))
1478
1479 (use-package doom-themes)
1480
1481 (use-package moody
1482 :disabled
1483 :demand
1484 :config
1485 (setq x-underline-at-descent-line t)
1486 (let ((line (face-attribute 'mode-line :underline)))
1487 (set-face-attribute 'mode-line nil :overline line)
1488 (set-face-attribute 'mode-line-inactive nil :overline line)
1489 (set-face-attribute 'mode-line-inactive nil :underline line)
1490 (set-face-attribute 'mode-line nil :box nil)
1491 (set-face-attribute 'mode-line-inactive nil :box nil)
1492 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
1493 (moody-replace-mode-line-buffer-identification)
1494 (moody-replace-vc-mode))
1495
1496 (use-package mini-modeline
1497 :disabled
1498 :demand
1499 :config (mini-modeline-mode))
1500
1501 (defvar b/org-mode-font-lock-keywords
1502 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1503 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1504 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1505 (4 '(:foreground "#c5c8c6") t))) ; title
1506 "For use with the `doom-tomorrow-night' theme.")
1507
1508 (defun b/lights-on ()
1509 "Enable my favourite light theme."
1510 (interactive)
1511 (mapc #'disable-theme custom-enabled-themes)
1512 (load-theme 'tangomod t)
1513 (when (featurep 'smart-mode-line)
1514 (sml/apply-theme 'tangomod))
1515 (font-lock-remove-keywords
1516 'org-mode b/org-mode-font-lock-keywords)
1517 (when (featurep 'erc-hl-nicks)
1518 (erc-hl-nicks-reset-face-table))
1519 (when (featurep 'exwm-systemtray)
1520 (exwm-systemtray--refresh)))
1521
1522 (defun b/lights-off ()
1523 "Go dark."
1524 (interactive)
1525 (mapc #'disable-theme custom-enabled-themes)
1526 (load-theme 'doom-one t)
1527 (when (featurep 'smart-mode-line)
1528 (sml/apply-theme 'automatic))
1529 (font-lock-add-keywords
1530 'org-mode b/org-mode-font-lock-keywords t)
1531 (when (featurep 'erc-hl-nicks)
1532 (erc-hl-nicks-reset-face-table))
1533 (when (featurep 'exwm-systemtray)
1534 (exwm-systemtray--refresh)))
1535
1536 (bind-keys
1537 ("C-c t d" . b/lights-off)
1538 ("C-c t l" . b/lights-on))
1539
1540 \f
1541 ;;; Emacs enhancements & auxiliary packages
1542
1543 (use-package man
1544 :config (setq Man-width 80))
1545
1546 (use-package which-key
1547 :defer 0.4
1548 :config
1549 (which-key-add-key-based-replacements
1550 ;; prefixes for global prefixes and minor modes
1551 "C-c @" "outline"
1552 "C-c !" "flycheck"
1553 "C-x RET" "coding system"
1554 "C-x 8" "unicode"
1555 "C-x @" "event modifiers"
1556 "C-x a" "abbrev/expand"
1557 "C-x r" "rectangle/register/bookmark"
1558 "C-x t" "tabs"
1559 "C-x v" "version control"
1560 "C-x X" "edebug"
1561 "C-x C-a" "edebug"
1562 "C-x C-k" "kmacro"
1563 ;; prefixes for my personal bindings
1564 "C-c &" "yasnippet"
1565 "C-c a" "applications"
1566 "C-c a e" "erc"
1567 "C-c a o" "org"
1568 "C-c a s" "shells"
1569 "C-c b" "buffers"
1570 "C-c c" "compile-and-comments"
1571 "C-c e" "eval"
1572 "C-c f" "files"
1573 "C-c F" "frames"
1574 "C-c g" "magit"
1575 "C-S-h" "help(ful)"
1576 "C-c m" "multiple-cursors"
1577 "C-c p" "projectile"
1578 "C-c p s" "projectile/search"
1579 "C-c p x" "projectile/execute"
1580 "C-c p 4" "projectile/other-window"
1581 "C-c q" "boxquote"
1582 "C-c t" "themes"
1583 ;; "s-O" "outline"
1584 )
1585
1586 ;; prefixes for major modes
1587 (which-key-add-major-mode-key-based-replacements 'message-mode
1588 "C-c f n" "footnote")
1589 (which-key-add-major-mode-key-based-replacements 'org-mode
1590 "C-c C-v" "org-babel")
1591
1592 (which-key-mode)
1593 :custom
1594 (which-key-add-column-padding 5)
1595 (which-key-max-description-length 32))
1596
1597 (use-package crux ; results in Waiting for git... [2 times]
1598 :defer 0.4
1599 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1600 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1601 ("C-c f C" . crux-copy-file-preserve-attributes)
1602 ("C-c f D" . crux-delete-file-and-buffer)
1603 ("C-c f R" . crux-rename-file-and-buffer)
1604 ("C-c j" . crux-top-join-line)
1605 ("C-S-j" . crux-top-join-line)))
1606
1607 (use-package mwim
1608 :bind (("C-a" . mwim-beginning-of-code-or-line)
1609 ("C-e" . mwim-end-of-code-or-line)
1610 ("<home>" . mwim-beginning-of-line-or-code)
1611 ("<end>" . mwim-end-of-line-or-code)))
1612
1613 (use-package projectile
1614 :disabled
1615 :defer 0.5
1616 :bind-keymap ("C-c p" . projectile-command-map)
1617 :config
1618 (projectile-mode)
1619
1620 (defun b/projectile-mode-line-fun ()
1621 "Report project name and type in the modeline."
1622 (let ((project-name (projectile-project-name))
1623 (project-type (projectile-project-type)))
1624 (format "%s%s"
1625 projectile-mode-line-prefix
1626 (if project-type
1627 (format ":%s" project-type)
1628 ""))))
1629 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1630
1631 (defun my-projectile-invalidate-cache (&rest _args)
1632 ;; ignore the args to `magit-checkout'
1633 (projectile-invalidate-cache nil))
1634
1635 (eval-after-load 'magit-branch
1636 '(progn
1637 (advice-add 'magit-checkout
1638 :after #'my-projectile-invalidate-cache)
1639 (advice-add 'magit-branch-and-checkout
1640 :after #'my-projectile-invalidate-cache)))
1641 :custom
1642 (projectile-completion-system 'ivy)
1643 (projectile-mode-line-prefix " proj"))
1644
1645 (use-package helpful
1646 :defer 0.6
1647 :bind
1648 (("C-S-h c" . helpful-command)
1649 ("C-S-h f" . helpful-callable) ; helpful-function
1650 ("C-S-h v" . helpful-variable)
1651 ("C-S-h k" . helpful-key)
1652 ("C-S-h p" . helpful-at-point)))
1653
1654 (use-package unkillable-scratch
1655 :defer 0.6
1656 :config
1657 (unkillable-scratch 1)
1658 :custom
1659 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1660
1661 ;; ,----
1662 ;; | make pretty boxed quotes like this
1663 ;; `----
1664 (use-package boxquote
1665 :defer 0.6
1666 :bind
1667 (:prefix-map b/boxquote-prefix-map
1668 :prefix "C-c q"
1669 ("b" . boxquote-buffer)
1670 ("B" . boxquote-insert-buffer)
1671 ("d" . boxquote-defun)
1672 ("F" . boxquote-insert-file)
1673 ("hf" . boxquote-describe-function)
1674 ("hk" . boxquote-describe-key)
1675 ("hv" . boxquote-describe-variable)
1676 ("hw" . boxquote-where-is)
1677 ("k" . boxquote-kill)
1678 ("p" . boxquote-paragraph)
1679 ("q" . boxquote-boxquote)
1680 ("r" . boxquote-region)
1681 ("s" . boxquote-shell-command)
1682 ("t" . boxquote-text)
1683 ("T" . boxquote-title)
1684 ("u" . boxquote-unbox)
1685 ("U" . boxquote-unbox-region)
1686 ("y" . boxquote-yank)
1687 ("M-q" . boxquote-fill-paragraph)
1688 ("M-w" . boxquote-kill-ring-save)))
1689
1690 (use-package orgalist
1691 ;; breaks auto-fill-mode, showing this error:
1692 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1693 :disabled
1694 :after message
1695 :hook (message-mode . orgalist-mode))
1696
1697 ;; highlight TODOs in buffers
1698 (use-package hl-todo
1699 :defer 0.5
1700 :config
1701 (global-hl-todo-mode))
1702
1703 (use-package multi-term
1704 :disabled
1705 :defer 0.6
1706 :bind (("C-c a s m m" . multi-term)
1707 ("C-c a s m d" . multi-term-dedicated-toggle)
1708 ("C-c a s m p" . multi-term-prev)
1709 ("C-c a s m n" . multi-term-next)
1710 :map term-mode-map
1711 ("C-c C-j" . term-char-mode))
1712 :config
1713 (setq multi-term-program "screen"
1714 multi-term-program-switches (concat "-c"
1715 (getenv "XDG_CONFIG_HOME")
1716 "/screen/screenrc")
1717 ;; TODO: add separate bindings for connecting to existing
1718 ;; session vs. always creating a new one
1719 multi-term-dedicated-select-after-open-p t
1720 multi-term-dedicated-window-height 20
1721 multi-term-dedicated-max-window-height 30
1722 term-bind-key-alist
1723 '(("C-c C-c" . term-interrupt-subjob)
1724 ("C-c C-e" . term-send-esc)
1725 ("C-c C-j" . term-line-mode)
1726 ("C-k" . kill-line)
1727 ;; ("C-y" . term-paste)
1728 ("C-y" . term-send-raw)
1729 ("M-f" . term-send-forward-word)
1730 ("M-b" . term-send-backward-word)
1731 ("M-p" . term-send-up)
1732 ("M-n" . term-send-down)
1733 ("M-j" . term-send-raw-meta)
1734 ("M-y" . term-send-raw-meta)
1735 ("M-/" . term-send-raw-meta)
1736 ("M-0" . term-send-raw-meta)
1737 ("M-1" . term-send-raw-meta)
1738 ("M-2" . term-send-raw-meta)
1739 ("M-3" . term-send-raw-meta)
1740 ("M-4" . term-send-raw-meta)
1741 ("M-5" . term-send-raw-meta)
1742 ("M-6" . term-send-raw-meta)
1743 ("M-7" . term-send-raw-meta)
1744 ("M-8" . term-send-raw-meta)
1745 ("M-9" . term-send-raw-meta)
1746 ("<C-backspace>" . term-send-backward-kill-word)
1747 ("<M-DEL>" . term-send-backward-kill-word)
1748 ("M-d" . term-send-delete-word)
1749 ("M-," . term-send-raw)
1750 ("M-." . comint-dynamic-complete))
1751 term-unbind-key-alist
1752 '("C-z" "C-x" "C-c" "C-h"
1753 ;; "C-y"
1754 "<ESC>")))
1755
1756 (use-package page-break-lines
1757 :defer 0.5
1758 :custom
1759 (page-break-lines-max-width fill-column)
1760 :config
1761 (global-page-break-lines-mode))
1762
1763 (use-package expand-region
1764 :bind ("C-=" . er/expand-region))
1765
1766 (use-package multiple-cursors
1767 :bind
1768 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1769 (:prefix-map b/mc-prefix-map
1770 :prefix "C-c m"
1771 ("c" . mc/edit-lines)
1772 ("n" . mc/mark-next-like-this)
1773 ("p" . mc/mark-previous-like-this)
1774 ("a" . mc/mark-all-like-this))))
1775
1776 (use-package yasnippet
1777 :defer 0.6
1778 :config
1779 (defconst yas-verbosity-cur yas-verbosity)
1780 (setq yas-verbosity 2)
1781 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1782 (yas-reload-all)
1783 (setq yas-verbosity yas-verbosity-cur)
1784
1785 (defun b/yas--maybe-expand-key-filter (cmd)
1786 (when (and (yas--maybe-expand-key-filter cmd)
1787 (not (bound-and-true-p git-commit-mode)))
1788 cmd))
1789 (defconst b/yas-maybe-expand
1790 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1791 (define-key yas-minor-mode-map
1792 (kbd "SPC") b/yas-maybe-expand)
1793
1794 (yas-global-mode))
1795
1796 (use-package debbugs
1797 :bind
1798 (("C-c D d" . debbugs-gnu)
1799 ("C-c D b" . debbugs-gnu-bugs)
1800 ("C-c D e" .
1801 (lambda ()
1802 (interactive) ; bug-gnu-emacs
1803 (setq debbugs-gnu-current-suppress t)
1804 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1805 ("C-c D g" . ; bug-gnuzilla
1806 (lambda ()
1807 (interactive)
1808 (setq debbugs-gnu-current-suppress t)
1809 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1810 ("C-c D G b" . ; bug-guix
1811 (lambda ()
1812 (interactive)
1813 (setq debbugs-gnu-current-suppress t)
1814 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1815 ("C-c D G p" . ; guix-patches
1816 (lambda ()
1817 (interactive)
1818 (setq debbugs-gnu-current-suppress t)
1819 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1820
1821 (use-package org-ref
1822 :init
1823 (b/setq-every '("~/usr/org/references.bib")
1824 reftex-default-bibliography
1825 org-ref-default-bibliography)
1826 (setq
1827 org-ref-bibliography-notes "~/usr/org/notes.org"
1828 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1829
1830 ;; (use-package fill-column-indicator)
1831
1832 (use-package window
1833 :bind
1834 (("C-c w e" . (lambda ()
1835 (interactive)
1836 (split-window-right)
1837 (other-window 1)
1838 (erc-switch-to-buffer)))
1839 ("C-c w s l" . (lambda ()
1840 (interactive)
1841 (split-window-right)
1842 (other-window 1)))
1843 ("C-c w s j" . (lambda ()
1844 (interactive)
1845 (split-window-below)
1846 (other-window 1)))
1847 ("C-c w q" . quit-window))
1848 :custom
1849 (split-width-threshold 150))
1850
1851 (use-package windmove
1852 :defer 0.6
1853 :bind
1854 (("C-c w h" . windmove-left)
1855 ("C-c w j" . windmove-down)
1856 ("C-c w k" . windmove-up)
1857 ("C-c w l" . windmove-right)
1858 ("C-c w H" . windmove-swap-states-left)
1859 ("C-c w J" . windmove-swap-states-down)
1860 ("C-c w K" . windmove-swap-states-up)
1861 ("C-c w L" . windmove-swap-states-right)))
1862
1863 (use-package pass
1864 :commands pass
1865 :bind ("C-c a p" . pass)
1866 :hook (pass-mode . View-exit))
1867
1868 (use-package pdf-tools
1869 :defer 0.5
1870 :bind (:map pdf-view-mode-map
1871 ("<C-XF86Back>" . pdf-history-backward)
1872 ("<mouse-8>" . pdf-history-backward)
1873 ("<drag-mouse-8>" . pdf-history-backward)
1874 ("<C-XF86Forward>" . pdf-history-forward)
1875 ("<mouse-9>" . pdf-history-forward)
1876 ("<drag-mouse-9>" . pdf-history-forward)
1877 ("M-RET" . image-previous-line)
1878 ("C-s" . isearch-forward)
1879 ("s s" . isearch-forward))
1880 :config (pdf-tools-install nil t)
1881 :custom (pdf-view-resize-factor 1.05))
1882
1883 (use-package org-pdftools
1884 :disabled
1885 :straight (:host github :repo "fuxialexander/org-pdftools")
1886 :demand
1887 :after org
1888 :config
1889 (with-eval-after-load 'org
1890 (require 'org-pdftools)))
1891
1892 (use-package biblio)
1893
1894 (use-package reftex
1895 :hook (latex-mode . reftex-mode))
1896
1897 (use-package reftex-cite
1898 :after reftex
1899 :disabled ; enable to disable
1900 ; reftex-cite's default choice
1901 ; of previous word
1902 :config
1903 (defun reftex-get-bibkey-default ()
1904 "If the cursor is in a citation macro, return the word before the macro."
1905 (let* ((macro (reftex-what-macro 1)))
1906 (save-excursion
1907 (when (and macro (string-match "cite" (car macro)))
1908 (goto-char (cdr macro)))
1909 (reftex-this-word)))))
1910
1911 (use-package minions
1912 :demand
1913 :config (minions-mode))
1914
1915 (use-package dmenu
1916 :custom
1917 (dmenu-prompt-string "run: ")
1918 (dmenu-save-file (b/var "dmenu-items")))
1919
1920 (use-package eosd
1921 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1922 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1923 :disabled
1924 :straight (:host github :repo "clarete/eosd")
1925 :demand
1926 :after exwm
1927 :config
1928 (eosd-start))
1929
1930 (use-package scpaste
1931 :disabled
1932 :config
1933 (setq scpaste-http-destination "https://p.bndl.org"
1934 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1935
1936 (use-package eww
1937 :bind ("C-c a e w" . eww)
1938 :custom
1939 (eww-download-directory (file-name-as-directory
1940 (getenv "XDG_DOWNLOAD_DIR"))))
1941
1942 \f
1943 ;;; Email (with Gnus)
1944
1945 (defvar b/maildir (expand-file-name "~/mail/"))
1946 (with-eval-after-load 'recentf
1947 (add-to-list 'recentf-exclude b/maildir))
1948
1949 (setq
1950 b/gnus-init-file (b/etc "gnus")
1951 mail-user-agent 'gnus-user-agent
1952 read-mail-command 'gnus)
1953
1954 (use-package gnus
1955 :bind (("s-m" . gnus-plugged)
1956 ("s-M" . gnus-unplugged)
1957 ("C-c a m" . gnus-plugged)
1958 ("C-c a M" . gnus-unplugged))
1959 :init
1960 (setq
1961 gnus-select-method '(nnnil "")
1962 gnus-secondary-select-methods
1963 '((nnimap "shemshak"
1964 (nnimap-stream plain)
1965 (nnimap-address "127.0.0.1")
1966 (nnimap-server-port 143)
1967 (nnimap-authenticator plain)
1968 (nnimap-user "amin@shemshak.local"))
1969 (nnimap "gnu"
1970 (nnimap-stream plain)
1971 (nnimap-address "127.0.0.1")
1972 (nnimap-server-port 143)
1973 (nnimap-authenticator plain)
1974 (nnimap-user "bandali@gnu.local")
1975 (nnimap-inbox "INBOX")
1976 (nnimap-split-methods 'nnimap-split-fancy)
1977 (nnimap-split-fancy (|
1978 ;; (: gnus-registry-split-fancy-with-parent)
1979 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1980 ;; gnu
1981 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1982 ;; gnus
1983 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
1984 ;; libreplanet
1985 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
1986 ;; *.lists.sr.ht, omitting one dot if present
1987 ;; add more \\.?\\([^.]*\\) if needed
1988 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
1989 ;; webmasters
1990 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1991 ;; other
1992 (list ".*atreus.freelists.org" "l.atreus")
1993 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1994 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1995 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1996 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1997 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1998 ;; ----------------------------------
1999 ;; legend: (u)nsubscribed | (d)ead
2000 ;; ----------------------------------
2001 ;; otherwise, leave mail in INBOX
2002 "INBOX")))
2003 (nnimap "uw"
2004 (nnimap-stream plain)
2005 (nnimap-address "127.0.0.1")
2006 (nnimap-server-port 143)
2007 (nnimap-authenticator plain)
2008 (nnimap-user "abandali@uw.local")
2009 (nnimap-inbox "INBOX")
2010 (nnimap-split-methods 'nnimap-split-fancy)
2011 (nnimap-split-fancy (|
2012 ;; (: gnus-registry-split-fancy-with-parent)
2013 ;; se212-f19
2014 ("subject" "SE\\s-?212" "course.se212-f19")
2015 (from "SE\\s-?212" "course.se212-f19")
2016 ;; catch-all
2017 "INBOX")))
2018 (nnimap "csc"
2019 (nnimap-stream plain)
2020 (nnimap-address "127.0.0.1")
2021 (nnimap-server-port 143)
2022 (nnimap-authenticator plain)
2023 (nnimap-user "abandali@csc.uw.local")))
2024 gnus-message-archive-group "nnimap+gnu:INBOX"
2025 gnus-parameters
2026 '(("l\\.atreus"
2027 (to-address . "atreus@freelists.org")
2028 (to-list . "atreus@freelists.org"))
2029 ("l\\.deepspec"
2030 (to-address . "deepspec@lists.cs.princeton.edu")
2031 (to-list . "deepspec@lists.cs.princeton.edu")
2032 (list-identifier . "\\[deepspec\\]"))
2033 ("l\\.emacs-devel"
2034 (to-address . "emacs-devel@gnu.org")
2035 (to-list . "emacs-devel@gnu.org"))
2036 ("l\\.help-gnu-emacs"
2037 (to-address . "help-gnu-emacs@gnu.org")
2038 (to-list . "help-gnu-emacs@gnu.org"))
2039 ("l\\.info-gnu-emacs"
2040 (to-address . "info-gnu-emacs@gnu.org")
2041 (to-list . "info-gnu-emacs@gnu.org"))
2042 ("l\\.emacs-orgmode"
2043 (to-address . "emacs-orgmode@gnu.org")
2044 (to-list . "emacs-orgmode@gnu.org")
2045 (list-identifier . "\\[O\\]"))
2046 ("l\\.emacs-tangents"
2047 (to-address . "emacs-tangents@gnu.org")
2048 (to-list . "emacs-tangents@gnu.org"))
2049 ("l\\.emacsconf-committee"
2050 (to-address . "emacsconf-committee@gnu.org")
2051 (to-list . "emacsconf-committee@gnu.org"))
2052 ("l\\.emacsconf-discuss"
2053 (to-address . "emacsconf-discuss@gnu.org")
2054 (to-list . "emacsconf-discuss@gnu.org"))
2055 ("l\\.emacsconf-register"
2056 (to-address . "emacsconf-register@gnu.org")
2057 (to-list . "emacsconf-register@gnu.org"))
2058 ("l\\.emacsconf-submit"
2059 (to-address . "emacsconf-submit@gnu.org")
2060 (to-list . "emacsconf-submit@gnu.org"))
2061 ("l\\.fencepost-users"
2062 (to-address . "fencepost-users@gnu.org")
2063 (to-list . "fencepost-users@gnu.org")
2064 (list-identifier . "\\[Fencepost-users\\]"))
2065 ("l\\.gnewsense-art"
2066 (to-address . "gnewsense-art@nongnu.org")
2067 (to-list . "gnewsense-art@nongnu.org")
2068 (list-identifier . "\\[gNewSense-art\\]"))
2069 ("l\\.gnewsense-dev"
2070 (to-address . "gnewsense-dev@nongnu.org")
2071 (to-list . "gnewsense-dev@nongnu.org")
2072 (list-identifier . "\\[Gnewsense-dev\\]"))
2073 ("l\\.gnewsense-users"
2074 (to-address . "gnewsense-users@nongnu.org")
2075 (to-list . "gnewsense-users@nongnu.org")
2076 (list-identifier . "\\[gNewSense-users\\]"))
2077 ("l\\.gnunet-developers"
2078 (to-address . "gnunet-developers@gnu.org")
2079 (to-list . "gnunet-developers@gnu.org")
2080 (list-identifier . "\\[GNUnet-developers\\]"))
2081 ("l\\.help-gnunet"
2082 (to-address . "help-gnunet@gnu.org")
2083 (to-list . "help-gnunet@gnu.org")
2084 (list-identifier . "\\[Help-gnunet\\]"))
2085 ("l\\.bug-gnuzilla"
2086 (to-address . "bug-gnuzilla@gnu.org")
2087 (to-list . "bug-gnuzilla@gnu.org")
2088 (list-identifier . "\\[Bug-gnuzilla\\]"))
2089 ("l\\.gnuzilla-dev"
2090 (to-address . "gnuzilla-dev@gnu.org")
2091 (to-list . "gnuzilla-dev@gnu.org")
2092 (list-identifier . "\\[Gnuzilla-dev\\]"))
2093 ("l\\.guile-devel"
2094 (to-address . "guile-devel@gnu.org")
2095 (to-list . "guile-devel@gnu.org"))
2096 ("l\\.guile-user"
2097 (to-address . "guile-user@gnu.org")
2098 (to-list . "guile-user@gnu.org"))
2099 ("l\\.guix-devel"
2100 (to-address . "guix-devel@gnu.org")
2101 (to-list . "guix-devel@gnu.org"))
2102 ("l\\.help-guix"
2103 (to-address . "help-guix@gnu.org")
2104 (to-list . "help-guix@gnu.org"))
2105 ("l\\.info-guix"
2106 (to-address . "info-guix@gnu.org")
2107 (to-list . "info-guix@gnu.org"))
2108 ("l\\.savannah-hackers-public"
2109 (to-address . "savannah-hackers-public@gnu.org")
2110 (to-list . "savannah-hackers-public@gnu.org"))
2111 ("l\\.savannah-users"
2112 (to-address . "savannah-users@gnu.org")
2113 (to-list . "savannah-users@gnu.org"))
2114 ("l\\.www-commits"
2115 (to-address . "www-commits@gnu.org")
2116 (to-list . "www-commits@gnu.org"))
2117 ("l\\.www-discuss"
2118 (to-address . "www-discuss@gnu.org")
2119 (to-list . "www-discuss@gnu.org"))
2120 ("l\\.haskell-art"
2121 (to-address . "haskell-art@we.lurk.org")
2122 (to-list . "haskell-art@we.lurk.org")
2123 (list-identifier . "\\[haskell-art\\]"))
2124 ("l\\.haskell-cafe"
2125 (to-address . "haskell-cafe@haskell.org")
2126 (to-list . "haskell-cafe@haskell.org")
2127 (list-identifier . "\\[Haskell-cafe\\]"))
2128 ("l\\.notmuch"
2129 (to-address . "notmuch@notmuchmail.org")
2130 (to-list . "notmuch@notmuchmail.org"))
2131 ("l\\.parabola-dev"
2132 (to-address . "dev@lists.parabola.nu")
2133 (to-list . "dev@lists.parabola.nu")
2134 (list-identifier . "\\[Dev\\]"))
2135 ("l\\.~bandali\\.public-inbox"
2136 (to-address . "~bandali/public-inbox@lists.sr.ht")
2137 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2138 ("l\\.~sircmpwn\\.free-writers-club"
2139 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2140 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2141 ("l\\.~sircmpwn\\.srht-admins"
2142 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2143 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2144 ("l\\.~sircmpwn\\.srht-announce"
2145 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2146 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2147 ("l\\.~sircmpwn\\.srht-dev"
2148 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2149 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2150 ("l\\.~sircmpwn\\.srht-discuss"
2151 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2152 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2153 ("webmasters"
2154 (to-address . "webmasters@gnu.org")
2155 (to-list . "webmasters@gnu.org"))
2156 ("gnu.*"
2157 (gcc-self . t))
2158 ("l\\."
2159 (subscribed . t))
2160 ("nnimap\\+uw:.*"
2161 (gcc-self . t)))
2162 gnus-large-newsgroup 50
2163 gnus-home-directory (b/var "gnus/")
2164 gnus-directory (concat gnus-home-directory "news/")
2165 message-directory (concat gnus-home-directory "mail/")
2166 nndraft-directory (concat gnus-home-directory "drafts/")
2167 gnus-save-newsrc-file nil
2168 gnus-read-newsrc-file nil
2169 gnus-interactive-exit nil
2170 gnus-gcc-mark-as-read t)
2171 :config
2172 (when (version< emacs-version "27")
2173 (with-eval-after-load 'nnmail
2174 (add-to-list
2175 'nnmail-split-abbrev-alist
2176 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2177 t)))
2178
2179 ;; (gnus-registry-initialize)
2180
2181 (with-eval-after-load 'recentf
2182 (add-to-list 'recentf-exclude gnus-home-directory)))
2183
2184 (use-package gnus-art
2185 :config
2186 (setq
2187 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2188 gnus-sorted-header-list '("^From:"
2189 "^X-RT-Originator"
2190 "^Newsgroups:"
2191 "^Subject:"
2192 "^Date:"
2193 "^Envelope-To:"
2194 "^Followup-To:"
2195 "^Reply-To:"
2196 "^Organization:"
2197 "^Summary:"
2198 "^Abstract:"
2199 "^Keywords:"
2200 "^To:"
2201 "^[BGF]?Cc:"
2202 "^Posted-To:"
2203 "^Mail-Copies-To:"
2204 "^Mail-Followup-To:"
2205 "^Apparently-To:"
2206 "^Resent-From:"
2207 "^User-Agent:"
2208 "^X-detected-operating-system:"
2209 "^Message-ID:"
2210 ;; "^References:"
2211 "^List-Id:"
2212 "^Gnus-Warning:")
2213 gnus-visible-headers (mapconcat 'identity
2214 gnus-sorted-header-list
2215 "\\|")
2216 ;; local-lapsed article dates
2217 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2218 gnus-article-date-headers '(user-defined)
2219 gnus-article-time-format
2220 (lambda (time)
2221 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2222 (local (article-make-date-line date 'local))
2223 (combined-lapsed (article-make-date-line date
2224 'combined-lapsed))
2225 (lapsed (progn
2226 (string-match " (.+" combined-lapsed)
2227 (match-string 0 combined-lapsed))))
2228 (concat local lapsed))))
2229 (bind-keys
2230 :map gnus-article-mode-map
2231 ("M-L" . org-store-link)))
2232
2233 (use-package gnus-sum
2234 :bind (:map gnus-summary-mode-map
2235 :prefix-map b/gnus-summary-prefix-map
2236 :prefix "v"
2237 ("r" . gnus-summary-reply)
2238 ("w" . gnus-summary-wide-reply)
2239 ("v" . gnus-summary-show-raw-article))
2240 :config
2241 (bind-keys
2242 :map gnus-summary-mode-map
2243 ("M-L" . org-store-link))
2244 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2245 :custom
2246 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2247 gnus-thread-sort-by-subject
2248 gnus-thread-sort-by-date)))
2249
2250 (use-package gnus-msg
2251 :config
2252 (defvar b/shemshak-signature "Amin Bandali
2253 https://shemshak.org/~amin")
2254 (defvar b/uw-signature "Amin Bandali, MMath Student
2255 Cheriton School of Computer Science
2256 University of Waterloo
2257 https://bandali.eu.org")
2258 (defvar b/csc-signature "Amin Bandali
2259 System Administrator, Systems Committee
2260 Computer Science Club, University of Waterloo
2261 https://csclub.uwaterloo.ca/~abandali")
2262 (setq gnus-message-replysign t
2263 gnus-posting-styles
2264 '((".*"
2265 (address "bandali@gnu.org"))
2266 ("nnimap\\+gnu:l\\..*"
2267 (signature nil))
2268 ("nnimap\\+gnu:.*"
2269 (organization "GNU"))
2270 ((header "subject" "ThankCRM")
2271 (to "webmasters-comment@gnu.org")
2272 (body "")
2273 (eval (setq b/message-cite-say-hi nil)))
2274 ("nnimap\\+shemshak:.*"
2275 (address "amin@shemshak.org")
2276 (body "\nBest,\n")
2277 (signature b/shemshak-signature)
2278 (gcc "nnimap+shemshak:Sent")
2279 (eval (setq b/message-cite-say-hi t)))
2280 ("nnimap\\+uw:.*"
2281 (address "bandali@uwaterloo.ca")
2282 (body "\nBest,\n")
2283 (signature b/uw-signature))
2284 ("nnimap\\+uw:INBOX"
2285 (gcc "\"nnimap+uw:Sent Items\""))
2286 ("nnimap\\+csc:.*"
2287 (address "bandali@csclub.uwaterloo.ca")
2288 (signature b/csc-signature)
2289 (gcc "nnimap+csc:Sent"))))
2290 :hook (gnus-message-setup . (lambda ()
2291 (unless (mml-secure-is-encrypted-p)
2292 (mml-secure-message-sign)))))
2293
2294 (use-package gnus-topic
2295 :hook (gnus-group-mode . gnus-topic-mode)
2296 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2297
2298 (use-package gnus-agent
2299 :config
2300 (setq gnus-agent-synchronize-flags 'ask)
2301 :hook (gnus-group-mode . gnus-agent-mode))
2302
2303 (use-package gnus-group
2304 :config
2305 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2306
2307 (comment
2308 ;; problematic with ebdb's popup, *EBDB-Gnus*
2309 (use-package gnus-win
2310 :config
2311 (setq gnus-use-full-window nil)))
2312
2313 (use-package gnus-dired
2314 :commands gnus-dired-mode
2315 :init
2316 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2317
2318 (comment
2319 (use-package gnus-utils
2320 :custom
2321 (gnus-completing-read-function 'gnus-ido-completing-read)))
2322
2323 (use-package mm-decode
2324 :config
2325 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2326 mm-decrypt-option 'known
2327 mm-verify-option 'known))
2328
2329 (use-package mm-uu
2330 :config
2331 (when (version< "27" emacs-version)
2332 (set-face-attribute 'mm-uu-extract nil :extend t))
2333 :custom
2334 (mm-uu-diff-groups-regexp
2335 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2336
2337 (use-package sendmail
2338 :config
2339 (setq sendmail-program (executable-find "msmtp")
2340 ;; message-sendmail-extra-arguments '("-v" "-d")
2341 mail-specify-envelope-from t
2342 mail-envelope-from 'header))
2343
2344 (use-package message
2345 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2346 :config
2347 ;; redefine for a simplified In-Reply-To header
2348 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2349 (defun message-make-in-reply-to ()
2350 "Return the In-Reply-To header for this message."
2351 (when message-reply-headers
2352 (let ((from (mail-header-from message-reply-headers))
2353 (msg-id (mail-header-id message-reply-headers)))
2354 (when from
2355 msg-id))))
2356
2357 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2358 (defconst message-cite-style-bandali
2359 '((message-cite-function 'message-cite-original)
2360 (message-citation-line-function 'message-insert-formatted-citation-line)
2361 (message-cite-reply-position 'traditional)
2362 (message-yank-prefix "> ")
2363 (message-yank-cited-prefix ">")
2364 (message-yank-empty-prefix ">")
2365 (message-citation-line-format
2366 (if b/message-cite-say-hi
2367 (concat "Hi %F,\n\n" b/message-cite-style-format)
2368 b/message-cite-style-format)))
2369 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2370 (setq ;; message-cite-style 'message-cite-style-bandali
2371 message-kill-buffer-on-exit t
2372 message-send-mail-function 'message-send-mail-with-sendmail
2373 message-sendmail-envelope-from 'header
2374 message-subscribed-address-functions
2375 '(gnus-find-subscribed-addresses)
2376 message-dont-reply-to-names
2377 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
2378 ;; (require 'company-ebdb)
2379 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2380 (message-mode . flyspell-mode)
2381 (message-mode . (lambda ()
2382 ;; (setq-local fill-column b/fill-column
2383 ;; message-fill-column b/fill-column)
2384 (make-local-variable 'company-idle-delay)
2385 (setq company-idle-delay 0.2))))
2386 ;; :custom-face
2387 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2388 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2389 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2390 :custom
2391 (message-elide-ellipsis "[...]\n"))
2392
2393 (use-package mml)
2394
2395 (use-package mml-sec
2396 :custom
2397 (mml-secure-openpgp-encrypt-to-self t)
2398 (mml-secure-openpgp-sign-with-sender t))
2399
2400 (use-package footnote
2401 :after message
2402 ;; :config
2403 ;; (setq footnote-start-tag ""
2404 ;; footnote-end-tag ""
2405 ;; footnote-style 'unicode)
2406 :bind
2407 (:map message-mode-map
2408 :prefix-map b/footnote-prefix-map
2409 :prefix "C-c f n"
2410 ("a" . footnote-add-footnote)
2411 ("b" . footnote-back-to-message)
2412 ("c" . footnote-cycle-style)
2413 ("d" . footnote-delete-footnote)
2414 ("g" . footnote-goto-footnote)
2415 ("r" . footnote-renumber-footnotes)
2416 ("s" . footnote-set-style)))
2417
2418 (use-package ebdb
2419 :demand
2420 :after gnus
2421 :bind (:map gnus-group-mode-map ("e" . ebdb))
2422 :config
2423 (setq ebdb-sources (b/var "ebdb"))
2424 (with-eval-after-load 'swiper
2425 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2426
2427 (use-package ebdb-com
2428 :after ebdb)
2429
2430 (use-package ebdb-complete
2431 :after ebdb
2432 :config
2433 ;; (setq ebdb-complete-mail 'capf)
2434 (ebdb-complete-enable))
2435
2436 (use-package ebdb-message
2437 :demand
2438 :after ebdb)
2439
2440 ;; (use-package company-ebdb
2441 ;; :config
2442 ;; (defun company-ebdb--post-complete (_) nil))
2443
2444 (use-package ebdb-gnus
2445 :after ebdb
2446 :custom
2447 (ebdb-gnus-window-size 0.3))
2448
2449 (use-package ebdb-mua
2450 :demand
2451 :after ebdb
2452 :custom (ebdb-mua-pop-up t))
2453
2454 ;; (use-package ebdb-message
2455 ;; :after ebdb)
2456
2457 ;; (use-package ebdb-vcard
2458 ;; :after ebdb)
2459
2460 (use-package message-x)
2461
2462 (comment
2463 (use-package message-x
2464 :custom
2465 (message-x-completion-alist
2466 (quote
2467 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2468 ((if
2469 (boundp
2470 (quote message-newgroups-header-regexp))
2471 message-newgroups-header-regexp message-newsgroups-header-regexp)
2472 . message-expand-group))))))
2473
2474 (comment
2475 (use-package gnus-harvest
2476 :commands gnus-harvest-install
2477 :demand t
2478 :config
2479 (if (featurep 'message-x)
2480 (gnus-harvest-install 'message-x)
2481 (gnus-harvest-install))))
2482
2483 (use-package gnus-article-treat-patch
2484 :disabled
2485 :demand
2486 :load-path "lisp/"
2487 :config
2488 ;; note: be sure to customize faces with `:foreground "white"' when
2489 ;; using a theme with a white/light background :)
2490 (setq ft/gnus-article-patch-conditions
2491 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2492
2493 \f
2494 ;;; IRC (with ERC and ZNC)
2495
2496 (use-package erc
2497 :bind (("C-c b b" . erc-switch-to-buffer)
2498 :map erc-mode-map
2499 ("M-a" . erc-track-switch-buffer))
2500 :custom
2501 (erc-join-buffer 'bury)
2502 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2503 (erc-nick "bandali")
2504 (erc-prompt "erc>")
2505 (erc-rename-buffers t)
2506 (erc-server-reconnect-attempts 5)
2507 (erc-server-reconnect-timeout 3)
2508 :config
2509 (defun erc-cmd-OPME ()
2510 "Request chanserv to op me."
2511 (erc-message "PRIVMSG"
2512 (format "chanserv op %s %s"
2513 (erc-default-target)
2514 (erc-current-nick)) nil))
2515 (defun erc-cmd-DEOPME ()
2516 "Deop myself from current channel."
2517 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2518 (add-to-list 'erc-modules 'keep-place)
2519 (add-to-list 'erc-modules 'notifications)
2520 (add-to-list 'erc-modules 'smiley)
2521 (add-to-list 'erc-modules 'spelling)
2522 (add-to-list 'erc-modules 'scrolltoplace)
2523 (erc-update-modules))
2524
2525 (use-package erc-fill
2526 :after erc
2527 :custom
2528 (erc-fill-column 77)
2529 (erc-fill-function 'erc-fill-static)
2530 (erc-fill-static-center 18))
2531
2532 (use-package erc-pcomplete
2533 :after erc
2534 :custom
2535 (erc-pcomplete-nick-postfix ", "))
2536
2537 (use-package erc-track
2538 :after erc
2539 :bind (("C-c a e t d" . erc-track-disable)
2540 ("C-c a e t e" . erc-track-enable))
2541 :custom
2542 (erc-track-enable-keybindings nil)
2543 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2544 "324" "329" "332" "333" "353" "477"))
2545 (erc-track-position-in-mode-line t)
2546 (erc-track-priority-faces-only 'all)
2547 (erc-track-shorten-function nil))
2548
2549 (use-package erc-hl-nicks
2550 :after erc)
2551
2552 (use-package erc-scrolltoplace
2553 :after erc)
2554
2555 (use-package znc
2556 :bind (("C-c a e e" . znc-erc)
2557 ("C-c a e a" . znc-all))
2558 :config
2559 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2560 (cond
2561 ((null auth) (error "Couldn't find znca's authinfo"))
2562 (t (funcall (plist-get (car auth) :secret)))))))
2563 (setq znc-servers
2564 `(("znc.shemshak.org" 1337 t
2565 ((freenode "amin/freenode" ,pwd)))
2566 ("znc.shemshak.org" 1337 t
2567 ((oftc "amin/oftc" ,pwd)))))))
2568
2569 \f
2570 ;;; Post initialization
2571
2572 (message "Loading %s...done (%.3fs)" user-init-file
2573 (float-time (time-subtract (current-time)
2574 b/before-user-init-time)))
2575
2576 ;;; init.el ends here