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