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