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