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