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