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