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