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