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