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