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