emacs: minor tweaks
[~bandali/configs] / .emacs.d / init.el
CommitLineData
dca50cf5 1;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
41d290a2 2
4ed3a945 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
20;; Emacs configuration of Amin Bandali, computer scientist, functional
dca50cf5
AB
21;; programmer, and free software activist. Used to use straight.el
22;; for purely functional and fully reproducible package management.
23;; Now I just use Guix.
b57457b2
AB
24
25;; Over the years, I've taken inspiration from configurations of many
26;; great people. Some that I can remember off the top of my head are:
27;;
28;; - https://github.com/dieggsy/dotfiles
29;; - https://github.com/dakra/dmacs
30;; - http://pages.sachachua.com/.emacs.d/Sacha.html
31;; - https://github.com/dakrone/eos
32;; - http://doc.rix.si/cce/cce.html
33;; - https://github.com/jwiegley/dot-emacs
34;; - https://github.com/wasamasa/dotemacs
35;; - https://github.com/hlissner/doom-emacs
41d290a2 36
49e9503b
AB
37;;; Code:
38
b57457b2
AB
39;;; Emacs initialization
40
dca50cf5 41(defvar b/before-user-init-time (current-time)
41d290a2
AB
42 "Value of `current-time' when Emacs begins loading `user-init-file'.")
43(message "Loading Emacs...done (%.3fs)"
dca50cf5 44 (float-time (time-subtract b/before-user-init-time
41d290a2
AB
45 before-init-time)))
46
b57457b2
AB
47;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
48;; during startup to reduce garbage collection frequency. clearing
49;; `file-name-handler-alist' seems to help reduce startup time too.
dca50cf5
AB
50(defvar b/gc-cons-threshold gc-cons-threshold)
51(defvar b/gc-cons-percentage gc-cons-percentage)
52(defvar b/file-name-handler-alist file-name-handler-alist)
41d290a2
AB
53(setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB
54 gc-cons-percentage 0.6
55 file-name-handler-alist nil
56 ;; sidesteps a bug when profiling with esup
57 esup-child-profile-require-level 0)
58
b57457b2 59;; set them back to their defaults once we're done initializing
dca50cf5
AB
60(defun b/post-init ()
61 (setq gc-cons-threshold b/gc-cons-threshold
62 gc-cons-percentage b/gc-cons-percentage
63 file-name-handler-alist b/file-name-handler-alist))
64(add-hook 'after-init-hook #'b/post-init)
41d290a2 65
b57457b2 66;; increase number of lines kept in *Messages* log
41d290a2
AB
67(setq message-log-max 20000)
68
b57457b2
AB
69;; optionally, uncomment to supress some byte-compiler warnings
70;; (see C-h v byte-compile-warnings RET for more info)
41d290a2
AB
71;; (setq byte-compile-warnings
72;; '(not free-vars unresolved noruntime lexical make-local))
73
b57457b2
AB
74\f
75;;; whoami
76
41d290a2 77(setq user-full-name "Amin Bandali"
dca50cf5 78 user-mail-address "bandali@gnu.org")
41d290a2 79
b57457b2
AB
80\f
81;;; comment macro
82
83;; useful for commenting out multiple sexps at a time
84(defmacro comment (&rest _)
85 "Comment out one or more s-expressions."
86 (declare (indent defun))
87 nil)
88
89\f
dca50cf5 90;;; use-package
41d290a2
AB
91(if nil ; set to t when need to debug init
92 (progn
93 (setq use-package-verbose t
94 use-package-expand-minimally nil
95 use-package-compute-statistics t
96 debug-on-error t)
97 (require 'use-package))
98 (setq use-package-verbose nil
99 use-package-expand-minimally t))
100
101(setq use-package-always-defer t)
102(require 'bind-key)
103
54209e74
AB
104(use-package delight)
105
b57457b2
AB
106\f
107;;; Initial setup
108
109;; keep ~/.emacs.d clean
dca50cf5
AB
110(defvar b/etc-dir
111 (expand-file-name
112 (convert-standard-filename "etc/") user-emacs-directory)
113 "The directory where packages place their configuration files.")
114
115(defvar b/var-dir
116 (expand-file-name
117 (convert-standard-filename "var/") user-emacs-directory)
118 "The directory where packages place their persistent data files.")
119
120(defun b/etc (file)
121 "Expand filename FILE relative to `b/etc-dir'."
122 (expand-file-name (convert-standard-filename file) b/etc-dir))
123
124(defun b/var (file)
125 "Expand filename FILE relative to `b/var-dir'."
126 (expand-file-name (convert-standard-filename file) b/var-dir))
127
128(setq auto-save-list-file-prefix (b/var "auto-save/sessions/"))
41d290a2 129
b57457b2 130;; separate custom file (don't want it mixing with init.el)
dca50cf5 131(use-package custom
41d290a2
AB
132 :no-require t
133 :config
dca50cf5 134 (setq custom-file (b/etc "custom.el"))
41d290a2
AB
135 (when (file-exists-p custom-file)
136 (load custom-file))
b57457b2 137 ;; while at it, treat themes as safe
41d290a2
AB
138 (setf custom-safe-themes t))
139
b57457b2 140;; load the secrets file if it exists, otherwise show a warning
dca50cf5
AB
141(comment
142 (with-demoted-errors
143 (load (b/etc "secrets"))))
41d290a2 144
b57457b2 145;; better $PATH (and other environment variable) handling
41d290a2
AB
146(use-package exec-path-from-shell
147 :defer 0.4
148 :init
149 (setq exec-path-from-shell-arguments nil
150 exec-path-from-shell-check-startup-files nil)
151 :config
152 (exec-path-from-shell-initialize)
153 ;; while we're at it, let's fix access to our running ssh-agent
154 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
155 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
156
b57457b2
AB
157;; only one custom theme at a time
158(comment
159 (defadvice load-theme (before clear-previous-themes activate)
160 "Clear existing theme settings instead of layering them"
161 (mapc #'disable-theme custom-enabled-themes)))
162
163;; start up emacs server. see
164;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
dca50cf5 165(use-package server
41d290a2
AB
166 :defer 0.4
167 :config (or (server-running-p) (server-mode)))
168
b57457b2
AB
169;; unicode support
170(comment
171 (dolist (ft (fontset-list))
172 (set-fontset-font
173 ft
174 'unicode
175 (font-spec :name "Source Code Pro" :size 14))
176 (set-fontset-font
177 ft
178 'unicode
179 (font-spec :name "DejaVu Sans Mono")
180 nil
181 'append)
182 ;; (set-fontset-font
183 ;; ft
184 ;; 'unicode
185 ;; (font-spec
186 ;; :name "Symbola monospacified for DejaVu Sans Mono")
187 ;; nil
188 ;; 'append)
189 ;; (set-fontset-font
190 ;; ft
191 ;; #x2115 ; ℕ
192 ;; (font-spec :name "DejaVu Sans Mono")
193 ;; nil
194 ;; 'append)
195 (set-fontset-font
196 ft
197 (cons ?Α ?ω)
198 (font-spec :name "DejaVu Sans Mono" :size 14)
199 nil
200 'prepend)))
201
202;; gentler font resizing
41d290a2
AB
203(setq text-scale-mode-step 1.05)
204
b57457b2 205;; focus follows mouse
41d290a2
AB
206(setq mouse-autoselect-window t)
207
dca50cf5 208(defun b/no-mouse-autoselect-window ()
b57457b2
AB
209 "Conveniently disable `focus-follows-mouse'.
210For disabling the behaviour for certain buffers and/or modes."
41d290a2
AB
211 (make-local-variable 'mouse-autoselect-window)
212 (setq mouse-autoselect-window nil))
213
b57457b2 214;; better scrolling
41d290a2
AB
215(setq ;; scroll-margin 1
216 ;; scroll-conservatively 10000
217 scroll-step 1
218 scroll-conservatively 10
219 scroll-preserve-screen-position 1)
220
dca50cf5 221(use-package mwheel
41d290a2
AB
222 :defer 0.4
223 :config
224 (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time
225 mouse-wheel-progressive-speed nil ; don't accelerate scrolling
226 mouse-wheel-follow-mouse t)) ; scroll window under mouse
227
dca50cf5 228(use-package pixel-scroll
41d290a2
AB
229 :defer 0.4
230 :config (pixel-scroll-mode 1))
231
b57457b2 232;; ask for GPG passphrase in minibuffer
dca50cf5
AB
233(use-package epa
234 :custom
235 ; this will fail if gpg>=2.1 is not available
236 (epa-pinentry-mode 'loopback))
237
238(use-package epg-config
9fc30d4c
AB
239 :defer 0.4
240 :custom
241 ((epg-gpg-program (executable-find "gpg"))
242 (epg-pinentry-mode 'loopback)))
dca50cf5
AB
243
244(use-package epg
9fc30d4c 245 :after epg-config)
dca50cf5 246
9fc30d4c
AB
247(use-package pinentry
248 :demand
dca50cf5 249 :after (epa epg server)
9fc30d4c
AB
250 :config
251 (setq pinentry--socket-dir server-socket-dir)
252 (pinentry-start))
41d290a2 253
b57457b2 254;; useful libraries
41d290a2
AB
255(require 'cl-lib)
256(require 'subr-x)
257
b57457b2
AB
258\f
259;;; Useful utilities
260
dca50cf5 261(defmacro b/setq-every (value &rest vars)
41d290a2
AB
262 "Set all the variables from VARS to value VALUE."
263 (declare (indent defun) (debug t))
264 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
265
dca50cf5 266(defun b/start-process (program &rest args)
41d290a2
AB
267 "Same as `start-process', but doesn't bother about name and buffer."
268 (let ((process-name (concat program "_process"))
269 (buffer-name (generate-new-buffer-name
270 (concat program "_output"))))
271 (apply #'start-process
272 process-name buffer-name program args)))
273
dca50cf5 274(defun b/dired-start-process (program &optional args)
41d290a2
AB
275 "Open current file with a PROGRAM."
276 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
277 ;; be nil, so remove it).
dca50cf5 278 (apply #'b/start-process
41d290a2
AB
279 program
280 (remove nil (list args (dired-get-file-for-visit)))))
281
dca50cf5 282(defun b/add-elisp-section ()
b57457b2
AB
283 (interactive)
284 (insert "\n")
285 (previous-line)
286 (insert "\n\f\n;;; "))
287
288\f
289;;; Defaults
290
291;; time and battery in mode-line
292(comment
293 (use-package time
294 :init
295 (setq display-time-default-load-average nil)
296 :config
297 (display-time-mode))
298
299 (use-package battery
300 :config
301 (display-battery-mode)))
302
303;; smaller fringe
41d290a2
AB
304;; (fringe-mode '(3 . 1))
305(fringe-mode nil)
306
b57457b2 307;; disable disabled commands
41d290a2
AB
308(setq disabled-command-function nil)
309
b57457b2
AB
310;; Save what I copy into clipboard from other applications into Emacs'
311;; kill-ring, which would allow me to still be able to easily access
312;; it in case I kill (cut or copy) something else inside Emacs before
313;; yanking (pasting) what I'd originally intended to.
41d290a2
AB
314(setq save-interprogram-paste-before-kill t)
315
b57457b2 316;; minibuffer
41d290a2
AB
317(setq enable-recursive-minibuffers t
318 resize-mini-windows t)
319
b57457b2 320;; lazy-person-friendly yes/no prompts
41d290a2
AB
321(defalias 'yes-or-no-p #'y-or-n-p)
322
b57457b2 323;; i want *scratch* as my startup buffer
41d290a2
AB
324(setq initial-buffer-choice t)
325
b57457b2 326;; i don't need the default hint
41d290a2
AB
327(setq initial-scratch-message nil)
328
b57457b2 329;; use customizable text-mode as major mode for *scratch*
41d290a2
AB
330(setq initial-major-mode 'text-mode)
331
b57457b2 332;; inhibit buffer list when more than 2 files are loaded
41d290a2
AB
333(setq inhibit-startup-buffer-menu t)
334
b57457b2 335;; don't need to see the startup screen or the echo area message
41d290a2
AB
336(advice-add #'display-startup-echo-area-message :override #'ignore)
337(setq inhibit-startup-screen t
338 inhibit-startup-echo-area-message user-login-name)
339
b57457b2 340;; more useful frame titles
41d290a2
AB
341(setq frame-title-format
342 '("" invocation-name " - "
343 (:eval (if (buffer-file-name)
344 (abbreviate-file-name (buffer-file-name))
345 "%b"))))
346
b57457b2 347;; backups (C-h v make-backup-files RET)
41d290a2 348(setq backup-by-copying t
dca50cf5 349 backup-directory-alist (list (cons "." (b/var "backup/")))
41d290a2
AB
350 version-control t
351 delete-old-versions t)
352
b57457b2 353;; enable automatic reloading of changed buffers and files
41d290a2
AB
354(global-auto-revert-mode 1)
355(setq auto-revert-verbose nil
356 global-auto-revert-non-file-buffers nil)
357
b57457b2 358;; always use space for indentation
41d290a2
AB
359(setq-default
360 indent-tabs-mode nil
361 require-final-newline t
362 tab-width 4)
363
b57457b2 364;; enable winner-mode (C-h f winner-mode RET)
41d290a2
AB
365(winner-mode 1)
366
b57457b2
AB
367;; don't display *compilation* buffer on success. based on
368;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
369;; instead of the now obsolete `flet'.
41d290a2 370(with-eval-after-load 'compile
dca50cf5 371 (defun b/compilation-finish-function (buffer outstr)
41d290a2
AB
372 (unless (string-match "finished" outstr)
373 (switch-to-buffer-other-window buffer))
374 t)
375
dca50cf5 376 (setq compilation-finish-functions #'b/compilation-finish-function)
41d290a2
AB
377
378 (require 'cl-macs)
379
380 (defadvice compilation-start
381 (around inhibit-display
382 (command &optional mode name-function highlight-regexp))
383 (if (not (string-match "^\\(find\\|grep\\)" command))
384 (cl-letf (((symbol-function 'display-buffer) #'ignore))
385 (save-window-excursion ad-do-it))
386 ad-do-it))
387 (ad-activate 'compilation-start))
388
b57457b2
AB
389;; search for non-ASCII characters: i’d like non-ASCII characters such
390;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
391;; counterpart. shoutout to
392;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
41d290a2 393(setq search-default-mode #'char-fold-to-regexp)
41d290a2
AB
394;; uncomment to extend this behaviour to query-replace
395;; (setq replace-char-fold t)
396
b57457b2 397;; cursor shape
41d290a2
AB
398(setq-default cursor-type 'bar)
399
b57457b2 400;; allow scrolling in Isearch
41d290a2
AB
401(setq isearch-allow-scroll t)
402
b9901074
AB
403;; open read-only file buffers in view-mode
404;; (enables niceties like `q' for quit)
405(setq view-read-only t)
406
dca50cf5 407(use-package vc
b1a5d811
AB
408 :bind ("C-x v C-=" . vc-ediff))
409
dca50cf5 410(use-package ediff
b1a5d811
AB
411 :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo)
412 :custom ((ediff-window-setup-function 'ediff-setup-windows-plain)
413 (ediff-split-window-function 'split-window-horizontally)))
414
b57457b2
AB
415\f
416;;; General bindings
417
41d290a2
AB
418(bind-keys
419 ("C-c a i" . ielm)
420
421 ("C-c e b" . eval-buffer)
422 ("C-c e r" . eval-region)
423
424 ("C-c e i" . emacs-init-time)
425 ("C-c e u" . emacs-uptime)
dca50cf5 426 ("C-c e v" . emacs-version)
41d290a2
AB
427
428 ("C-c F m" . make-frame-command)
429 ("C-c F d" . delete-frame)
435306f6 430 ("C-c F D" . server-edit)
41d290a2 431
41d290a2
AB
432 ("C-S-h C" . describe-char)
433 ("C-S-h F" . describe-face)
434
435 ("C-x k" . kill-this-buffer)
436 ("C-x K" . kill-buffer)
437
b57457b2 438 :map emacs-lisp-mode-map
dca50cf5 439 ("<C-return>" . b/add-elisp-section))
41d290a2
AB
440
441(when (display-graphic-p)
442 (unbind-key "C-z" global-map))
443
500004f4
AB
444(bind-keys
445 ;; for back and forward mouse keys
446 ("<mouse-8>" . previous-buffer)
447 ("<drag-mouse-8>" . previous-buffer)
448 ("<mouse-9>" . next-buffer)
449 ("<drag-mouse-9>" . next-buffer)
450 ("<drag-mouse-2>" . kill-this-buffer)
451 ("<drag-mouse-3>" . ivy-switch-buffer))
452
b57457b2
AB
453\f
454;;; Essential packages
455
dca50cf5 456(use-package org
41d290a2
AB
457 :defer 0.5
458 :config
459 (setq org-src-tab-acts-natively t
460 org-src-preserve-indentation nil
461 org-edit-src-content-indentation 0
462 org-link-email-description-format "Email %c: %s" ; %.30s
463 org-highlight-latex-and-related '(entities)
464 org-use-speed-commands t
465 org-startup-folded 'content
466 org-catch-invisible-edits 'show-and-error
467 org-log-done 'time)
468 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
506ba717 469 (add-to-list 'org-modules 'org-habit)
41d290a2
AB
470 :bind
471 (("C-c a o a" . org-agenda)
472 :map org-mode-map
473 ("M-L" . org-insert-last-stored-link)
34c6cf4c 474 ("M-O" . org-toggle-link-display)
41d290a2
AB
475 ("s-T" . org-todo))
476 :hook ((org-mode . org-indent-mode)
477 (org-mode . auto-fill-mode)
478 (org-mode . flyspell-mode))
479 :custom
480 (org-agenda-files '("~/usr/org/todos/personal.org"
506ba717 481 "~/usr/org/todos/habits.org"
41d290a2
AB
482 "~/usr/org/todos/masters.org"))
483 (org-agenda-start-on-weekday 0)
506ba717
AB
484 (org-agenda-time-leading-zero t)
485 (org-habit-graph-column 44)
41d290a2
AB
486 (org-latex-packages-alist '(("" "listings") ("" "color")))
487 :custom-face
488 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
489 '(org-block ((t (:background "#1d1f21"))))
490 '(org-latex-and-related ((t (:foreground "#b294bb")))))
491
dca50cf5 492(use-package ox-latex
41d290a2
AB
493 :after ox
494 :config
495 (setq org-latex-listings 'listings
496 ;; org-latex-prefer-user-labels t
497 )
498 (add-to-list 'org-latex-classes
499 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
500 ("\\section{%s}" . "\\section*{%s}")
501 ("\\subsection{%s}" . "\\subsection*{%s}")
502 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
503 ("\\paragraph{%s}" . "\\paragraph*{%s}")
504 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
505 t)
506 (require 'ox-beamer))
507
dca50cf5 508(use-package ox-extra
41d290a2
AB
509 :config
510 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
511
b57457b2
AB
512;; asynchronous tangle, using emacs-async to asynchronously tangle an
513;; org file. closely inspired by
514;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
41d290a2 515(with-eval-after-load 'org
dca50cf5 516 (defvar b/show-async-tangle-results nil
41d290a2
AB
517 "Keep *emacs* async buffers around for later inspection.")
518
dca50cf5 519 (defvar b/show-async-tangle-time nil
41d290a2
AB
520 "Show the time spent tangling the file.")
521
dca50cf5 522 (defun b/async-babel-tangle ()
41d290a2
AB
523 "Tangle org file asynchronously."
524 (interactive)
525 (let* ((file-tangle-start-time (current-time))
526 (file (buffer-file-name))
527 (file-nodir (file-name-nondirectory file))
528 ;; (async-quiet-switch "-q")
529 (file-noext (file-name-sans-extension file)))
530 (async-start
531 `(lambda ()
532 (require 'org)
533 (org-babel-tangle-file ,file))
dca50cf5 534 (unless b/show-async-tangle-results
41d290a2
AB
535 `(lambda (result)
536 (if result
29ea9439
AB
537 (message "Tangled %s%s"
538 ,file-nodir
dca50cf5 539 (if b/show-async-tangle-time
29ea9439
AB
540 (format " (%.3fs)"
541 (float-time (time-subtract (current-time)
542 ',file-tangle-start-time)))
543 ""))
41d290a2
AB
544 (message "Tangling %s failed" ,file-nodir))))))))
545
546(add-to-list
547 'safe-local-variable-values
dca50cf5 548 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
41d290a2 549
b57457b2 550;; *the* right way to do git
41d290a2
AB
551(use-package magit
552 :defer 0.5
553 :bind (("C-x g" . magit-status)
554 ("s-g s" . magit-status)
555 ("s-g l" . magit-log-buffer-file))
556 :config
557 (magit-add-section-hook 'magit-status-sections-hook
558 'magit-insert-modules
559 'magit-insert-stashes
560 'append)
561 (setq magit-repository-directories '(("~/" . 0)
562 ("~/src/git/" . 1)))
563 (nconc magit-section-initial-visibility-alist
564 '(([unpulled status] . show)
565 ([unpushed status] . show)))
afbbf23a 566 :custom (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
41d290a2
AB
567 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
568
b57457b2 569;; recently opened files
dca50cf5 570(use-package recentf
41d290a2 571 :defer 0.2
dca50cf5 572 ;; :config
9424b3d6 573 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
dca50cf5
AB
574 :custom
575 (recentf-max-saved-items 2000)
576 (recentf-save-file (b/var "recentf-save.el")))
41d290a2 577
b57457b2 578;; smart M-x enhancement (needed by counsel for history)
41d290a2
AB
579(use-package smex)
580
581(use-package ivy
582 :defer 0.3
54209e74 583 :delight ;; " 🙒"
41d290a2
AB
584 :bind
585 (:map ivy-minibuffer-map
586 ([escape] . keyboard-escape-quit)
587 ([S-up] . ivy-previous-history-element)
588 ([S-down] . ivy-next-history-element)
589 ("DEL" . ivy-backward-delete-char))
590 :config
591 (setq ivy-wrap t
592 ivy-height 14
593 ivy-use-virtual-buffers t
594 ivy-virtual-abbreviate 'abbreviate
595 ivy-count-format "%d/%d ")
596 (ivy-mode 1)
597 ;; :custom-face
598 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
599 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
600 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
601)
602
603(use-package swiper
604 :after ivy
605 :bind (("C-s" . swiper-isearch)
606 ("C-r" . swiper)
607 ("C-S-s" . isearch-forward)))
608
609(use-package counsel
610 :after ivy
54209e74 611 :delight
41d290a2
AB
612 :bind (([remap execute-extended-command] . counsel-M-x)
613 ([remap find-file] . counsel-find-file)
614 ("C-c x" . counsel-M-x)
615 ("C-c f ." . counsel-find-file)
616 ("C-c f l" . counsel-find-library)
2b53c994
AB
617 ("C-c f r" . counsel-recentf)
618 ("s-." . counsel-find-file)
619 ("s-r" . ivy-switch-buffer)
41d290a2
AB
620 :map minibuffer-local-map
621 ("C-r" . counsel-minibuffer-history))
622 :config
623 (counsel-mode 1)
624 (defalias 'locate #'counsel-locate))
625
b57457b2
AB
626(comment
627 (use-package helm
628 :commands (helm-M-x helm-mini helm-resume)
629 :bind (("M-x" . helm-M-x)
630 ("M-y" . helm-show-kill-ring)
631 ("C-x b" . helm-mini)
632 ("C-x C-b" . helm-buffers-list)
633 ("C-x C-f" . helm-find-files)
634 ("C-h r" . helm-info-emacs)
635 ("s-r" . helm-recentf)
636 ("C-s-r" . helm-resume)
637 :map helm-map
638 ("<tab>" . helm-execute-persistent-action)
639 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
640 ("C-z" . helm-select-action)) ; List actions
641 :config (helm-mode 1)))
642
dca50cf5 643(use-package eshell
41d290a2
AB
644 :defer 0.5
645 :commands eshell
646 :bind ("C-c a s e" . eshell)
647 :config
648 (eval-when-compile (defvar eshell-prompt-regexp))
dca50cf5 649 (defun b/eshell-quit-or-delete-char (arg)
41d290a2
AB
650 (interactive "p")
651 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
652 (eshell-life-is-too-much)
653 (delete-char arg)))
654
dca50cf5 655 (defun b/eshell-clear ()
41d290a2
AB
656 (interactive)
657 (let ((inhibit-read-only t))
658 (erase-buffer))
659 (eshell-send-input))
660
dca50cf5 661 (defun b/eshell-setup ()
41d290a2
AB
662 (make-local-variable 'company-idle-delay)
663 (defvar company-idle-delay)
664 (setq company-idle-delay nil)
665 (bind-keys :map eshell-mode-map
dca50cf5
AB
666 ("C-d" . b/eshell-quit-or-delete-char)
667 ("C-S-l" . b/eshell-clear)
41d290a2
AB
668 ("M-r" . counsel-esh-history)
669 ([tab] . company-complete)))
670
dca50cf5 671 :hook (eshell-mode . b/eshell-setup)
41d290a2 672 :custom
dca50cf5 673 (eshell-directory-name (b/var "eshell/"))
41d290a2
AB
674 (eshell-hist-ignoredups t)
675 (eshell-input-filter 'eshell-input-filter-initial-space))
676
dca50cf5 677(use-package ibuffer
41d290a2 678 :bind
92df6c4f 679 (("C-x C-b" . ibuffer)
41d290a2
AB
680 :map ibuffer-mode-map
681 ("P" . ibuffer-backward-filter-group)
682 ("N" . ibuffer-forward-filter-group)
683 ("M-p" . ibuffer-do-print)
684 ("M-n" . ibuffer-do-shell-command-pipe-replace))
685 :config
686 ;; Use human readable Size column instead of original one
687 (define-ibuffer-column size-h
688 (:name "Size" :inline t)
689 (cond
690 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
691 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
692 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
693 (t (format "%8d" (buffer-size)))))
694 :custom
695 (ibuffer-saved-filter-groups
696 '(("default"
697 ("dired" (mode . dired-mode))
698 ("org" (mode . org-mode))
699 ("gnus"
700 (or
701 (mode . gnus-group-mode)
702 (mode . gnus-summary-mode)
703 (mode . gnus-article-mode)
704 ;; not really, but...
705 (mode . message-mode)))
706 ("web"
707 (or
708 (mode . web-mode)
709 (mode . css-mode)
710 (mode . scss-mode)
711 (mode . js2-mode)))
712 ("shell"
713 (or
714 (mode . eshell-mode)
715 (mode . shell-mode)
716 (mode . term-mode)))
717 ("programming"
718 (or
719 (mode . python-mode)
720 (mode . c-mode)
721 (mode . c++-mode)
722 (mode . java-mode)
723 (mode . emacs-lisp-mode)
724 (mode . scheme-mode)
725 (mode . haskell-mode)
726 (mode . lean-mode)
99473567 727 (mode . go-mode)
41d290a2
AB
728 (mode . alloy-mode)))
729 ("tex"
730 (or
731 (mode . bibtex-mode)
732 (mode . latex-mode)))
733 ("emacs"
734 (or
735 (name . "^\\*scratch\\*$")
736 (name . "^\\*Messages\\*$")))
737 ("erc" (mode . erc-mode)))))
738 (ibuffer-formats
739 '((mark modified read-only locked " "
740 (name 18 18 :left :elide)
741 " "
742 (size-h 9 -1 :right)
743 " "
744 (mode 16 16 :left :elide)
745 " " filename-and-process)
746 (mark " "
747 (name 16 -1)
748 " " filename)))
749 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
750
dca50cf5 751(use-package outline
41d290a2 752 :hook (prog-mode . outline-minor-mode)
54209e74 753 :delight (outline-minor-mode " outl")
41d290a2
AB
754 :bind
755 (:map
756 outline-minor-mode-map
757 ("<s-tab>" . outline-toggle-children)
758 ("M-p" . outline-previous-visible-heading)
759 ("M-n" . outline-next-visible-heading)
dca50cf5 760 :prefix-map b/outline-prefix-map
ed8c4fa9 761 :prefix "s-O"
41d290a2
AB
762 ("TAB" . outline-toggle-children)
763 ("a" . outline-hide-body)
764 ("H" . outline-hide-body)
765 ("S" . outline-show-all)
766 ("h" . outline-hide-subtree)
767 ("s" . outline-show-subtree)))
768
dca50cf5 769(use-package ls-lisp
41d290a2
AB
770 :custom (ls-lisp-dirs-first t))
771
dca50cf5 772(use-package dired
41d290a2
AB
773 :config
774 (setq dired-listing-switches "-alh"
775 ls-lisp-use-insert-directory-program nil)
776
777 ;; easily diff 2 marked files
778 ;; https://oremacs.com/2017/03/18/dired-ediff/
779 (defun dired-ediff-files ()
780 (interactive)
781 (require 'dired-aux)
782 (defvar ediff-after-quit-hook-internal)
783 (let ((files (dired-get-marked-files))
784 (wnd (current-window-configuration)))
785 (if (<= (length files) 2)
786 (let ((file1 (car files))
787 (file2 (if (cdr files)
788 (cadr files)
789 (read-file-name
790 "file: "
791 (dired-dwim-target-directory)))))
792 (if (file-newer-than-file-p file1 file2)
793 (ediff-files file2 file1)
794 (ediff-files file1 file2))
795 (add-hook 'ediff-after-quit-hook-internal
796 (lambda ()
797 (setq ediff-after-quit-hook-internal nil)
798 (set-window-configuration wnd))))
799 (error "no more than 2 files should be marked"))))
06ee5a00
AB
800
801 (require 'dired-x)
802 (setq dired-guess-shell-alist-user
803 '(("\\.pdf\\'" "evince" "zathura" "okular")
804 ("\\.doc\\'" "libreoffice")
805 ("\\.docx\\'" "libreoffice")
806 ("\\.ppt\\'" "libreoffice")
807 ("\\.pptx\\'" "libreoffice")
808 ("\\.xls\\'" "libreoffice")
809 ("\\.xlsx\\'" "libreoffice")
810 ("\\.flac\\'" "mpv")))
41d290a2
AB
811 :bind (:map dired-mode-map
812 ("b" . dired-up-directory)
813 ("e" . dired-ediff-files)
814 ("E" . dired-toggle-read-only)
815 ("\\" . dired-hide-details-mode)
816 ("z" . (lambda ()
817 (interactive)
dca50cf5 818 (b/dired-start-process "zathura"))))
41d290a2
AB
819 :hook (dired-mode . dired-hide-details-mode))
820
dca50cf5 821(use-package help
41d290a2
AB
822 :config
823 (temp-buffer-resize-mode)
824 (setq help-window-select t))
825
dca50cf5 826(use-package tramp
41d290a2
AB
827 :config
828 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
829 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
830 (add-to-list 'tramp-default-proxies-alist
831 (list (regexp-quote (system-name)) nil nil)))
832
833(use-package dash
834 :config (dash-enable-font-lock))
835
836(use-package doc-view
837 :bind (:map doc-view-mode-map
838 ("M-RET" . image-previous-line)))
839
b57457b2
AB
840\f
841;;; Editing
842
843;; highlight uncommitted changes in the left fringe
41d290a2 844(use-package diff-hl
df1c9bc8 845 :defer 0.6
41d290a2
AB
846 :config
847 (setq diff-hl-draw-borders nil)
848 (global-diff-hl-mode)
849 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
850
b57457b2 851;; display Lisp objects at point in the echo area
dca50cf5 852(use-package eldoc
41d290a2 853 :when (version< "25" emacs-version)
54209e74 854 :delight " eldoc"
41d290a2
AB
855 :config (global-eldoc-mode))
856
b57457b2 857;; highlight matching parens
dca50cf5 858(use-package paren
41d290a2
AB
859 :demand
860 :config (show-paren-mode))
861
dca50cf5 862(use-package elec-pair
40eddfea
AB
863 :demand
864 :config (electric-pair-mode))
865
dca50cf5 866(use-package simple
54209e74 867 :delight (auto-fill-function " fill")
41d290a2
AB
868 :config (column-number-mode))
869
b57457b2 870;; save minibuffer history
dca50cf5
AB
871(use-package savehist
872 :config
873 (savehist-mode)
874 :custom
875 (savehist-file (b/var "savehist.el")))
41d290a2 876
b57457b2 877;; automatically save place in files
dca50cf5 878(use-package saveplace
41d290a2 879 :when (version< "25" emacs-version)
dca50cf5
AB
880 :config (save-place-mode)
881 :custom
882 (save-place-file (b/var "save-place.el")))
41d290a2 883
dca50cf5 884(use-package prog-mode
41d290a2
AB
885 :config (global-prettify-symbols-mode)
886 (defun indicate-buffer-boundaries-left ()
887 (setq indicate-buffer-boundaries 'left))
888 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
889
dca50cf5 890(use-package text-mode
54209e74 891 :hook (text-mode . indicate-buffer-boundaries-left))
41d290a2 892
dca50cf5 893(use-package conf-mode
300b7363
AB
894 :mode "\\.*rc$")
895
dca50cf5 896(use-package sh-mode
300b7363
AB
897 :mode "\\.bashrc$")
898
41d290a2
AB
899(use-package company
900 :defer 0.6
0c53f5ae 901 :delight " comp"
41d290a2
AB
902 :bind
903 (:map company-active-map
904 ([tab] . company-complete-common-or-cycle)
905 ([escape] . company-abort))
906 :custom
907 (company-minimum-prefix-length 1)
908 (company-selection-wrap-around t)
909 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
910 (company-dabbrev-downcase nil)
911 (company-dabbrev-ignore-case nil)
912 :config
913 (global-company-mode t))
914
915(use-package flycheck
916 :defer 0.6
917 :hook (prog-mode . flycheck-mode)
918 :bind
919 (:map flycheck-mode-map
920 ("M-P" . flycheck-previous-error)
921 ("M-N" . flycheck-next-error))
922 :config
923 ;; Use the load-path from running Emacs when checking elisp files
924 (setq flycheck-emacs-lisp-load-path 'inherit)
925
926 ;; Only flycheck when I actually save the buffer
54209e74
AB
927 (setq flycheck-check-syntax-automatically '(mode-enabled save))
928 :custom (flycheck-mode-line-prefix "flyc"))
929
dca50cf5 930(use-package flyspell
54209e74 931 :delight " flysp")
41d290a2
AB
932
933;; http://endlessparentheses.com/ispell-and-apostrophes.html
934(use-package ispell
935 :defer 0.6
936 :config
937 ;; ’ can be part of a word
938 (setq ispell-local-dictionary-alist
939 `((nil "[[:alpha:]]" "[^[:alpha:]]"
b1ed9ee8
AB
940 "['\x2019]" nil ("-B") nil utf-8))
941 ispell-program-name (executable-find "hunspell"))
41d290a2
AB
942 ;; don't send ’ to the subprocess
943 (defun endless/replace-apostrophe (args)
944 (cons (replace-regexp-in-string
945 "’" "'" (car args))
946 (cdr args)))
947 (advice-add #'ispell-send-string :filter-args
948 #'endless/replace-apostrophe)
949
950 ;; convert ' back to ’ from the subprocess
951 (defun endless/replace-quote (args)
952 (if (not (derived-mode-p 'org-mode))
953 args
954 (cons (replace-regexp-in-string
955 "'" "’" (car args))
956 (cdr args))))
957 (advice-add #'ispell-parse-output :filter-args
958 #'endless/replace-quote))
959
dca50cf5 960(use-package abbrev
54209e74 961 :delight " abbr"
dca50cf5
AB
962 :hook (text-mode . abbrev-mode)
963 :custom
964 (abbrev-file-name (b/var "abbrev.el")))
54209e74 965
b57457b2
AB
966\f
967;;; Programming modes
968
dca50cf5 969(use-package lisp-mode
41d290a2 970 :config
41d290a2
AB
971 (defun indent-spaces-mode ()
972 (setq indent-tabs-mode nil))
973 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
974
dca50cf5 975(use-package reveal
54209e74
AB
976 :delight (reveal-mode " reveal")
977 :hook (emacs-lisp-mode . reveal-mode))
978
dca50cf5 979(use-package elisp-mode
54209e74
AB
980 :delight (emacs-lisp-mode "Elisp" :major))
981
dca50cf5
AB
982(comment
983 ;; TODO
984 (use-package alloy-mode
985 :straight (:host github :repo "dwwmmn/alloy-mode")
986 :mode "\\.als\\'"
987 :config (setq alloy-basic-offset 2))
988
989 (use-package proof-site ; for Coq
990 :straight proof-general)
991
992 (eval-when-compile (defvar lean-mode-map))
993 (use-package lean-mode
994 :defer 0.4
995 :bind (:map lean-mode-map
996 ("S-SPC" . company-complete))
997 :config
998 (require 'lean-input)
999 (setq default-input-method "Lean"
1000 lean-input-tweak-all '(lean-input-compose
1001 (lean-input-prepend "/")
1002 (lean-input-nonempty))
1003 lean-input-user-translations '(("/" "/")))
1004 (lean-input-setup))
1005
1006 (use-package haskell-mode
1007 :config
1008 (setq haskell-indentation-layout-offset 4
1009 haskell-indentation-left-offset 4
1010 flycheck-checker 'haskell-hlint
1011 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1012
1013 (use-package dante
1014 :after haskell-mode
1015 :commands dante-mode
1016 :hook (haskell-mode . dante-mode))
1017
1018 (use-package hlint-refactor
1019 :after haskell-mode
1020 :bind (:map hlint-refactor-mode-map
1021 ("C-c l b" . hlint-refactor-refactor-buffer)
1022 ("C-c l r" . hlint-refactor-refactor-at-point))
1023 :hook (haskell-mode . hlint-refactor-mode))
1024
1025 (use-package flycheck-haskell
1026 :after haskell-mode)
1027 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1028 )
41d290a2
AB
1029
1030(use-package sgml-mode
1031 :config
1032 (setq sgml-basic-offset 2))
1033
1034(use-package css-mode
1035 :config
1036 (setq css-indent-offset 2))
1037
1038(use-package web-mode
1039 :mode "\\.html\\'"
1040 :config
dca50cf5 1041 (b/setq-every 2
41d290a2
AB
1042 web-mode-code-indent-offset
1043 web-mode-css-indent-offset
1044 web-mode-markup-indent-offset))
1045
1046(use-package emmet-mode
1047 :after (:any web-mode css-mode sgml-mode)
1048 :bind* (("C-)" . emmet-next-edit-point)
1049 ("C-(" . emmet-prev-edit-point))
1050 :config
1051 (unbind-key "C-j" emmet-mode-keymap)
1052 (setq emmet-move-cursor-between-quotes t)
1053 :hook (web-mode css-mode html-mode sgml-mode))
1054
b57457b2
AB
1055(comment
1056 (use-package meghanada
1057 :bind
1058 (:map meghanada-mode-map
1059 (("C-M-o" . meghanada-optimize-import)
1060 ("C-M-t" . meghanada-import-all)))
1061 :hook (java-mode . meghanada-mode)))
1062
1063(comment
1064 (use-package treemacs
1065 :config (setq treemacs-never-persist t))
1066
1067 (use-package yasnippet
1068 :config
1069 ;; (yas-global-mode)
1070 )
1071
1072 (use-package lsp-mode
1073 :init (setq lsp-eldoc-render-all nil
1074 lsp-highlight-symbol-at-point nil)
1075 )
1076
1077 (use-package hydra)
1078
1079 (use-package company-lsp
1080 :after company
1081 :config
1082 (setq company-lsp-cache-candidates t
1083 company-lsp-async t))
1084
1085 (use-package lsp-ui
1086 :config
1087 (setq lsp-ui-sideline-update-mode 'point))
1088
1089 (use-package lsp-java
1090 :config
1091 (add-hook 'java-mode-hook
1092 (lambda ()
1093 (setq-local company-backends (list 'company-lsp))))
1094
1095 (add-hook 'java-mode-hook 'lsp-java-enable)
1096 (add-hook 'java-mode-hook 'flycheck-mode)
1097 (add-hook 'java-mode-hook 'company-mode)
1098 (add-hook 'java-mode-hook 'lsp-ui-mode))
1099
1100 (use-package dap-mode
1101 :after lsp-mode
1102 :config
1103 (dap-mode t)
1104 (dap-ui-mode t))
1105
1106 (use-package dap-java
1107 :after (lsp-java))
1108
1109 (use-package lsp-java-treemacs
1110 :after (treemacs)))
1111
1112(comment
1113 (use-package eclim
1114 :bind (:map eclim-mode-map ("S-SPC" . company-complete))
1115 :hook ((java-mode . eclim-mode)
1116 (eclim-mode . (lambda ()
1117 (make-local-variable 'company-idle-delay)
1118 (defvar company-idle-delay)
1119 ;; (setq company-idle-delay 0.7)
1120 (setq company-idle-delay nil))))
1121 :custom
1122 (eclim-auto-save nil)
1123 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1124 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1125 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1126
41d290a2
AB
1127(use-package geiser)
1128
dca50cf5 1129(use-package geiser-guile
41d290a2
AB
1130 :config
1131 (setq geiser-guile-load-path "~/src/git/guix"))
1132
1133(use-package guix)
1134
b57457b2
AB
1135(comment
1136 (use-package auctex
1137 :custom
1138 (font-latex-fontify-sectioning 'color)))
1139
99473567
AB
1140(use-package go-mode)
1141
f704f564
AB
1142(use-package po-mode
1143 :hook
1144 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1145
b57457b2
AB
1146\f
1147;;; Theme
1148
dca50cf5
AB
1149(add-to-list 'custom-theme-load-path
1150 (expand-file-name
1151 (convert-standard-filename "lisp") user-emacs-directory))
b57457b2
AB
1152(load-theme 'tangomod t)
1153
1154(use-package smart-mode-line
1155 :commands (sml/apply-theme)
1156 :demand
1157 :config
26906e22
AB
1158 (sml/setup)
1159 (smart-mode-line-enable))
b57457b2 1160
dca50cf5
AB
1161(comment
1162 ;; TODO
1163 (use-package doom-themes))
b57457b2 1164
dca50cf5 1165(defvar b/org-mode-font-lock-keywords
b57457b2
AB
1166 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1167 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1168 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1169 (4 '(:foreground "#c5c8c6") t)))) ; title
1170
dca50cf5 1171(defun b/lights-on ()
b57457b2
AB
1172 "Enable my favourite light theme."
1173 (interactive)
1174 (mapc #'disable-theme custom-enabled-themes)
1175 (load-theme 'tangomod t)
1176 (sml/apply-theme 'automatic)
1177 (font-lock-remove-keywords
dca50cf5 1178 'org-mode b/org-mode-font-lock-keywords))
b57457b2 1179
dca50cf5 1180(defun b/lights-off ()
b57457b2
AB
1181 "Go dark."
1182 (interactive)
1183 (mapc #'disable-theme custom-enabled-themes)
dca50cf5 1184 ;; (load-theme 'doom-tomorrow-night t)
b57457b2
AB
1185 (sml/apply-theme 'automatic)
1186 (font-lock-add-keywords
dca50cf5 1187 'org-mode b/org-mode-font-lock-keywords t))
b57457b2
AB
1188
1189(bind-keys
dca50cf5
AB
1190 ("s-t d" . b/lights-off)
1191 ("s-t l" . b/lights-on))
b57457b2
AB
1192
1193\f
1194;;; Emacs enhancements & auxiliary packages
1195
dca50cf5 1196(use-package man
41d290a2
AB
1197 :config (setq Man-width 80))
1198
1199(use-package which-key
1200 :defer 0.4
54209e74 1201 :delight
41d290a2
AB
1202 :config
1203 (which-key-add-key-based-replacements
1204 ;; prefixes for global prefixes and minor modes
1205 "C-c @" "outline"
1206 "C-c !" "flycheck"
1207 "C-c 8" "typo"
1208 "C-c 8 -" "typo/dashes"
1209 "C-c 8 <" "typo/left-brackets"
1210 "C-c 8 >" "typo/right-brackets"
1211 "C-x 8" "unicode"
1212 "C-x a" "abbrev/expand"
1213 "C-x r" "rectangle/register/bookmark"
1214 "C-x v" "version control"
1215 ;; prefixes for my personal bindings
1216 "C-c a" "applications"
1217 "C-c a e" "erc"
1218 "C-c a o" "org"
1219 "C-c a s" "shells"
1220 "C-c p" "package-management"
1221 ;; "C-c p e" "package-management/epkg"
1222 "C-c p s" "straight.el"
1223 "C-c psa" "all"
1224 "C-c psp" "package"
1225 "C-c c" "compile-and-comments"
1226 "C-c e" "eval"
1227 "C-c f" "files"
1228 "C-c F" "frames"
1229 "C-S-h" "help(ful)"
1230 "C-c m" "multiple-cursors"
1231 "C-c P" "projectile"
1232 "C-c P s" "projectile/search"
1233 "C-c P x" "projectile/execute"
1234 "C-c P 4" "projectile/other-window"
1235 "C-c q" "boxquote"
1236 "s-g" "magit"
ed8c4fa9 1237 "s-O" "outline"
41d290a2
AB
1238 "s-t" "themes")
1239
1240 ;; prefixes for major modes
1241 (which-key-add-major-mode-key-based-replacements 'message-mode
1242 "C-c f" "footnote")
1243 (which-key-add-major-mode-key-based-replacements 'org-mode
1244 "C-c C-v" "org-babel")
1245 (which-key-add-major-mode-key-based-replacements 'web-mode
1246 "C-c C-a" "web/attributes"
1247 "C-c C-b" "web/blocks"
1248 "C-c C-d" "web/dom"
1249 "C-c C-e" "web/element"
1250 "C-c C-t" "web/tags")
1251
1252 (which-key-mode)
1253 :custom
1254 (which-key-add-column-padding 5)
1255 (which-key-max-description-length 32))
1256
b57457b2 1257(use-package crux ; results in Waiting for git... [2 times]
41d290a2
AB
1258 :defer 0.4
1259 :bind (("C-c b k" . crux-kill-other-buffers)
1260 ("C-c d" . crux-duplicate-current-line-or-region)
1261 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
1262 ("C-c f c" . crux-copy-file-preserve-attributes)
1263 ("C-c f d" . crux-delete-file-and-buffer)
1264 ("C-c f r" . crux-rename-file-and-buffer)
1265 ("C-c j" . crux-top-join-line)
1266 ("C-S-j" . crux-top-join-line)))
1267
dca50cf5
AB
1268(comment
1269 ;; TODO
1270 (use-package mwim
1271 :bind (("C-a" . mwim-beginning-of-code-or-line)
1272 ("C-e" . mwim-end-of-code-or-line)
1273 ("<home>" . mwim-beginning-of-line-or-code)
1274 ("<end>" . mwim-end-of-line-or-code))))
41d290a2
AB
1275
1276(use-package projectile
26906e22 1277 :defer 0.5
41d290a2
AB
1278 :bind-keymap ("C-c P" . projectile-command-map)
1279 :config
1280 (projectile-mode)
1281
dca50cf5 1282 (defun b/projectile-mode-line-fun ()
26906e22
AB
1283 "Report project name and type in the modeline."
1284 (let ((project-name (projectile-project-name))
1285 (project-type (projectile-project-type)))
1286 (format "%s%s"
1287 projectile-mode-line-prefix
1288 (if project-type
1289 (format ":%s" project-type)
1290 ""))))
dca50cf5 1291 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
26906e22 1292
41d290a2
AB
1293 (defun my-projectile-invalidate-cache (&rest _args)
1294 ;; ignore the args to `magit-checkout'
1295 (projectile-invalidate-cache nil))
1296
1297 (eval-after-load 'magit-branch
1298 '(progn
1299 (advice-add 'magit-checkout
1300 :after #'my-projectile-invalidate-cache)
1301 (advice-add 'magit-branch-and-checkout
1302 :after #'my-projectile-invalidate-cache)))
54209e74
AB
1303 :custom
1304 (projectile-completion-system 'ivy)
1305 (projectile-mode-line-prefix " proj"))
41d290a2
AB
1306
1307(use-package helpful
1308 :defer 0.6
1309 :bind
1310 (("C-S-h c" . helpful-command)
1311 ("C-S-h f" . helpful-callable) ; helpful-function
1312 ("C-S-h v" . helpful-variable)
1313 ("C-S-h k" . helpful-key)
1314 ("C-S-h p" . helpful-at-point)))
1315
dca50cf5
AB
1316(comment
1317 ;; TODO
1318 (use-package unkillable-scratch
1319 :defer 0.6
1320 :config
1321 (unkillable-scratch 1)
1322 :custom
1323 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))))
41d290a2 1324
dca50cf5
AB
1325(comment
1326 ;; TODO
1327 ;; ,----
1328 ;; | make pretty boxed quotes like this
1329 ;; `----
1330 (use-package boxquote
1331 :defer 0.6
1332 :bind
1333 (:prefix-map b/boxquote-prefix-map
1334 :prefix "C-c q"
1335 ("b" . boxquote-buffer)
1336 ("B" . boxquote-insert-buffer)
1337 ("d" . boxquote-defun)
1338 ("F" . boxquote-insert-file)
1339 ("hf" . boxquote-describe-function)
1340 ("hk" . boxquote-describe-key)
1341 ("hv" . boxquote-describe-variable)
1342 ("hw" . boxquote-where-is)
1343 ("k" . boxquote-kill)
1344 ("p" . boxquote-paragraph)
1345 ("q" . boxquote-boxquote)
1346 ("r" . boxquote-region)
1347 ("s" . boxquote-shell-command)
1348 ("t" . boxquote-text)
1349 ("T" . boxquote-title)
1350 ("u" . boxquote-unbox)
1351 ("U" . boxquote-unbox-region)
1352 ("y" . boxquote-yank)
1353 ("M-q" . boxquote-fill-paragraph)
1354 ("M-w" . boxquote-kill-ring-save))))
41d290a2
AB
1355
1356(use-package orgalist
b57457b2 1357 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
41d290a2
AB
1358 :disabled t
1359 :after message
1360 :hook (message-mode . orgalist-mode))
1361
b57457b2 1362;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
41d290a2
AB
1363(use-package typo
1364 :defer 0.5
54209e74 1365 :delight " typo"
41d290a2
AB
1366 :config
1367 (typo-global-mode 1)
54209e74 1368 :hook ((text-mode erc-mode) . typo-mode))
41d290a2 1369
b57457b2 1370;; highlight TODOs in buffers
41d290a2
AB
1371(use-package hl-todo
1372 :defer 0.5
1373 :config
1374 (global-hl-todo-mode))
1375
dca50cf5
AB
1376(comment
1377 ;; TODO
1378 (use-package shrink-path
1379 :defer 0.5
1380 :after eshell
1381 :config
1382 (defvar user-@-host (concat (user-login-name) "@" (system-name) " "))
1383 (defun +eshell/prompt ()
1384 (let ((base/dir (shrink-path-prompt default-directory)))
1385 (concat (propertize user-@-host 'face 'default)
1386 (propertize (car base/dir)
1387 'face 'font-lock-comment-face)
1388 (propertize (cdr base/dir)
1389 'face 'font-lock-constant-face)
1390 (propertize "> " 'face 'default))))
1391 (setq eshell-prompt-regexp (concat user-@-host ".*> ")
1392 eshell-prompt-function #'+eshell/prompt)))
41d290a2
AB
1393
1394(use-package eshell-up
1395 :after eshell
1396 :commands eshell-up)
1397
1398(use-package multi-term
1399 :defer 0.6
fb078e63
AB
1400 :bind (("C-c a s m m" . multi-term)
1401 ("C-c a s m d" . multi-term-dedicated-toggle)
1402 ("C-c a s m p" . multi-term-prev)
1403 ("C-c a s m n" . multi-term-next)
41d290a2 1404 :map term-mode-map
0af1e91a 1405 ("C-c C-j" . term-char-mode))
41d290a2 1406 :config
96c704d7
AB
1407 (setq multi-term-program "screen"
1408 multi-term-program-switches (concat "-c"
1409 (getenv "XDG_CONFIG_HOME")
1410 "/screen/screenrc")
41d290a2
AB
1411 ;; TODO: add separate bindings for connecting to existing
1412 ;; session vs. always creating a new one
1413 multi-term-dedicated-select-after-open-p t
1414 multi-term-dedicated-window-height 20
1415 multi-term-dedicated-max-window-height 30
1416 term-bind-key-alist
1417 '(("C-c C-c" . term-interrupt-subjob)
1418 ("C-c C-e" . term-send-esc)
0af1e91a 1419 ("C-c C-j" . term-line-mode)
41d290a2 1420 ("C-k" . kill-line)
fb078e63
AB
1421 ;; ("C-y" . term-paste)
1422 ("C-y" . term-send-raw)
41d290a2
AB
1423 ("M-f" . term-send-forward-word)
1424 ("M-b" . term-send-backward-word)
1425 ("M-p" . term-send-up)
1426 ("M-n" . term-send-down)
fb078e63
AB
1427 ("M-j" . term-send-raw-meta)
1428 ("M-y" . term-send-raw-meta)
1429 ("M-/" . term-send-raw-meta)
1430 ("M-0" . term-send-raw-meta)
1431 ("M-1" . term-send-raw-meta)
1432 ("M-2" . term-send-raw-meta)
1433 ("M-3" . term-send-raw-meta)
1434 ("M-4" . term-send-raw-meta)
1435 ("M-5" . term-send-raw-meta)
1436 ("M-6" . term-send-raw-meta)
1437 ("M-7" . term-send-raw-meta)
1438 ("M-8" . term-send-raw-meta)
1439 ("M-9" . term-send-raw-meta)
41d290a2
AB
1440 ("<C-backspace>" . term-send-backward-kill-word)
1441 ("<M-DEL>" . term-send-backward-kill-word)
1442 ("M-d" . term-send-delete-word)
1443 ("M-," . term-send-raw)
1444 ("M-." . comint-dynamic-complete))
1445 term-unbind-key-alist
fb078e63
AB
1446 '("C-z" "C-x" "C-c" "C-h"
1447 ;; "C-y"
1448 "<ESC>")))
41d290a2
AB
1449
1450(use-package page-break-lines
b57457b2 1451 :defer 0.5
54209e74 1452 :delight " pgln"
2f5d8190
AB
1453 :custom
1454 (page-break-lines-max-width fill-column)
41d290a2
AB
1455 :config
1456 (global-page-break-lines-mode))
1457
1458(use-package expand-region
1459 :bind ("C-=" . er/expand-region))
1460
1461(use-package multiple-cursors
1462 :bind
1463 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
dca50cf5 1464 (:prefix-map b/mc-prefix-map
41d290a2
AB
1465 :prefix "C-c m"
1466 ("c" . mc/edit-lines)
1467 ("n" . mc/mark-next-like-this)
1468 ("p" . mc/mark-previous-like-this)
1469 ("a" . mc/mark-all-like-this))))
1470
dca50cf5
AB
1471(comment
1472 ;; TODO
1473 (use-package forge
1474 :after magit
1475 :demand))
41d290a2
AB
1476
1477(use-package yasnippet
1478 :defer 0.6
1479 :config
1480 (defconst yas-verbosity-cur yas-verbosity)
1481 (setq yas-verbosity 2)
476f6228 1482 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
41d290a2
AB
1483 (yas-reload-all)
1484 (setq yas-verbosity yas-verbosity-cur)
476f6228 1485 (yas-global-mode))
41d290a2 1486
dca50cf5 1487(use-package debbugs)
41d290a2
AB
1488
1489(use-package org-ref
1490 :init
dca50cf5 1491 (b/setq-every '("~/usr/org/references.bib")
41d290a2
AB
1492 reftex-default-bibliography
1493 org-ref-default-bibliography)
1494 (setq
1495 org-ref-bibliography-notes "~/usr/org/notes.org"
1496 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1497
41d290a2
AB
1498(use-package alert
1499 :commands (alert)
83a17ce5 1500 :init (setq alert-default-style 'notifications))
41d290a2 1501
2f5d8190
AB
1502;; (use-package fill-column-indicator)
1503
b46ed2ba
AB
1504(use-package emojify
1505 :hook (erc-mode . emojify-mode))
1506
dca50cf5 1507(use-package window
ed8c4fa9
AB
1508 :bind
1509 (("s-o" . other-window)
ed8c4fa9
AB
1510 ("s-/ ." . split-window-right)
1511 ("s-/ ," . split-window-below)
1512 ("s-/ 0" . delete-window)
92df6c4f
AB
1513 ("s-q" . delete-window))
1514 :custom
1515 (split-width-threshold 150))
ed8c4fa9 1516
dca50cf5 1517(use-package windmove
ed8c4fa9
AB
1518 :defer 0.6
1519 :bind
1520 (("s-h" . windmove-left)
1521 ("s-j" . windmove-down)
1522 ("s-k" . windmove-up)
1523 ("s-l" . windmove-right)
1524 ("s-H" . windmove-swap-states-left)
1525 ("s-J" . windmove-swap-states-down)
1526 ("s-K" . windmove-swap-states-up)
1527 ("s-L" . windmove-swap-states-right)))
1528
05068e71
AB
1529(use-package pass
1530 :commands pass
1531 :bind ("C-c a p" . pass)
1532 :hook (pass-mode . View-exit))
1533
b57457b2
AB
1534\f
1535;;; Email (with Gnus)
1536
dca50cf5 1537(defvar b/maildir (expand-file-name "~/mail/"))
41d290a2 1538(with-eval-after-load 'recentf
dca50cf5 1539 (add-to-list 'recentf-exclude b/maildir))
41d290a2
AB
1540
1541(setq
dca50cf5 1542 b/gnus-init-file (b/etc "gnus")
41d290a2
AB
1543 mail-user-agent 'gnus-user-agent
1544 read-mail-command 'gnus)
1545
dca50cf5 1546(use-package gnus
41d290a2
AB
1547 :bind (("s-m" . gnus)
1548 ("s-M" . gnus-unplugged))
1549 :init
1550 (setq
1551 gnus-select-method '(nnnil "")
1552 gnus-secondary-select-methods
d4cc5497 1553 '((nnimap "shemshak"
41d290a2
AB
1554 (nnimap-stream plain)
1555 (nnimap-address "127.0.0.1")
1556 (nnimap-server-port 143)
1557 (nnimap-authenticator plain)
4ed3a945 1558 (nnimap-user "amin@shemshak.local"))
2e9074a4
AB
1559 (nnimap "gnu"
1560 (nnimap-stream plain)
1561 (nnimap-address "127.0.0.1")
1562 (nnimap-server-port 143)
1563 (nnimap-authenticator plain)
7f88c321
AB
1564 (nnimap-user "bandali@gnu.local")
1565 (nnimap-inbox "INBOX")
1566 (nnimap-split-methods 'nnimap-split-fancy)
1567 (nnimap-split-fancy (|
29e42dc1 1568 ;; (: gnus-registry-split-fancy-with-parent)
7f88c321
AB
1569 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1570 ;; gnu
1571 (list ".*emacs-devel.gnu.org" "l.gnu.emacs.devel")
1572 (list ".*help-gnu-emacs.gnu.org" "l.gnu.emacs.help")
1573 (list ".*info-gnu-emacs.gnu.org" "l.gnu.emacs.info")
1574 (list ".*emacs-orgmode.gnu.org" "l.gnu.emacs.orgmode")
40b9eac1 1575 (list ".*emacs-tangents.gnu.org" "l.gnu.emacs.tangents")
7f88c321 1576 (list ".*emacsconf-discuss.gnu.org" "l.gnu.emacsconf.discuss")
690a977d
AB
1577 (list ".*emacsconf-register.gnu.org" "l.gnu.emacsconf.register")
1578 (list ".*emacsconf-submit.gnu.org" "l.gnu.emacsconf.submit")
7f88c321
AB
1579 (list ".*fencepost-users.gnu.org" "l.gnu.fencepost.users")
1580 (list ".*gnunet-developers.gnu.org" "l.gnu.gnunet.developers")
1581 (list ".*help-gnunet.gnu.org" "l.gnu.gnunet.help")
1582 (list ".*bug-gnuzilla.gnu.org" "l.gnu.gnuzilla.bug")
1583 (list ".*gnuzilla-dev.gnu.org" "l.gnu.gnuzilla.dev")
1584 (list ".*guile-devel.gnu.org" "l.gnu.guile.devel")
29e42dc1 1585 (list ".*guile-user.gnu.org" "l.gnu.guile.user")
7f88c321 1586 (list ".*guix-devel.gnu.org" "l.gnu.guix.devel")
837a23a5 1587 (list ".*help-guix.gnu.org" "l.gnu.guix.help")
7f88c321 1588 (list ".*info-guix.gnu.org" "l.gnu.guix.info")
6f25cef1
AB
1589 (list ".*savannah-hackers-public.gnu.org" "l.gnu.savannah.hackers.public")
1590 (list ".*savannah-users.gnu.org" "l.gnu.savannah.users")
7f88c321
AB
1591 (list ".*www-commits.gnu.org" "l.gnu.www.commits")
1592 (list ".*www-discuss.gnu.org" "l.gnu.www.discuss")
9747f63f
AB
1593 ;; webmasters
1594 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
7f88c321
AB
1595 ;; haskell
1596 (list ".*haskell-art.we.lurk.org" "l.haskell.art")
1597 (list ".*haskell-cafe.haskell.org" "l.haskell.cafe")
1598 ;; other
859ba2a0 1599 (list ".*atreus.freelists.org" "l.atreus")
7f88c321
AB
1600 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1601 (list ".*notmuch.notmuchmail.org" "l.notmuch")
1602 (list ".*dev.lists.parabola.nu" "l.parabola.dev")
1603 ;; *@lists.sr.ht
1604 (list ".*~bandali/public-inbox@lists.sr.ht" "l.~bandali.public-inbox")
7c281dfc 1605 (list ".*~sircmpwn/free-writers-club@lists.sr.ht" "l.~sircmpwn.free-writers-club")
7f88c321
AB
1606 (list ".*~sircmpwn/sr.ht-admins@lists.sr.ht" "l.~sircmpwn.srht.admins")
1607 (list ".*~sircmpwn/sr.ht-announce@lists.sr.ht" "l.~sircmpwn.srht.announce")
1608 (list ".*~sircmpwn/sr.ht-dev@lists.sr.ht" "l.~sircmpwn.srht.dev")
1609 (list ".*~sircmpwn/sr.ht-discuss@lists.sr.ht" "l.~sircmpwn.srht.discuss")
1610 "INBOX")))
727d14d3 1611 (nnimap "uw"
41d290a2
AB
1612 (nnimap-stream plain)
1613 (nnimap-address "127.0.0.1")
1614 (nnimap-server-port 143)
1615 (nnimap-authenticator plain)
f0d99991
AB
1616 (nnimap-user "abandali@uw.local")
1617 (nnimap-inbox "INBOX")
1618 (nnimap-split-methods 'nnimap-split-fancy)
1619 (nnimap-split-fancy (|
29e42dc1 1620 ;; (: gnus-registry-split-fancy-with-parent)
f0d99991 1621 ;; se463-s19
cec07e02
AB
1622 ("subject" "\\(SE\\s-?463\\|Deliverable\\)" "course.se463-s19")
1623 (from "\\(SE\\s-?463\\|Gema\\|Hemant\\|Davood\\|Camilo\\|Reza\\|Michael\\|Sandy\\)" "course.se463-s19")
f0d99991
AB
1624 ;; catch-all
1625 "INBOX")))
727d14d3 1626 (nnimap "csc"
41d290a2
AB
1627 (nnimap-stream plain)
1628 (nnimap-address "127.0.0.1")
1629 (nnimap-server-port 143)
1630 (nnimap-authenticator plain)
727d14d3 1631 (nnimap-user "abandali@csc.uw.local")))
d4cc5497 1632 gnus-message-archive-group "nnimap+shemshak:Sent"
41d290a2 1633 gnus-parameters
859ba2a0
AB
1634 '(("l\\.atreus"
1635 (to-address . "atreus@freelists.org")
1636 (to-list . "atreus@freelists.org"))
1637 ("l\\.deepspec"
41d290a2 1638 (to-address . "deepspec@lists.cs.princeton.edu")
778202b8
AB
1639 (to-list . "deepspec@lists.cs.princeton.edu")
1640 (list-identifier . "\\[deepspec\\]"))
74fd778e
AB
1641 ("l\\.gnu\\.emacs\\.devel"
1642 (to-address . "emacs-devel@gnu.org")
1643 (to-list . "emacs-devel@gnu.org"))
1644 ("l\\.gnu\\.emacs\\.help"
1645 (to-address . "help-gnu-emacs@gnu.org")
1646 (to-list . "help-gnu-emacs@gnu.org"))
1647 ("l\\.gnu\\.emacs\\.info"
1648 (to-address . "info-gnu-emacs@gnu.org")
1649 (to-list . "info-gnu-emacs@gnu.org"))
1650 ("l\\.gnu\\.emacs\\.orgmode"
41d290a2 1651 (to-address . "emacs-orgmode@gnu.org")
778202b8
AB
1652 (to-list . "emacs-orgmode@gnu.org")
1653 (list-identifier . "\\[O\\]"))
40b9eac1
AB
1654 ("l\\.gnu\\.emacs\\.tangents"
1655 (to-address . "emacs-tangents@gnu.org")
1656 (to-list . "emacs-tangents@gnu.org"))
74fd778e 1657 ("l\\.gnu\\.emacsconf\\.discuss"
41d290a2
AB
1658 (to-address . "emacsconf-discuss@gnu.org")
1659 (to-list . "emacsconf-discuss@gnu.org"))
690a977d
AB
1660 ("l\\.gnu\\.emacsconf\\.register"
1661 (to-address . "emacsconf-register@gnu.org")
1662 (to-list . "emacsconf-register@gnu.org"))
1663 ("l\\.gnu\\.emacsconf\\.submit"
1664 (to-address . "emacsconf-submit@gnu.org")
1665 (to-list . "emacsconf-submit@gnu.org"))
74fd778e 1666 ("l\\.gnu\\.fencepost\\.users"
41d290a2 1667 (to-address . "fencepost-users@gnu.org")
778202b8
AB
1668 (to-list . "fencepost-users@gnu.org")
1669 (list-identifier . "\\[Fencepost-users\\]"))
74fd778e 1670 ("l\\.gnu\\.gnunet\\.developers"
41d290a2 1671 (to-address . "gnunet-developers@gnu.org")
778202b8
AB
1672 (to-list . "gnunet-developers@gnu.org")
1673 (list-identifier . "\\[GNUnet-developers\\]"))
74fd778e
AB
1674 ("l\\.gnu\\.gnunet\\.help"
1675 (to-address . "help-gnunet@gnu.org")
1676 (to-list . "help-gnunet@gnu.org")
1677 (list-identifier . "\\[Help-gnunet\\]"))
1678 ("l\\.gnu\\.gnuzilla\\.bug"
1679 (to-address . "bug-gnuzilla@gnu.org")
1680 (to-list . "bug-gnuzilla@gnu.org")
1681 (list-identifier . "\\[Bug-gnuzilla\\]"))
1682 ("l\\.gnu\\.gnuzilla\\.dev"
1683 (to-address . "gnuzilla-dev@gnu.org")
1684 (to-list . "gnuzilla-dev@gnu.org")
1685 (list-identifier . "\\[Gnuzilla-dev\\]"))
1686 ("l\\.gnu\\.guile\\.devel"
41d290a2
AB
1687 (to-address . "guile-devel@gnu.org")
1688 (to-list . "guile-devel@gnu.org"))
29e42dc1
AB
1689 ("l\\.gnu\\.guile\\.user"
1690 (to-address . "guile-user@gnu.org")
1691 (to-list . "guile-user@gnu.org"))
74fd778e 1692 ("l\\.gnu\\.guix\\.devel"
41d290a2
AB
1693 (to-address . "guix-devel@gnu.org")
1694 (to-list . "guix-devel@gnu.org"))
837a23a5
AB
1695 ("l\\.gnu\\.guix\\.help"
1696 (to-address . "help-guix@gnu.org")
1697 (to-list . "help-guix@gnu.org"))
74fd778e
AB
1698 ("l\\.gnu\\.guix\\.info"
1699 (to-address . "info-guix@gnu.org")
1700 (to-list . "info-guix@gnu.org"))
6f25cef1
AB
1701 ("l\\.gnu\\.savannah\\.hackers\\.public"
1702 (to-address . "savannah-hackers-public@gnu.org")
1703 (to-list . "savannah-hackers-public@gnu.org"))
1704 ("l\\.gnu\\.savannah\\.users"
1705 (to-address . "savannah-users@gnu.org")
1706 (to-list . "savannah-users@gnu.org"))
74fd778e
AB
1707 ("l\\.gnu\\.www\\.commits"
1708 (to-address . "www-commits@gnu.org")
1709 (to-list . "www-commits@gnu.org"))
1710 ("l\\.gnu\\.www\\.discuss"
1711 (to-address . "www-discuss@gnu.org")
1712 (to-list . "www-discuss@gnu.org"))
1713 ("l\\.haskell\\.art"
41d290a2 1714 (to-address . "haskell-art@we.lurk.org")
778202b8
AB
1715 (to-list . "haskell-art@we.lurk.org")
1716 (list-identifier . "\\[haskell-art\\]"))
74fd778e 1717 ("l\\.haskell\\.cafe"
41d290a2 1718 (to-address . "haskell-cafe@haskell.org")
778202b8
AB
1719 (to-list . "haskell-cafe@haskell.org")
1720 (list-identifier . "\\[Haskell-cafe\\]"))
74fd778e 1721 ("l\\.notmuch"
41d290a2
AB
1722 (to-address . "notmuch@notmuchmail.org")
1723 (to-list . "notmuch@notmuchmail.org"))
74fd778e 1724 ("l\\.parabola\\.dev"
41d290a2 1725 (to-address . "dev@lists.parabola.nu")
778202b8
AB
1726 (to-list . "dev@lists.parabola.nu")
1727 (list-identifier . "\\[Dev\\]"))
74fd778e 1728 ("l\\.~bandali\\.public-inbox"
41d290a2
AB
1729 (to-address . "~bandali/public-inbox@lists.sr.ht")
1730 (to-list . "~bandali/public-inbox@lists.sr.ht"))
7c281dfc
AB
1731 ("l\\.~sircmpwn\\.free-writers-club"
1732 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
1733 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
74fd778e 1734 ("l\\.~sircmpwn\\.srht\\.admins"
41d290a2
AB
1735 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
1736 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
74fd778e 1737 ("l\\.~sircmpwn\\.srht\\.announce"
41d290a2
AB
1738 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
1739 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
74fd778e 1740 ("l\\.~sircmpwn\\.srht\\.dev"
41d290a2
AB
1741 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
1742 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
74fd778e 1743 ("l\\.~sircmpwn\\.srht\\.discuss"
41d290a2
AB
1744 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
1745 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
74fd778e
AB
1746 ("webmasters"
1747 (to-address . "webmasters@gnu.org")
1748 (to-list . "webmasters@gnu.org"))
41d290a2
AB
1749 ("gnu.*"
1750 (gcc-self . t))
1751 ("gnu\\."
262483ba
AB
1752 (subscribed . t))
1753 ("nnimap\\+uw:.*"
1754 (gcc-self . t)))
41d290a2 1755 gnus-large-newsgroup 50
dca50cf5 1756 gnus-home-directory (b/var "gnus/")
41d290a2
AB
1757 gnus-directory (concat gnus-home-directory "news/")
1758 message-directory (concat gnus-home-directory "mail/")
1759 nndraft-directory (concat gnus-home-directory "drafts/")
1760 gnus-save-newsrc-file nil
1761 gnus-read-newsrc-file nil
1762 gnus-interactive-exit nil
1763 gnus-gcc-mark-as-read t)
1764 :config
dca50cf5
AB
1765 (comment
1766 ;; TODO
1767 (require 'ebdb)
1768 (require 'ebdb-mua)
1769 (require 'ebdb-gnus))
41d290a2 1770
29e42dc1 1771 ;; (gnus-registry-initialize)
7f88c321 1772
41d290a2
AB
1773 (with-eval-after-load 'recentf
1774 (add-to-list 'recentf-exclude gnus-home-directory)))
1775
dca50cf5 1776(use-package gnus-art
41d290a2
AB
1777 :config
1778 (setq
7e1cad06 1779 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
41d290a2
AB
1780 gnus-visible-headers
1781 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1782 gnus-sorted-header-list
1783 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1784 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1785 "^Newsgroups:" "List-Id:" "^Organization:"
1786 "^User-Agent:" "^Date:")
1787 ;; local-lapsed article dates
1788 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1789 gnus-article-date-headers '(user-defined)
1790 gnus-article-time-format
1791 (lambda (time)
1792 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1793 (local (article-make-date-line date 'local))
1794 (combined-lapsed (article-make-date-line date
1795 'combined-lapsed))
1796 (lapsed (progn
1797 (string-match " (.+" combined-lapsed)
1798 (match-string 0 combined-lapsed))))
1799 (concat local lapsed))))
1800 (bind-keys
1801 :map gnus-article-mode-map
1802 ("M-L" . org-store-link)))
1803
dca50cf5 1804(use-package gnus-sum
41d290a2 1805 :bind (:map gnus-summary-mode-map
dca50cf5 1806 :prefix-map b/gnus-summary-prefix-map
41d290a2
AB
1807 :prefix "v"
1808 ("r" . gnus-summary-reply)
1809 ("w" . gnus-summary-wide-reply)
1810 ("v" . gnus-summary-show-raw-article))
1811 :config
1812 (bind-keys
1813 :map gnus-summary-mode-map
1814 ("M-L" . org-store-link))
dca50cf5 1815 :hook (gnus-summary-mode . b/no-mouse-autoselect-window))
41d290a2 1816
dca50cf5 1817(use-package gnus-msg
41d290a2 1818 :config
dca50cf5 1819 (defvar b/signature "Amin Bandali
ce72f966
AB
1820Free Software Activist | GNU Webmaster & Volunteer
1821GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
4ed3a945 1822https://shemshak.org/~amin")
dca50cf5 1823 (defvar b/gnu-signature "Amin Bandali
515674c5
AB
1824Free Software Activist | GNU Webmaster & Volunteer
1825GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1826https://bandalis.org")
dca50cf5 1827 (defvar b/uw-signature "Amin Bandali, MMath Student
4d19e255 1828Cheriton School of Computer Science
e0e5275d 1829University of Waterloo
515674c5 1830https://bandalis.org")
dca50cf5 1831 (defvar b/csc-signature "Amin Bandali
e0e5275d
AB
1832Termcom, Computer Science Club
1833University of Waterloo
515674c5 1834https://bandalis.org")
41d290a2
AB
1835 (setq gnus-posting-styles
1836 '((".*"
4ed3a945 1837 (address "amin@shemshak.org")
41d290a2 1838 (body "\nBest,\n")
dca50cf5
AB
1839 (signature b/signature)
1840 (eval (setq b/message-cite-say-hi t)))
7f88c321 1841 ("nnimap\\+gnu:.*"
4ed3a945 1842 (address "bandali@gnu.org")
dca50cf5 1843 (signature b/gnu-signature)
41d290a2
AB
1844 (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org")))
1845 ((header "subject" "ThankCRM")
1846 (to "webmasters-comment@gnu.org")
55495e2f 1847 (body "")
dca50cf5 1848 (eval (setq b/message-cite-say-hi nil)))
63c1969d 1849 ("nnimap\\+uw:.*"
4d19e255 1850 (address "abandali@uwaterloo.ca")
dca50cf5 1851 (signature b/uw-signature))
262483ba 1852 ("nnimap\\+uw:INBOX"
63c1969d
AB
1853 (gcc "\"nnimap+uw:Sent Items\""))
1854 ("nnimap\\+csc:.*"
41d290a2 1855 (address "abandali@csclub.uwaterloo.ca")
dca50cf5 1856 (signature b/csc-signature)
63c1969d 1857 (gcc "nnimap+csc:Sent")))))
41d290a2 1858
dca50cf5 1859(use-package gnus-topic
41d290a2
AB
1860 :hook (gnus-group-mode . gnus-topic-mode)
1861 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
1862
dca50cf5 1863(use-package gnus-agent
41d290a2
AB
1864 :config
1865 (setq gnus-agent-synchronize-flags 'ask)
1866 :hook (gnus-group-mode . gnus-agent-mode))
1867
dca50cf5 1868(use-package gnus-group
41d290a2
AB
1869 :config
1870 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
1871
082360a8
AB
1872(comment
1873 ;; problematic with ebdb's popup, *EBDB-Gnus*
dca50cf5 1874 (use-package gnus-win
082360a8
AB
1875 :config
1876 (setq gnus-use-full-window nil)))
f485f78e 1877
dca50cf5 1878(use-package gnus-dired
348511ef
AB
1879 :commands gnus-dired-mode
1880 :init
1881 (add-hook 'dired-mode-hook 'gnus-dired-mode))
1882
dca50cf5 1883(use-package mm-decode
41d290a2 1884 :config
7e1cad06
AB
1885 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
1886 mm-decrypt-option 'known
1887 mm-verify-option 'known))
41d290a2 1888
dca50cf5 1889(use-package sendmail
41d290a2 1890 :config
8f8d4c32 1891 (setq sendmail-program (executable-find "msmtp")
41d290a2
AB
1892 ;; message-sendmail-extra-arguments '("-v" "-d")
1893 mail-specify-envelope-from t
1894 mail-envelope-from 'header))
1895
dca50cf5 1896(use-package message
41d290a2
AB
1897 :config
1898 ;; redefine for a simplified In-Reply-To header
1899 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
1900 (defun message-make-in-reply-to ()
1901 "Return the In-Reply-To header for this message."
1902 (when message-reply-headers
1903 (let ((from (mail-header-from message-reply-headers))
1904 (msg-id (mail-header-id message-reply-headers)))
1905 (when from
1906 msg-id))))
1907
dca50cf5 1908 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
41d290a2
AB
1909 (defconst message-cite-style-bandali
1910 '((message-cite-function 'message-cite-original)
1911 (message-citation-line-function 'message-insert-formatted-citation-line)
1912 (message-cite-reply-position 'traditional)
1913 (message-yank-prefix "> ")
1914 (message-yank-cited-prefix ">")
1915 (message-yank-empty-prefix ">")
1916 (message-citation-line-format
dca50cf5
AB
1917 (if b/message-cite-say-hi
1918 (concat "Hi %F,\n\n" b/message-cite-style-format)
1919 b/message-cite-style-format)))
41d290a2
AB
1920 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
1921 (setq ;; message-cite-style 'message-cite-style-bandali
1922 message-kill-buffer-on-exit t
1923 message-send-mail-function 'message-send-mail-with-sendmail
1924 message-sendmail-envelope-from 'header
1925 message-subscribed-address-functions
1926 '(gnus-find-subscribed-addresses)
1927 message-dont-reply-to-names
4ed3a945 1928 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
dca50cf5
AB
1929 (comment
1930 ;; TODO
1931 (require 'company-ebdb))
41d290a2
AB
1932 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
1933 (message-mode . flyspell-mode)
1934 (message-mode . (lambda ()
1935 ;; (setq fill-column 65
1936 ;; message-fill-column 65)
1937 (make-local-variable 'company-idle-delay)
1938 (setq company-idle-delay 0.2))))
1939 ;; :custom-face
1940 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
1941 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
1942 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
1943 )
1944
dca50cf5 1945(use-package mml
54209e74
AB
1946 :delight " mml")
1947
dca50cf5 1948(use-package mml-sec
54209e74
AB
1949 :custom
1950 (mml-secure-openpgp-encrypt-to-self t)
1951 (mml-secure-openpgp-sign-with-sender t))
41d290a2 1952
dca50cf5 1953(use-package footnote
41d290a2
AB
1954 :after message
1955 ;; :config
1956 ;; (setq footnote-start-tag ""
1957 ;; footnote-end-tag ""
1958 ;; footnote-style 'unicode)
1959 :bind
1960 (:map message-mode-map
dca50cf5 1961 :prefix-map b/footnote-prefix-map
41d290a2
AB
1962 :prefix "C-c f"
1963 ("a" . footnote-add-footnote)
1964 ("b" . footnote-back-to-message)
1965 ("c" . footnote-cycle-style)
1966 ("d" . footnote-delete-footnote)
1967 ("g" . footnote-goto-footnote)
1968 ("r" . footnote-renumber-footnotes)
1969 ("s" . footnote-set-style)))
1970
dca50cf5
AB
1971(comment
1972 ;; TODO
1973 (use-package ebdb
1974 :straight (:host github :repo "girzel/ebdb")
1975 :after gnus
1976 :bind (:map gnus-group-mode-map ("e" . ebdb))
1977 :config
1978 (setq ebdb-sources (b/var "ebdb"))
1979 (with-eval-after-load 'swiper
1980 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
41d290a2 1981
dca50cf5
AB
1982 (use-package ebdb-com
1983 :after ebdb)
41d290a2 1984
dca50cf5
AB
1985 ;; (use-package ebdb-complete
1986 ;; :after ebdb
1987 ;; :config
1988 ;; (ebdb-complete-enable))
41d290a2 1989
dca50cf5
AB
1990 (use-package company-ebdb
1991 :config
1992 (defun company-ebdb--post-complete (_) nil))
41d290a2 1993
dca50cf5
AB
1994 (use-package ebdb-gnus
1995 :after ebdb
1996 :custom
1997 (ebdb-gnus-window-configuration
1998 '(article
1999 (vertical 1.0
2000 (summary 0.25 point)
2001 (horizontal 1.0
2002 (article 1.0)
2003 (ebdb-gnus 0.3))))))
2004
2005 (use-package ebdb-mua
2006 :after ebdb
2007 ;; :custom (ebdb-mua-pop-up nil)
2008 )
41d290a2 2009
dca50cf5
AB
2010 ;; (use-package ebdb-message
2011 ;; :after ebdb)
41d290a2
AB
2012
2013
dca50cf5
AB
2014 ;; (use-package ebdb-vcard
2015 ;; :after ebdb)
2016 )
41d290a2 2017
dca50cf5
AB
2018(comment
2019 ;; TODO
2020 (use-package message-x))
41d290a2 2021
b57457b2
AB
2022(comment
2023 (use-package message-x
2024 :custom
2025 (message-x-completion-alist
2026 (quote
2027 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2028 ((if
2029 (boundp
2030 (quote message-newgroups-header-regexp))
2031 message-newgroups-header-regexp message-newsgroups-header-regexp)
2032 . message-expand-group))))))
2033
2034(comment
2035 (use-package gnus-harvest
2036 :commands gnus-harvest-install
2037 :demand t
2038 :config
2039 (if (featurep 'message-x)
2040 (gnus-harvest-install 'message-x)
2041 (gnus-harvest-install))))
2042
2043\f
e3e5e846 2044;;; IRC (with ERC and ZNC)
b57457b2 2045
dca50cf5 2046(use-package erc
96840c88
AB
2047 :bind (("C-c a e b" . erc-switch-to-buffer)
2048 :map erc-mode-map
2049 ("M-a" . erc-track-switch-buffer))
2050 :custom
96840c88
AB
2051 (erc-join-buffer 'bury)
2052 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2053 (erc-nick "bandali")
4d5a11b3 2054 (erc-prompt "erc>")
96840c88
AB
2055 (erc-rename-buffers t)
2056 (erc-server-reconnect-attempts 5)
2057 (erc-server-reconnect-timeout 3)
96840c88
AB
2058 :config
2059 (with-eval-after-load 'ivy
2060 ;; ignore channel buffer names
2061 (add-to-list 'ivy-ignore-buffers "^#"))
2062 (defun erc-cmd-OPME ()
2063 "Request chanserv to op me."
2064 (erc-message "PRIVMSG"
2065 (format "chanserv op %s %s"
2066 (erc-default-target)
2067 (erc-current-nick)) nil))
2068 (defun erc-cmd-DEOPME ()
2069 "Deop myself from current channel."
2070 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2071 (add-to-list 'erc-modules 'keep-place)
2072 (add-to-list 'erc-modules 'notifications)
2073 (add-to-list 'erc-modules 'spelling)
dca50cf5
AB
2074 (comment
2075 ;; TODO
2076 (add-to-list 'erc-modules 'scrolltoplace))
96840c88
AB
2077 (erc-update-modules))
2078
dca50cf5 2079(use-package erc-fill
e3e5e846
AB
2080 :after erc
2081 :custom
92df6c4f 2082 (erc-fill-column 77)
e3e5e846
AB
2083 (erc-fill-function 'erc-fill-static)
2084 (erc-fill-static-center 18))
2085
dca50cf5 2086(use-package erc-pcomplete
e3e5e846
AB
2087 :after erc
2088 :custom
2089 (erc-pcomplete-nick-postfix ","))
2090
dca50cf5 2091(use-package erc-track
e3e5e846
AB
2092 :after erc
2093 :custom
2384d161 2094 (erc-track-enable-keybindings nil)
e3e5e846
AB
2095 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2096 "324" "329" "332" "333" "353" "477"))
2097 (erc-track-priority-faces-only 'all)
2098 (erc-track-shorten-function nil))
2099
96840c88
AB
2100(use-package erc-hl-nicks
2101 :after erc)
2102
dca50cf5
AB
2103(comment
2104 ;; TODO
2105 (use-package erc-scrolltoplace
2106 :after erc))
96840c88 2107
41d290a2 2108(use-package znc
dca50cf5 2109 :load-path "lisp/znc.el/"
41d290a2
AB
2110 :bind (("C-c a e e" . znc-erc)
2111 ("C-c a e a" . znc-all))
2112 :config
2113 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2114 (cond
2115 ((null auth) (error "Couldn't find znca's authinfo"))
2116 (t (funcall (plist-get (car auth) :secret)))))))
2117 (setq znc-servers
cad07800 2118 `(("znc.shemshak.org" 1337 t
4ed3a945 2119 ((freenode "amin/freenode" ,pwd)))
cad07800 2120 ("znc.shemshak.org" 1337 t
4ed3a945 2121 ((moznet "amin/moznet" ,pwd)))
cad07800 2122 ("znc.shemshak.org" 1337 t
4ed3a945 2123 ((oftc "amin/oftc" ,pwd)))))))
41d290a2 2124
b57457b2
AB
2125\f
2126;;; Post initialization
2127
41d290a2
AB
2128(message "Loading %s...done (%.3fs)" user-init-file
2129 (float-time (time-subtract (current-time)
dca50cf5 2130 b/before-user-init-time)))
41d290a2
AB
2131
2132;;; init.el ends here