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