* lisp/bandali-gnus.el: SFL mail setup
[~bandali/configs] / init.el
CommitLineData
33b1a7ea 1;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
41d290a2 2
4c05c418 3;; Copyright (C) 2018-2020 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
33b1a7ea 20;; GNU Emacs configuration of Amin Bandali, computer scientist,
92ad9675 21;; Free Software activist, and GNU maintainer & webmaster. Packages
f7910e3d 22;; are installed through using Borg for a fully reproducible setup.
b57457b2
AB
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
dca50cf5 40(defvar b/before-user-init-time (current-time)
41d290a2 41 "Value of `current-time' when Emacs begins loading `user-init-file'.")
83364e5b
AB
42(defvar b/emacs-initialized nil
43 "Whether Emacs has been initialized.")
8b1a2f32
AB
44(defvar b/exwm-p (string= (system-name) "chaman")
45 "Whether or not we will be using `exwm'.")
83364e5b
AB
46
47(when (not (bound-and-true-p b/emacs-initialized))
48 (message "Loading Emacs...done (%.3fs)"
49 (float-time (time-subtract b/before-user-init-time
50 before-init-time))))
41d290a2 51
b57457b2
AB
52;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
53;; during startup to reduce garbage collection frequency. clearing
54;; `file-name-handler-alist' seems to help reduce startup time too.
dca50cf5
AB
55(defvar b/gc-cons-threshold gc-cons-threshold)
56(defvar b/gc-cons-percentage gc-cons-percentage)
57(defvar b/file-name-handler-alist file-name-handler-alist)
bc58e70a 58(setq gc-cons-threshold (* 30 1024 1024) ; 30 MiB
41d290a2
AB
59 gc-cons-percentage 0.6
60 file-name-handler-alist nil
61 ;; sidesteps a bug when profiling with esup
62 esup-child-profile-require-level 0)
63
b57457b2 64;; set them back to their defaults once we're done initializing
dca50cf5 65(defun b/post-init ()
83364e5b
AB
66 "My post-initialize function, run after loading `user-init-file'."
67 (setq b/emacs-initialized t
68 gc-cons-threshold b/gc-cons-threshold
69 gc-cons-percentage b/gc-cons-percentage
e8a3b8f7 70 file-name-handler-alist b/file-name-handler-alist)
8b1a2f32
AB
71 (when b/exwm-p
72 (with-eval-after-load 'exwm-workspace
73 (setq-default
74 mode-line-format
75 (append
76 mode-line-format
77 '((:eval
78 (format
79 "[%s]" (number-to-string
80 exwm-workspace-current-index)))))))))
dca50cf5 81(add-hook 'after-init-hook #'b/post-init)
41d290a2 82
b57457b2 83;; increase number of lines kept in *Messages* log
41d290a2
AB
84(setq message-log-max 20000)
85
b57457b2
AB
86;; optionally, uncomment to supress some byte-compiler warnings
87;; (see C-h v byte-compile-warnings RET for more info)
41d290a2
AB
88;; (setq byte-compile-warnings
89;; '(not free-vars unresolved noruntime lexical make-local))
90
b57457b2
AB
91\f
92;;; whoami
93
41d290a2 94(setq user-full-name "Amin Bandali"
33b1a7ea 95 user-mail-address "bandali@gnu.org")
41d290a2 96
b57457b2 97\f
33273849
AB
98;;; Package management
99
032726b6
AB
100(progn ; `borg'
101 (add-to-list 'load-path
102 (expand-file-name "lib/borg" user-emacs-directory))
103 (require 'borg)
104 (borg-initialize)
105 (setq borg-rewrite-urls-alist
106 '(("git@github.com:" . "https://github.com/")
107 ("git@gitlab.com:" . "https://gitlab.com/"))))
33273849
AB
108
109;; use-package
41d290a2
AB
110(if nil ; set to t when need to debug init
111 (progn
112 (setq use-package-verbose t
113 use-package-expand-minimally nil
114 use-package-compute-statistics t
115 debug-on-error t)
116 (require 'use-package))
117 (setq use-package-verbose nil
118 use-package-expand-minimally t))
119
120(setq use-package-always-defer t)
121(require 'bind-key)
122
b57457b2
AB
123\f
124;;; Initial setup
125
126;; keep ~/.emacs.d clean
1060413b
AB
127(use-package no-littering
128 :demand
129 :config
130 (defalias 'b/etc 'no-littering-expand-etc-file-name)
131 (defalias 'b/var 'no-littering-expand-var-file-name))
41d290a2 132
032726b6
AB
133(use-package auto-compile
134 :demand
135 :config
136 (auto-compile-on-load-mode)
137 (auto-compile-on-save-mode)
138 (setq auto-compile-display-buffer nil)
139 (setq auto-compile-mode-line-counter t)
140 (setq auto-compile-source-recreate-deletes-dest t)
141 (setq auto-compile-toggle-deletes-nonlib-dest t)
142 (setq auto-compile-update-autoloads t))
143
b57457b2 144;; separate custom file (don't want it mixing with init.el)
47904cb7 145(use-package custom
60ff805e 146 :no-require
41d290a2 147 :config
dca50cf5 148 (setq custom-file (b/etc "custom.el"))
41d290a2
AB
149 (when (file-exists-p custom-file)
150 (load custom-file))
b57457b2 151 ;; while at it, treat themes as safe
60ff805e
AB
152 (setf custom-safe-themes t)
153 ;; only one custom theme at a time
154 (comment
155 (defadvice load-theme (before clear-previous-themes activate)
156 "Clear existing theme settings instead of layering them"
157 (mapc #'disable-theme custom-enabled-themes))))
41d290a2 158
b57457b2 159;; load the secrets file if it exists, otherwise show a warning
dca50cf5
AB
160(comment
161 (with-demoted-errors
162 (load (b/etc "secrets"))))
41d290a2 163
b57457b2
AB
164;; start up emacs server. see
165;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
47904cb7 166(use-package server
f7910e3d 167 :defer 0.5
2087ae39
AB
168 :config
169 (declare-function server-edit "server")
170 (bind-key "C-c F D" 'server-edit)
171 (declare-function server-running-p "server")
172 (or (server-running-p) (server-mode)))
41d290a2 173
60ff805e 174\f
60ff805e
AB
175;;; Defaults
176
177;;;; C-level customizations
178
179(setq
180 ;; minibuffer
181 enable-recursive-minibuffers t
182 resize-mini-windows t
183 ;; more useful frame titles
7c558c9b
AB
184 ;; frame-title-format '("" invocation-name " - "
185 ;; (:eval
186 ;; (if (buffer-file-name)
187 ;; (abbreviate-file-name (buffer-file-name))
188 ;; "%b")))
60ff805e
AB
189 ;; i don't feel like jumping out of my chair every now and again; so
190 ;; don't BEEP! at me, emacs
191 ring-bell-function 'ignore
192 ;; better scrolling
193 ;; scroll-margin 1
194 ;; scroll-conservatively 10000
195 scroll-step 1
bdd3a0bb 196 scroll-conservatively 101
60ff805e
AB
197 scroll-preserve-screen-position 1
198 ;; focus follows mouse
39cc9c96 199 mouse-autoselect-window t)
60ff805e
AB
200
201(setq-default
202 ;; always use space for indentation
203 indent-tabs-mode nil
204 tab-width 4
7682baf8
AB
205 ;; case-sensitive search (and `dabbrev-expand')
206 ;; case-fold-search nil
60ff805e 207 ;; cursor shape
567440fa 208 cursor-type t)
60ff805e 209
7c558c9b
AB
210(set-fontset-font t 'arabic "Vazir")
211
b57457b2
AB
212;; unicode support
213(comment
214 (dolist (ft (fontset-list))
215 (set-fontset-font
216 ft
217 'unicode
218 (font-spec :name "Source Code Pro" :size 14))
219 (set-fontset-font
220 ft
221 'unicode
222 (font-spec :name "DejaVu Sans Mono")
223 nil
224 'append)
225 ;; (set-fontset-font
226 ;; ft
227 ;; 'unicode
228 ;; (font-spec
229 ;; :name "Symbola monospacified for DejaVu Sans Mono")
230 ;; nil
231 ;; 'append)
232 ;; (set-fontset-font
233 ;; ft
234 ;; #x2115 ; ℕ
235 ;; (font-spec :name "DejaVu Sans Mono")
236 ;; nil
237 ;; 'append)
238 (set-fontset-font
239 ft
240 (cons ?Α ?ω)
241 (font-spec :name "DejaVu Sans Mono" :size 14)
242 nil
243 'prepend)))
244
60ff805e 245;;;; Elisp-level customizations
41d290a2 246
47904cb7 247(use-package startup
60ff805e
AB
248 :no-require
249 :demand
41d290a2 250 :config
60ff805e
AB
251 ;; don't need to see the startup echo area message
252 (advice-add #'display-startup-echo-area-message :override #'ignore)
253 :custom
254 ;; i want *scratch* as my startup buffer
255 (initial-buffer-choice t)
256 ;; i don't need the default hint
257 (initial-scratch-message nil)
258 ;; use customizable text-mode as major mode for *scratch*
2568a634 259 ;; (initial-major-mode 'text-mode)
60ff805e
AB
260 ;; inhibit buffer list when more than 2 files are loaded
261 (inhibit-startup-buffer-menu t)
262 ;; don't need to see the startup screen or echo area message
263 (inhibit-startup-screen t)
264 (inhibit-startup-echo-area-message user-login-name))
41d290a2 265
47904cb7 266(use-package files
60ff805e
AB
267 :no-require
268 :demand
9fc30d4c 269 :custom
60ff805e
AB
270 ;; backups (C-h v make-backup-files RET)
271 (backup-by-copying t)
272 (version-control t)
273 (delete-old-versions t)
41d290a2 274
60ff805e
AB
275 ;; auto-save
276 (auto-save-file-name-transforms
277 `((".*" ,(b/var "auto-save/") t)))
41d290a2 278
60ff805e
AB
279 ;; insert newline at the end of files
280 (require-final-newline t)
b57457b2 281
60ff805e
AB
282 ;; open read-only file buffers in view-mode
283 ;; (enables niceties like `q' for quit)
284 (view-read-only t))
41d290a2 285
60ff805e
AB
286;; disable disabled commands
287(setq disabled-command-function nil)
41d290a2 288
60ff805e
AB
289;; lazy-person-friendly yes/no prompts
290(defalias 'yes-or-no-p #'y-or-n-p)
b57457b2 291
60ff805e 292;; enable automatic reloading of changed buffers and files
47904cb7 293(use-package autorevert
60ff805e
AB
294 :demand
295 :config
296 (global-auto-revert-mode 1)
297 :custom
298 (auto-revert-verbose nil)
299 (global-auto-revert-non-file-buffers nil))
b57457b2
AB
300
301;; time and battery in mode-line
47904cb7 302(use-package time
e4902e0b 303 :demand
64938292
AB
304 :config
305 (display-time-mode)
306 :custom
307 (display-time-default-load-average nil)
f7910e3d 308 (display-time-format " %a %b %-e %-l:%M%P")
ad61316b
AB
309 (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center))
310 (display-time-use-mail-icon t))
64938292 311
47904cb7 312(use-package battery
e4902e0b 313 :demand
64938292
AB
314 :config
315 (display-battery-mode)
316 :custom
f7910e3d 317 (battery-mode-line-format "%p%% %t"))
b57457b2 318
47904cb7 319(use-package fringe
60ff805e
AB
320 :demand
321 :config
322 ;; smaller fringe
323 ;; (fringe-mode '(3 . 1))
324 (fringe-mode nil))
41d290a2 325
47904cb7 326(use-package winner
60ff805e
AB
327 :demand
328 :config
329 ;; enable winner-mode (C-h f winner-mode RET)
330 (winner-mode 1))
41d290a2 331
47904cb7 332(use-package compile
60ff805e
AB
333 :config
334 ;; don't display *compilation* buffer on success. based on
335 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
336 ;; instead of the now obsolete `flet'.
dca50cf5 337 (defun b/compilation-finish-function (buffer outstr)
41d290a2
AB
338 (unless (string-match "finished" outstr)
339 (switch-to-buffer-other-window buffer))
340 t)
341
dca50cf5 342 (setq compilation-finish-functions #'b/compilation-finish-function)
41d290a2
AB
343
344 (require 'cl-macs)
345
346 (defadvice compilation-start
347 (around inhibit-display
348 (command &optional mode name-function highlight-regexp))
349 (if (not (string-match "^\\(find\\|grep\\)" command))
350 (cl-letf (((symbol-function 'display-buffer) #'ignore))
351 (save-window-excursion ad-do-it))
352 ad-do-it))
353 (ad-activate 'compilation-start))
354
47904cb7 355(use-package isearch
60ff805e
AB
356 :custom
357 ;; allow scrolling in Isearch
358 (isearch-allow-scroll t)
359 ;; search for non-ASCII characters: i’d like non-ASCII characters such
360 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
361 ;; counterpart. shoutout to
362 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
363 (search-default-mode #'char-fold-to-regexp))
364
365;; uncomment to extend the above behaviour to query-replace
366(comment
47904cb7 367 (use-package replace
60ff805e
AB
368 :custom
369 (replace-char-fold t)))
b9901074 370
47904cb7 371(use-package vc
b1a5d811
AB
372 :bind ("C-x v C-=" . vc-ediff))
373
47904cb7 374(use-package vc-git
e59c8878
AB
375 :after vc
376 :custom
377 (vc-git-print-log-follow t))
378
47904cb7 379(use-package ediff
b1a5d811
AB
380 :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo)
381 :custom ((ediff-window-setup-function 'ediff-setup-windows-plain)
382 (ediff-split-window-function 'split-window-horizontally)))
383
47904cb7 384(use-package face-remap
60ff805e
AB
385 :custom
386 ;; gentler font resizing
387 (text-scale-mode-step 1.05))
388
47904cb7 389(use-package mwheel
60ff805e
AB
390 :defer 0.4
391 :config
392 (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time
393 mouse-wheel-progressive-speed nil ; don't accelerate scrolling
394 mouse-wheel-follow-mouse t)) ; scroll window under mouse
395
47904cb7 396(use-package pixel-scroll
60ff805e
AB
397 :defer 0.4
398 :config (pixel-scroll-mode 1))
399
47904cb7 400(use-package epg-config
a89c8bd8
AB
401 :config
402 ;; ask for GPG passphrase in minibuffer
403 ;; this will fail if gpg>=2.1 is not available
97141042 404 (setq epg-pinentry-mode 'loopback)
60ff805e 405 :custom
47904cb7 406 (epg-gpg-program (executable-find "gpg")))
1d405cde 407
47904cb7
AB
408(use-package epg
409 :after epg-config)
410
a89c8bd8 411(use-package pinentry
8b1a2f32 412 :disabled
a89c8bd8
AB
413 :demand
414 :after (epa epg server)
415 :config
416 ;; workaround for systemd-based distros:
417 ;; (setq pinentry--socket-dir server-socket-dir)
418 (pinentry-start))
419
47904cb7 420(use-package auth-source
b98dbb3d
AB
421 :custom
422 (auth-sources '("~/.authinfo.gpg"))
423 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
424
b57457b2
AB
425\f
426;;; General bindings
427
41d290a2 428(bind-keys
c64e010d 429 ("C-a" . b/move-indentation-or-beginning-of-line)
41d290a2 430 ("C-c a i" . ielm)
ad1f9d99 431 ("C-c d" . b/duplicate-line-or-region)
41d290a2
AB
432
433 ("C-c e b" . eval-buffer)
2a816b71 434 ("C-c e e" . eval-last-sexp)
12ff40a3 435 ("C-c e p" . pp-macroexpand-last-sexp)
41d290a2
AB
436 ("C-c e r" . eval-region)
437
438 ("C-c e i" . emacs-init-time)
439 ("C-c e u" . emacs-uptime)
dca50cf5 440 ("C-c e v" . emacs-version)
41d290a2 441
567440fa
AB
442 ("C-c f ." . find-file)
443 ("C-c f d" . find-name-dired)
444 ("C-c f l" . find-library)
445
41d290a2
AB
446 ("C-c F m" . make-frame-command)
447 ("C-c F d" . delete-frame)
41d290a2 448
41d290a2
AB
449 ("C-S-h C" . describe-char)
450 ("C-S-h F" . describe-face)
451
e5c2d147
AB
452 ("C-S-j" . b/join-line-top)
453
567440fa
AB
454 ("C-c x" . execute-extended-command)
455
a5cc22f4 456 ("C-x k" . b/kill-current-buffer)
41d290a2 457 ("C-x K" . kill-buffer)
2a816b71
AB
458 ("C-x s" . save-buffer)
459 ("C-x S" . save-some-buffers)
41d290a2 460
b57457b2 461 :map emacs-lisp-mode-map
dca50cf5 462 ("<C-return>" . b/add-elisp-section))
41d290a2
AB
463
464(when (display-graphic-p)
465 (unbind-key "C-z" global-map))
466
500004f4
AB
467(bind-keys
468 ;; for back and forward mouse keys
0365678c 469 ("<XF86Back>" . previous-buffer)
500004f4 470 ("<mouse-8>" . previous-buffer)
4bdfe6ab 471 ;; ("<drag-mouse-8>" . previous-buffer)
0365678c 472 ("<XF86Forward>" . next-buffer)
500004f4 473 ("<mouse-9>" . next-buffer)
4bdfe6ab
AB
474 ;; ("<drag-mouse-9>" . next-buffer)
475 ;; ("<drag-mouse-2>" . kill-this-buffer)
476 ;; ("<drag-mouse-3>" . switch-to-buffer)
477 )
500004f4 478
b57457b2
AB
479\f
480;;; Essential packages
481
8b1a2f32
AB
482(when b/exwm-p
483 (require 'bandali-exwm))
33273849 484
f7910e3d 485(require 'bandali-org)
41d290a2 486
9c48decc
AB
487(require 'bandali-theme)
488
b57457b2 489;; *the* right way to do git
41d290a2 490(use-package magit
2a816b71
AB
491 :bind (("C-x g" . magit-status)
492 ("C-c g g" . magit-status)
ef6c487c
AB
493 ("C-c g b" . magit-blame-addition)
494 ("C-c g l" . magit-log-buffer-file))
41d290a2 495 :config
2087ae39
AB
496 (declare-function magit-add-section-hook "magit-section"
497 (hook function &optional at append local))
41d290a2
AB
498 (magit-add-section-hook 'magit-status-sections-hook
499 'magit-insert-modules
500 'magit-insert-stashes
501 'append)
3b3615f5
AB
502 ;; (magit-add-section-hook 'magit-status-sections-hook
503 ;; 'magit-insert-ignored-files
504 ;; 'magit-insert-untracked-files
505 ;; 'append)
8a2e0eef 506 (setq magit-repository-directories '(("~/.emacs.d/" . 0)
81ea6e55 507 ("~/src/git/" . 2)))
41d290a2
AB
508 (nconc magit-section-initial-visibility-alist
509 '(([unpulled status] . show)
510 ([unpushed status] . show)))
2087ae39 511 (declare-function magit-display-buffer-fullframe-status-v1 "magit-mode" (buffer))
3fffeb0a
AB
512 :custom
513 (magit-diff-refine-hunk t)
514 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
6ca3a7b1 515 ;; (magit-completing-read-function 'magit-ido-completing-read)
41d290a2
AB
516 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
517
7c558c9b
AB
518(use-package magit-extras
519 :after magit
520 :config
521 (setq magit-pop-revision-stack-format
522 (pcase-let ((`(,pt ,_eob ,index-regexp)
523 (default-value 'magit-pop-revision-stack-format)))
524 `(,pt "[%N: %h]: %ci\n %s
525 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=%H"
526 ,index-regexp))))
527
b57457b2 528;; recently opened files
47904cb7 529(use-package recentf
41d290a2 530 :defer 0.2
6b09fc8a
AB
531 :config
532 (add-to-list 'recentf-keep 'file-remote-p)
6eb104ff
AB
533 :config
534 (recentf-mode)
dca50cf5 535 :custom
1060413b 536 (recentf-max-saved-items 2000))
41d290a2 537
679463c6 538;; needed for history for counsel
6eb104ff
AB
539(use-package amx
540 :defer 0.3
541 :config
542 (amx-mode))
543
679463c6
AB
544;; (require 'bandali-ido)
545(require 'bandali-ivy)
41d290a2 546
679463c6 547(require 'bandali-eshell)
1eb20313 548;; (require 'bandali-multi-term)
41d290a2 549
679463c6 550(require 'bandali-ibuffer)
41d290a2 551
47904cb7 552(use-package outline
2e81c51a 553 :disabled
41d290a2
AB
554 :hook (prog-mode . outline-minor-mode)
555 :bind
556 (:map
557 outline-minor-mode-map
558 ("<s-tab>" . outline-toggle-children)
559 ("M-p" . outline-previous-visible-heading)
560 ("M-n" . outline-next-visible-heading)
dca50cf5 561 :prefix-map b/outline-prefix-map
ed8c4fa9 562 :prefix "s-O"
41d290a2
AB
563 ("TAB" . outline-toggle-children)
564 ("a" . outline-hide-body)
565 ("H" . outline-hide-body)
566 ("S" . outline-show-all)
567 ("h" . outline-hide-subtree)
1eb20313
AB
568 ("s" . outline-show-subtree))
569 :config
570 (when (featurep 'which-key)
571 (which-key-add-key-based-replacements
572 "C-c @" "outline"
573 "s-O" "outline")))
41d290a2 574
679463c6 575(require 'bandali-dired)
41d290a2 576
47904cb7 577(use-package help
6b09fc8a
AB
578 :bind
579 (:map help-mode-map
580 ("p" . backward-button)
581 ("n" . forward-button))
41d290a2
AB
582 :config
583 (temp-buffer-resize-mode)
584 (setq help-window-select t))
585
47904cb7 586(use-package tramp
41d290a2
AB
587 :config
588 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
589 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
590 (add-to-list 'tramp-default-proxies-alist
591 (list (regexp-quote (system-name)) nil nil)))
592
47904cb7 593(use-package doc-view
41d290a2
AB
594 :bind (:map doc-view-mode-map
595 ("M-RET" . image-previous-line)))
596
7c558c9b
AB
597(use-package shr
598 :custom
599 (shr-max-width 80))
600
e2178fd3 601;; Email (with Gnus, message, and EBDB)
2087ae39 602(require 'bandali-gnus)
2087ae39
AB
603(use-package sendmail
604 :config
605 (setq sendmail-program (executable-find "msmtp")
606 ;; message-sendmail-extra-arguments '("-v" "-d")
607 mail-specify-envelope-from t
608 mail-envelope-from 'header))
2087ae39 609(require 'bandali-message)
e2178fd3 610(require 'bandali-ebdb)
2087ae39 611
39c1c073
AB
612;; IRC (with ERC and ZNC)
613(require 'bandali-erc)
614
2331b5a0
AB
615(use-package scpaste
616 :config
617 (setq scpaste-http-destination "https://p.bndl.org"
618 scpaste-scp-destination "p:~"))
619
b57457b2
AB
620\f
621;;; Editing
5750405c 622
b57457b2 623;; highlight uncommitted changes in the left fringe
41d290a2 624(use-package diff-hl
7682baf8 625 :disabled
df1c9bc8 626 :defer 0.6
41d290a2
AB
627 :config
628 (setq diff-hl-draw-borders nil)
629 (global-diff-hl-mode)
5750405c
AB
630 :hook
631 ((magit-pre-refresh . diff-hl-magit-pre-refresh)
632 (magit-post-refresh . diff-hl-magit-post-refresh)))
41d290a2 633
b57457b2 634;; display Lisp objects at point in the echo area
47904cb7 635(use-package eldoc
41d290a2
AB
636 :when (version< "25" emacs-version)
637 :config (global-eldoc-mode))
638
b57457b2 639;; highlight matching parens
47904cb7 640(use-package paren
41d290a2
AB
641 :demand
642 :config (show-paren-mode))
643
47904cb7 644(use-package elec-pair
7c558c9b 645 :disabled
40eddfea
AB
646 :demand
647 :config (electric-pair-mode))
648
47904cb7 649(use-package simple
60ff805e
AB
650 :config (column-number-mode)
651 :custom
652 ;; Save what I copy into clipboard from other applications into Emacs'
653 ;; kill-ring, which would allow me to still be able to easily access
654 ;; it in case I kill (cut or copy) something else inside Emacs before
655 ;; yanking (pasting) what I'd originally intended to.
656 (save-interprogram-paste-before-kill t))
41d290a2 657
b57457b2 658;; save minibuffer history
47904cb7 659(use-package savehist
1060413b 660 :demand
dca50cf5
AB
661 :config
662 (savehist-mode)
1060413b 663 (add-to-list 'savehist-additional-variables 'kill-ring))
41d290a2 664
b57457b2 665;; automatically save place in files
47904cb7 666(use-package saveplace
41d290a2 667 :when (version< "25" emacs-version)
1060413b 668 :config (save-place-mode))
41d290a2 669
47904cb7 670(use-package prog-mode
41d290a2
AB
671 :config (global-prettify-symbols-mode)
672 (defun indicate-buffer-boundaries-left ()
673 (setq indicate-buffer-boundaries 'left))
674 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
675
47904cb7 676(use-package text-mode
bc2f85e1 677 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
93a86536
AB
678 :hook ((text-mode . indicate-buffer-boundaries-left)
679 (text-mode . flyspell-mode)))
41d290a2 680
47904cb7 681(use-package conf-mode
300b7363
AB
682 :mode "\\.*rc$")
683
5b990219
AB
684(use-package sh-script
685 :mode ("\\.bashrc$" . sh-mode))
300b7363 686
41d290a2 687(use-package company
ccade202 688 :disabled
41d290a2
AB
689 :bind
690 (:map company-active-map
691 ([tab] . company-complete-common-or-cycle)
d39234b9
AB
692 ([escape] . company-abort)
693 ("C-p" . company-select-previous-or-abort)
694 ("C-n" . company-select-next-or-abort))
41d290a2
AB
695 :custom
696 (company-minimum-prefix-length 1)
697 (company-selection-wrap-around t)
698 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
699 (company-dabbrev-downcase nil)
700 (company-dabbrev-ignore-case nil)
6eb104ff
AB
701 ;; :config
702 ;; (global-company-mode t)
703 )
41d290a2
AB
704
705(use-package flycheck
fac1032c 706 :disabled
41d290a2
AB
707 :defer 0.6
708 :hook (prog-mode . flycheck-mode)
709 :bind
710 (:map flycheck-mode-map
711 ("M-P" . flycheck-previous-error)
712 ("M-N" . flycheck-next-error))
713 :config
714 ;; Use the load-path from running Emacs when checking elisp files
715 (setq flycheck-emacs-lisp-load-path 'inherit)
716
717 ;; Only flycheck when I actually save the buffer
54209e74
AB
718 (setq flycheck-check-syntax-automatically '(mode-enabled save))
719 :custom (flycheck-mode-line-prefix "flyc"))
720
fac1032c 721;; (use-package flyspell)
41d290a2
AB
722
723;; http://endlessparentheses.com/ispell-and-apostrophes.html
47904cb7 724(use-package ispell
fac1032c 725 :disabled
41d290a2
AB
726 :defer 0.6
727 :config
728 ;; ’ can be part of a word
729 (setq ispell-local-dictionary-alist
730 `((nil "[[:alpha:]]" "[^[:alpha:]]"
b1ed9ee8
AB
731 "['\x2019]" nil ("-B") nil utf-8))
732 ispell-program-name (executable-find "hunspell"))
41d290a2
AB
733 ;; don't send ’ to the subprocess
734 (defun endless/replace-apostrophe (args)
735 (cons (replace-regexp-in-string
736 "’" "'" (car args))
737 (cdr args)))
738 (advice-add #'ispell-send-string :filter-args
739 #'endless/replace-apostrophe)
740
741 ;; convert ' back to ’ from the subprocess
742 (defun endless/replace-quote (args)
743 (if (not (derived-mode-p 'org-mode))
744 args
745 (cons (replace-regexp-in-string
746 "'" "’" (car args))
747 (cdr args))))
748 (advice-add #'ispell-parse-output :filter-args
749 #'endless/replace-quote))
750
47904cb7 751(use-package abbrev
1060413b 752 :hook (text-mode . abbrev-mode))
54209e74 753
b57457b2
AB
754\f
755;;; Programming modes
756
47904cb7 757(use-package lisp-mode
41d290a2 758 :config
41d290a2
AB
759 (defun indent-spaces-mode ()
760 (setq indent-tabs-mode nil))
761 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
762
fac1032c
AB
763(use-package alloy-mode
764 :mode "\\.\\(als\\|dsh\\)\\'"
765 :config
766 (setq alloy-basic-offset 2)
767 ;; (defun b/alloy-simple-indent (start end)
768 ;; (interactive "r")
769 ;; ;; (if (region-active-p)
770 ;; ;; (indent-rigidly start end alloy-basic-offset)
771 ;; ;; (if (bolp)
772 ;; ;; (indent-rigidly (line-beginning-position)
773 ;; ;; (line-end-position)
774 ;; ;; alloy-basic-offset)))
775 ;; (indent-to (+ (current-column) alloy-basic-offset)))
776 :bind (:map alloy-mode-map
777 ("RET" . electric-newline-and-maybe-indent)
778 ;; ("TAB" . b/alloy-simple-indent)
779 ("TAB" . indent-for-tab-command))
780 :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
781
33273849 782(use-package lean-mode
46b0569f 783 :disabled
33273849 784 :defer 0.4
46b0569f 785 :init (eval-when-compile (defvar lean-mode-map))
33273849
AB
786 :bind (:map lean-mode-map
787 ("S-SPC" . company-complete))
788 :config
789 (require 'lean-input)
790 (setq default-input-method "Lean"
791 lean-input-tweak-all '(lean-input-compose
792 (lean-input-prepend "/")
793 (lean-input-nonempty))
794 lean-input-user-translations '(("/" "/")))
795 (lean-input-setup))
796
47904cb7 797(use-package sgml-mode
41d290a2 798 :config
5dfaee4c 799 (setq sgml-basic-offset 0))
41d290a2 800
47904cb7 801(use-package css-mode
41d290a2
AB
802 :config
803 (setq css-indent-offset 2))
804
46b0569f
AB
805(use-package geiser
806 :disabled)
41d290a2 807
47904cb7 808(use-package geiser-guile
46b0569f 809 :disabled
41d290a2
AB
810 :config
811 (setq geiser-guile-load-path "~/src/git/guix"))
812
46b0569f
AB
813(use-package guix
814 :disabled)
41d290a2 815
47904cb7
AB
816(use-package go-mode
817 :disabled)
99473567 818
f704f564 819(use-package po-mode
46b0569f 820 :disabled
f704f564
AB
821 :hook
822 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
823
a2feb3de
AB
824(use-package auctex
825 :disabled
826 :custom
827 (font-latex-fontify-sectioning 'color))
828
47904cb7 829(use-package tex-mode
748bd8ac
AB
830 :config
831 (cl-delete-if
832 (lambda (p) (string-match "^---?" (car p)))
0758ec38
AB
833 tex--prettify-symbols-alist)
834 :hook ((tex-mode . auto-fill-mode)
3457307b 835 (tex-mode . flyspell-mode)))
748bd8ac 836
47904cb7
AB
837;; (use-package george-mode
838;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
839;; :mode "\\.grg\\'")
1d01c927 840
b57457b2 841\f
b57457b2 842;;; Emacs enhancements & auxiliary packages
1eb20313 843
dca50cf5 844(use-package man
41d290a2
AB
845 :config (setq Man-width 80))
846
847(use-package which-key
848 :defer 0.4
849 :config
850 (which-key-add-key-based-replacements
851 ;; prefixes for global prefixes and minor modes
41d290a2 852 "C-c !" "flycheck"
b549b760 853 "C-x RET" "coding system"
41d290a2 854 "C-x 8" "unicode"
b549b760 855 "C-x @" "event modifiers"
41d290a2
AB
856 "C-x a" "abbrev/expand"
857 "C-x r" "rectangle/register/bookmark"
b549b760 858 "C-x t" "tabs"
41d290a2 859 "C-x v" "version control"
b549b760
AB
860 "C-x X" "edebug"
861 "C-x C-a" "edebug"
862 "C-x C-k" "kmacro"
41d290a2 863 ;; prefixes for my personal bindings
b549b760 864 "C-c &" "yasnippet"
41d290a2
AB
865 "C-c a" "applications"
866 "C-c a e" "erc"
867 "C-c a o" "org"
868 "C-c a s" "shells"
2e81c51a 869 "C-c b" "buffers"
41d290a2
AB
870 "C-c c" "compile-and-comments"
871 "C-c e" "eval"
872 "C-c f" "files"
873 "C-c F" "frames"
ef6c487c 874 "C-c g" "magit"
41d290a2 875 "C-S-h" "help(ful)"
41d290a2 876 "C-c q" "boxquote"
1eb20313 877 "C-c t" "themes")
41d290a2
AB
878
879 ;; prefixes for major modes
41d290a2
AB
880 (which-key-add-major-mode-key-based-replacements 'org-mode
881 "C-c C-v" "org-babel")
41d290a2
AB
882
883 (which-key-mode)
884 :custom
885 (which-key-add-column-padding 5)
1eb20313
AB
886 (which-key-idle-delay 10000)
887 (which-key-idle-secondary-delay 0.05)
888 (which-key-max-description-length 32)
889 (which-key-show-early-on-C-h t))
41d290a2 890
1eb20313 891;; (require 'bandali-projectile)
41d290a2
AB
892
893(use-package helpful
1eb20313 894 :disabled
41d290a2
AB
895 :defer 0.6
896 :bind
897 (("C-S-h c" . helpful-command)
898 ("C-S-h f" . helpful-callable) ; helpful-function
899 ("C-S-h v" . helpful-variable)
900 ("C-S-h k" . helpful-key)
901 ("C-S-h p" . helpful-at-point)))
902
5b10d879
AB
903(use-package unkillable-scratch
904 :defer 0.6
905 :config
906 (unkillable-scratch 1)
907 :custom
908 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
41d290a2 909
5b10d879
AB
910;; ,----
911;; | make pretty boxed quotes like this
912;; `----
913(use-package boxquote
914 :defer 0.6
915 :bind
1eb20313
AB
916 (:prefix-map
917 b/boxquote-prefix-map
918 :prefix "C-c q"
919 ("b" . boxquote-buffer)
920 ("B" . boxquote-insert-buffer)
921 ("d" . boxquote-defun)
922 ("F" . boxquote-insert-file)
923 ("hf" . boxquote-describe-function)
924 ("hk" . boxquote-describe-key)
925 ("hv" . boxquote-describe-variable)
926 ("hw" . boxquote-where-is)
927 ("k" . boxquote-kill)
928 ("p" . boxquote-paragraph)
929 ("q" . boxquote-boxquote)
930 ("r" . boxquote-region)
931 ("s" . boxquote-shell-command)
932 ("t" . boxquote-text)
933 ("T" . boxquote-title)
934 ("u" . boxquote-unbox)
935 ("U" . boxquote-unbox-region)
936 ("y" . boxquote-yank)
937 ("M-q" . boxquote-fill-paragraph)
938 ("M-w" . boxquote-kill-ring-save)))
41d290a2 939
41d290a2 940(use-package hl-todo
1eb20313 941 ;; highlight TODOs in buffers
41d290a2
AB
942 :defer 0.5
943 :config
944 (global-hl-todo-mode))
945
41d290a2 946(use-package page-break-lines
b57457b2 947 :defer 0.5
2f5d8190
AB
948 :custom
949 (page-break-lines-max-width fill-column)
41d290a2
AB
950 :config
951 (global-page-break-lines-mode))
952
953(use-package expand-region
954 :bind ("C-=" . er/expand-region))
955
1eb20313
AB
956(require 'bandali-yasnippet)
957
33273849 958(use-package debbugs
ba45b932
AB
959 :bind
960 (("C-c D d" . debbugs-gnu)
8cee0db4 961 ("C-c D b" . debbugs-gnu-bugs)
ba45b932
AB
962 ("C-c D e" .
963 (lambda ()
d6c37a13 964 (interactive) ; bug-gnu-emacs
ba45b932
AB
965 (setq debbugs-gnu-current-suppress t)
966 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
d6c37a13 967 ("C-c D g" . ; bug-gnuzilla
ba45b932
AB
968 (lambda ()
969 (interactive)
970 (setq debbugs-gnu-current-suppress t)
64b53575 971 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
d6c37a13
AB
972 ("C-c D G b" . ; bug-guix
973 (lambda ()
974 (interactive)
975 (setq debbugs-gnu-current-suppress t)
976 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
977 ("C-c D G p" . ; guix-patches
64b53575
AB
978 (lambda ()
979 (interactive)
980 (setq debbugs-gnu-current-suppress t)
d6c37a13 981 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
41d290a2 982
f0a2dfe1
AB
983(comment
984
41d290a2
AB
985(use-package org-ref
986 :init
dca50cf5 987 (b/setq-every '("~/usr/org/references.bib")
41d290a2
AB
988 reftex-default-bibliography
989 org-ref-default-bibliography)
990 (setq
991 org-ref-bibliography-notes "~/usr/org/notes.org"
992 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
993
2f5d8190
AB
994;; (use-package fill-column-indicator)
995
47904cb7 996(use-package window
ed8c4fa9 997 :bind
0b7f98f4 998 (("C-c w s l" . (lambda ()
edb03389
AB
999 (interactive)
1000 (split-window-right)
1001 (other-window 1)))
1002 ("C-c w s j" . (lambda ()
1003 (interactive)
1004 (split-window-below)
1005 (other-window 1)))
446cb096 1006 ("C-c w q" . quit-window))
92df6c4f
AB
1007 :custom
1008 (split-width-threshold 150))
ed8c4fa9 1009
47904cb7 1010(use-package windmove
ed8c4fa9
AB
1011 :defer 0.6
1012 :bind
2e81c51a
AB
1013 (("C-c w h" . windmove-left)
1014 ("C-c w j" . windmove-down)
1015 ("C-c w k" . windmove-up)
1016 ("C-c w l" . windmove-right)
1017 ("C-c w H" . windmove-swap-states-left)
1018 ("C-c w J" . windmove-swap-states-down)
1019 ("C-c w K" . windmove-swap-states-up)
1020 ("C-c w L" . windmove-swap-states-right)))
ed8c4fa9 1021
05068e71
AB
1022(use-package pass
1023 :commands pass
1024 :bind ("C-c a p" . pass)
1025 :hook (pass-mode . View-exit))
1026
b188e798
AB
1027(use-package pdf-tools
1028 :defer 0.5
1029 :bind (:map pdf-view-mode-map
0365678c
AB
1030 ("<C-XF86Back>" . pdf-history-backward)
1031 ("<mouse-8>" . pdf-history-backward)
1032 ("<drag-mouse-8>" . pdf-history-backward)
1033 ("<C-XF86Forward>" . pdf-history-forward)
1034 ("<mouse-9>" . pdf-history-forward)
1035 ("<drag-mouse-9>" . pdf-history-forward)
4fa43cd8
AB
1036 ("M-RET" . image-previous-line)
1037 ("C-s" . isearch-forward)
1038 ("s s" . isearch-forward))
822ac360
AB
1039 :config (pdf-tools-install nil t)
1040 :custom (pdf-view-resize-factor 1.05))
b188e798 1041
62a2088e 1042(use-package org-pdftools
47904cb7 1043 :disabled
62a2088e
AB
1044 :straight (:host github :repo "fuxialexander/org-pdftools")
1045 :demand
1046 :after org
1047 :config
1048 (with-eval-after-load 'org
1049 (require 'org-pdftools)))
1050
9de75957
AB
1051(use-package biblio)
1052
47904cb7 1053(use-package reftex
9a5ffb33
AB
1054 :hook (latex-mode . reftex-mode))
1055
47904cb7 1056(use-package reftex-cite
9a5ffb33
AB
1057 :after reftex
1058 :disabled ; enable to disable
1059 ; reftex-cite's default choice
1060 ; of previous word
1061 :config
1062 (defun reftex-get-bibkey-default ()
1063 "If the cursor is in a citation macro, return the word before the macro."
1064 (let* ((macro (reftex-what-macro 1)))
1065 (save-excursion
1066 (when (and macro (string-match "cite" (car macro)))
1067 (goto-char (cdr macro)))
1068 (reftex-this-word)))))
1069
fa9943dc 1070(use-package dmenu
fa9943dc 1071 :custom
fa9943dc
AB
1072 (dmenu-prompt-string "run: ")
1073 (dmenu-save-file (b/var "dmenu-items")))
1074
996bebf6
AB
1075(use-package eosd
1076 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1077 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1078 :disabled
1079 :straight (:host github :repo "clarete/eosd")
1080 :demand
1081 :after exwm
1082 :config
1083 (eosd-start))
1084
9ed5410e 1085(use-package eww
03745e6e 1086 :bind ("C-c a e w" . eww)
9ed5410e
AB
1087 :custom
1088 (eww-download-directory (file-name-as-directory
1089 (getenv "XDG_DOWNLOAD_DIR"))))
1090
b57457b2 1091\f
b57457b2
AB
1092;;; Post initialization
1093
8b1a2f32 1094)
41d290a2
AB
1095(message "Loading %s...done (%.3fs)" user-init-file
1096 (float-time (time-subtract (current-time)
dca50cf5 1097 b/before-user-init-time)))
41d290a2
AB
1098
1099;;; init.el ends here