Assimilate EBDB and move email setup to separate files in lisp/
[~bandali/configs] / init.el
CommitLineData
33b1a7ea 1;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
41d290a2 2
33b1a7ea 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
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
AB
97\f
98;;; comment macro
99
100;; useful for commenting out multiple sexps at a time
101(defmacro comment (&rest _)
102 "Comment out one or more s-expressions."
103 (declare (indent defun))
104 nil)
105
106\f
33273849
AB
107;;; Package management
108
032726b6
AB
109(progn ; `borg'
110 (add-to-list 'load-path
111 (expand-file-name "lib/borg" user-emacs-directory))
112 (require 'borg)
113 (borg-initialize)
114 (setq borg-rewrite-urls-alist
115 '(("git@github.com:" . "https://github.com/")
116 ("git@gitlab.com:" . "https://gitlab.com/"))))
33273849
AB
117
118;; use-package
41d290a2
AB
119(if nil ; set to t when need to debug init
120 (progn
121 (setq use-package-verbose t
122 use-package-expand-minimally nil
123 use-package-compute-statistics t
124 debug-on-error t)
125 (require 'use-package))
126 (setq use-package-verbose nil
127 use-package-expand-minimally t))
128
129(setq use-package-always-defer t)
130(require 'bind-key)
131
b57457b2
AB
132\f
133;;; Initial setup
134
135;; keep ~/.emacs.d clean
1060413b
AB
136(use-package no-littering
137 :demand
138 :config
139 (defalias 'b/etc 'no-littering-expand-etc-file-name)
140 (defalias 'b/var 'no-littering-expand-var-file-name))
41d290a2 141
032726b6
AB
142(use-package auto-compile
143 :demand
144 :config
145 (auto-compile-on-load-mode)
146 (auto-compile-on-save-mode)
147 (setq auto-compile-display-buffer nil)
148 (setq auto-compile-mode-line-counter t)
149 (setq auto-compile-source-recreate-deletes-dest t)
150 (setq auto-compile-toggle-deletes-nonlib-dest t)
151 (setq auto-compile-update-autoloads t))
152
b57457b2 153;; separate custom file (don't want it mixing with init.el)
47904cb7 154(use-package custom
60ff805e 155 :no-require
41d290a2 156 :config
dca50cf5 157 (setq custom-file (b/etc "custom.el"))
41d290a2
AB
158 (when (file-exists-p custom-file)
159 (load custom-file))
b57457b2 160 ;; while at it, treat themes as safe
60ff805e
AB
161 (setf custom-safe-themes t)
162 ;; only one custom theme at a time
163 (comment
164 (defadvice load-theme (before clear-previous-themes activate)
165 "Clear existing theme settings instead of layering them"
166 (mapc #'disable-theme custom-enabled-themes))))
41d290a2 167
b57457b2 168;; load the secrets file if it exists, otherwise show a warning
dca50cf5
AB
169(comment
170 (with-demoted-errors
171 (load (b/etc "secrets"))))
41d290a2 172
b57457b2
AB
173;; start up emacs server. see
174;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
47904cb7 175(use-package server
f7910e3d 176 :defer 0.5
2087ae39
AB
177 :config
178 (declare-function server-edit "server")
179 (bind-key "C-c F D" 'server-edit)
180 (declare-function server-running-p "server")
181 (or (server-running-p) (server-mode)))
41d290a2 182
60ff805e
AB
183\f
184;;; Useful utilities
185
60ff805e
AB
186(defmacro b/setq-every (value &rest vars)
187 "Set all the variables from VARS to value VALUE."
188 (declare (indent defun) (debug t))
189 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
190
191(defun b/start-process (program &rest args)
192 "Same as `start-process', but doesn't bother about name and buffer."
193 (let ((process-name (concat program "_process"))
194 (buffer-name (generate-new-buffer-name
195 (concat program "_output"))))
196 (apply #'start-process
197 process-name buffer-name program args)))
198
199(defun b/dired-start-process (program &optional args)
200 "Open current file with a PROGRAM."
201 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
202 ;; be nil, so remove it).
2087ae39 203 (declare-function dired-get-file-for-visit "dired")
60ff805e
AB
204 (apply #'b/start-process
205 program
206 (remove nil (list args (dired-get-file-for-visit)))))
207
208(defun b/add-elisp-section ()
209 (interactive)
210 (insert "\n")
97141042 211 (forward-line -1)
60ff805e
AB
212 (insert "\n\f\n;;; "))
213
a1e77a3d
AB
214;; (defvar b/fill-column 47
215;; "My custom `fill-column'.")
3214b7ca
AB
216
217(defconst b/asterism "* * *")
218
bc2f85e1 219(defun b/insert-asterism ()
3214b7ca 220 "Insert a centred asterism."
bc2f85e1 221 (interactive)
3214b7ca
AB
222 (insert
223 (concat
224 "\n\n"
a1e77a3d 225 (make-string (floor (/ (- fill-column (length b/asterism)) 2))
3214b7ca
AB
226 ?\s)
227 b/asterism
228 "\n\n")))
bc2f85e1 229
60ff805e
AB
230(defun b/no-mouse-autoselect-window ()
231 "Conveniently disable `focus-follows-mouse'.
232For disabling the behaviour for certain buffers and/or modes."
233 (make-local-variable 'mouse-autoselect-window)
234 (setq mouse-autoselect-window nil))
235
a5cc22f4
AB
236(defun b/kill-current-buffer ()
237 "Kill the current buffer."
238 ;; also see https://redd.it/64xb3q
239 (interactive)
240 (kill-buffer (current-buffer)))
241
60ff805e
AB
242\f
243;;; Defaults
244
245;;;; C-level customizations
246
247(setq
248 ;; minibuffer
249 enable-recursive-minibuffers t
250 resize-mini-windows t
251 ;; more useful frame titles
252 frame-title-format '("" invocation-name " - "
253 (:eval
254 (if (buffer-file-name)
255 (abbreviate-file-name (buffer-file-name))
256 "%b")))
257 ;; i don't feel like jumping out of my chair every now and again; so
258 ;; don't BEEP! at me, emacs
259 ring-bell-function 'ignore
260 ;; better scrolling
261 ;; scroll-margin 1
262 ;; scroll-conservatively 10000
263 scroll-step 1
264 scroll-conservatively 10
265 scroll-preserve-screen-position 1
266 ;; focus follows mouse
39cc9c96 267 mouse-autoselect-window t)
60ff805e
AB
268
269(setq-default
270 ;; always use space for indentation
271 indent-tabs-mode nil
272 tab-width 4
273 ;; cursor shape
567440fa 274 cursor-type t)
60ff805e 275
b57457b2
AB
276;; unicode support
277(comment
278 (dolist (ft (fontset-list))
279 (set-fontset-font
280 ft
281 'unicode
282 (font-spec :name "Source Code Pro" :size 14))
283 (set-fontset-font
284 ft
285 'unicode
286 (font-spec :name "DejaVu Sans Mono")
287 nil
288 'append)
289 ;; (set-fontset-font
290 ;; ft
291 ;; 'unicode
292 ;; (font-spec
293 ;; :name "Symbola monospacified for DejaVu Sans Mono")
294 ;; nil
295 ;; 'append)
296 ;; (set-fontset-font
297 ;; ft
298 ;; #x2115 ; ℕ
299 ;; (font-spec :name "DejaVu Sans Mono")
300 ;; nil
301 ;; 'append)
302 (set-fontset-font
303 ft
304 (cons ?Α ?ω)
305 (font-spec :name "DejaVu Sans Mono" :size 14)
306 nil
307 'prepend)))
308
60ff805e 309;;;; Elisp-level customizations
41d290a2 310
47904cb7 311(use-package startup
60ff805e
AB
312 :no-require
313 :demand
41d290a2 314 :config
60ff805e
AB
315 ;; don't need to see the startup echo area message
316 (advice-add #'display-startup-echo-area-message :override #'ignore)
317 :custom
318 ;; i want *scratch* as my startup buffer
319 (initial-buffer-choice t)
320 ;; i don't need the default hint
321 (initial-scratch-message nil)
322 ;; use customizable text-mode as major mode for *scratch*
2568a634 323 ;; (initial-major-mode 'text-mode)
60ff805e
AB
324 ;; inhibit buffer list when more than 2 files are loaded
325 (inhibit-startup-buffer-menu t)
326 ;; don't need to see the startup screen or echo area message
327 (inhibit-startup-screen t)
328 (inhibit-startup-echo-area-message user-login-name))
41d290a2 329
47904cb7 330(use-package files
60ff805e
AB
331 :no-require
332 :demand
9fc30d4c 333 :custom
60ff805e
AB
334 ;; backups (C-h v make-backup-files RET)
335 (backup-by-copying t)
336 (version-control t)
337 (delete-old-versions t)
41d290a2 338
60ff805e
AB
339 ;; auto-save
340 (auto-save-file-name-transforms
341 `((".*" ,(b/var "auto-save/") t)))
41d290a2 342
60ff805e
AB
343 ;; insert newline at the end of files
344 (require-final-newline t)
b57457b2 345
60ff805e
AB
346 ;; open read-only file buffers in view-mode
347 ;; (enables niceties like `q' for quit)
348 (view-read-only t))
41d290a2 349
60ff805e
AB
350;; disable disabled commands
351(setq disabled-command-function nil)
41d290a2 352
60ff805e
AB
353;; lazy-person-friendly yes/no prompts
354(defalias 'yes-or-no-p #'y-or-n-p)
b57457b2 355
60ff805e 356;; enable automatic reloading of changed buffers and files
47904cb7 357(use-package autorevert
60ff805e
AB
358 :demand
359 :config
360 (global-auto-revert-mode 1)
361 :custom
362 (auto-revert-verbose nil)
363 (global-auto-revert-non-file-buffers nil))
b57457b2
AB
364
365;; time and battery in mode-line
47904cb7 366(use-package time
e4902e0b 367 :demand
64938292
AB
368 :config
369 (display-time-mode)
370 :custom
371 (display-time-default-load-average nil)
f7910e3d 372 (display-time-format " %a %b %-e %-l:%M%P")
ad61316b
AB
373 (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center))
374 (display-time-use-mail-icon t))
64938292 375
47904cb7 376(use-package battery
e4902e0b 377 :demand
64938292
AB
378 :config
379 (display-battery-mode)
380 :custom
f7910e3d 381 (battery-mode-line-format "%p%% %t"))
b57457b2 382
47904cb7 383(use-package fringe
60ff805e
AB
384 :demand
385 :config
386 ;; smaller fringe
387 ;; (fringe-mode '(3 . 1))
388 (fringe-mode nil))
41d290a2 389
47904cb7 390(use-package winner
60ff805e
AB
391 :demand
392 :config
393 ;; enable winner-mode (C-h f winner-mode RET)
394 (winner-mode 1))
41d290a2 395
47904cb7 396(use-package compile
60ff805e
AB
397 :config
398 ;; don't display *compilation* buffer on success. based on
399 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
400 ;; instead of the now obsolete `flet'.
dca50cf5 401 (defun b/compilation-finish-function (buffer outstr)
41d290a2
AB
402 (unless (string-match "finished" outstr)
403 (switch-to-buffer-other-window buffer))
404 t)
405
dca50cf5 406 (setq compilation-finish-functions #'b/compilation-finish-function)
41d290a2
AB
407
408 (require 'cl-macs)
409
410 (defadvice compilation-start
411 (around inhibit-display
412 (command &optional mode name-function highlight-regexp))
413 (if (not (string-match "^\\(find\\|grep\\)" command))
414 (cl-letf (((symbol-function 'display-buffer) #'ignore))
415 (save-window-excursion ad-do-it))
416 ad-do-it))
417 (ad-activate 'compilation-start))
418
47904cb7 419(use-package isearch
60ff805e
AB
420 :custom
421 ;; allow scrolling in Isearch
422 (isearch-allow-scroll t)
423 ;; search for non-ASCII characters: i’d like non-ASCII characters such
424 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
425 ;; counterpart. shoutout to
426 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
427 (search-default-mode #'char-fold-to-regexp))
428
429;; uncomment to extend the above behaviour to query-replace
430(comment
47904cb7 431 (use-package replace
60ff805e
AB
432 :custom
433 (replace-char-fold t)))
b9901074 434
47904cb7 435(use-package vc
b1a5d811
AB
436 :bind ("C-x v C-=" . vc-ediff))
437
47904cb7 438(use-package vc-git
e59c8878
AB
439 :after vc
440 :custom
441 (vc-git-print-log-follow t))
442
47904cb7 443(use-package ediff
b1a5d811
AB
444 :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo)
445 :custom ((ediff-window-setup-function 'ediff-setup-windows-plain)
446 (ediff-split-window-function 'split-window-horizontally)))
447
47904cb7 448(use-package face-remap
60ff805e
AB
449 :custom
450 ;; gentler font resizing
451 (text-scale-mode-step 1.05))
452
47904cb7 453(use-package mwheel
60ff805e
AB
454 :defer 0.4
455 :config
456 (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time
457 mouse-wheel-progressive-speed nil ; don't accelerate scrolling
458 mouse-wheel-follow-mouse t)) ; scroll window under mouse
459
47904cb7 460(use-package pixel-scroll
60ff805e
AB
461 :defer 0.4
462 :config (pixel-scroll-mode 1))
463
47904cb7 464(use-package epg-config
a89c8bd8
AB
465 :config
466 ;; ask for GPG passphrase in minibuffer
467 ;; this will fail if gpg>=2.1 is not available
97141042 468 (setq epg-pinentry-mode 'loopback)
60ff805e 469 :custom
47904cb7 470 (epg-gpg-program (executable-find "gpg")))
1d405cde 471
47904cb7
AB
472(use-package epg
473 :after epg-config)
474
a89c8bd8 475(use-package pinentry
8b1a2f32 476 :disabled
a89c8bd8
AB
477 :demand
478 :after (epa epg server)
479 :config
480 ;; workaround for systemd-based distros:
481 ;; (setq pinentry--socket-dir server-socket-dir)
482 (pinentry-start))
483
47904cb7 484(use-package auth-source
b98dbb3d
AB
485 :custom
486 (auth-sources '("~/.authinfo.gpg"))
487 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
488
b57457b2
AB
489\f
490;;; General bindings
491
41d290a2
AB
492(bind-keys
493 ("C-c a i" . ielm)
494
495 ("C-c e b" . eval-buffer)
2a816b71 496 ("C-c e e" . eval-last-sexp)
12ff40a3 497 ("C-c e p" . pp-macroexpand-last-sexp)
41d290a2
AB
498 ("C-c e r" . eval-region)
499
500 ("C-c e i" . emacs-init-time)
501 ("C-c e u" . emacs-uptime)
dca50cf5 502 ("C-c e v" . emacs-version)
41d290a2 503
567440fa
AB
504 ("C-c f ." . find-file)
505 ("C-c f d" . find-name-dired)
506 ("C-c f l" . find-library)
507
41d290a2
AB
508 ("C-c F m" . make-frame-command)
509 ("C-c F d" . delete-frame)
41d290a2 510
41d290a2
AB
511 ("C-S-h C" . describe-char)
512 ("C-S-h F" . describe-face)
513
567440fa
AB
514 ("C-c x" . execute-extended-command)
515
a5cc22f4 516 ("C-x k" . b/kill-current-buffer)
41d290a2 517 ("C-x K" . kill-buffer)
2a816b71
AB
518 ("C-x s" . save-buffer)
519 ("C-x S" . save-some-buffers)
41d290a2 520
b57457b2 521 :map emacs-lisp-mode-map
dca50cf5 522 ("<C-return>" . b/add-elisp-section))
41d290a2
AB
523
524(when (display-graphic-p)
525 (unbind-key "C-z" global-map))
526
500004f4
AB
527(bind-keys
528 ;; for back and forward mouse keys
0365678c 529 ("<XF86Back>" . previous-buffer)
500004f4 530 ("<mouse-8>" . previous-buffer)
4bdfe6ab 531 ;; ("<drag-mouse-8>" . previous-buffer)
0365678c 532 ("<XF86Forward>" . next-buffer)
500004f4 533 ("<mouse-9>" . next-buffer)
4bdfe6ab
AB
534 ;; ("<drag-mouse-9>" . next-buffer)
535 ;; ("<drag-mouse-2>" . kill-this-buffer)
536 ;; ("<drag-mouse-3>" . switch-to-buffer)
537 )
500004f4 538
b57457b2
AB
539\f
540;;; Essential packages
541
f7910e3d
AB
542(add-to-list
543 'load-path
544 (expand-file-name
545 (convert-standard-filename "lisp") user-emacs-directory))
546
8b1a2f32
AB
547(when b/exwm-p
548 (require 'bandali-exwm))
33273849 549
f7910e3d 550(require 'bandali-org)
41d290a2 551
b57457b2 552;; *the* right way to do git
41d290a2 553(use-package magit
2a816b71
AB
554 :bind (("C-x g" . magit-status)
555 ("C-c g g" . magit-status)
ef6c487c
AB
556 ("C-c g b" . magit-blame-addition)
557 ("C-c g l" . magit-log-buffer-file))
41d290a2 558 :config
2087ae39
AB
559 (declare-function magit-add-section-hook "magit-section"
560 (hook function &optional at append local))
41d290a2
AB
561 (magit-add-section-hook 'magit-status-sections-hook
562 'magit-insert-modules
563 'magit-insert-stashes
564 'append)
3b3615f5
AB
565 ;; (magit-add-section-hook 'magit-status-sections-hook
566 ;; 'magit-insert-ignored-files
567 ;; 'magit-insert-untracked-files
568 ;; 'append)
8a2e0eef 569 (setq magit-repository-directories '(("~/.emacs.d/" . 0)
81ea6e55 570 ("~/src/git/" . 2)))
41d290a2
AB
571 (nconc magit-section-initial-visibility-alist
572 '(([unpulled status] . show)
573 ([unpushed status] . show)))
2087ae39 574 (declare-function magit-display-buffer-fullframe-status-v1 "magit-mode" (buffer))
3fffeb0a
AB
575 :custom
576 (magit-diff-refine-hunk t)
577 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
6ca3a7b1 578 ;; (magit-completing-read-function 'magit-ido-completing-read)
41d290a2
AB
579 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
580
b57457b2 581;; recently opened files
47904cb7 582(use-package recentf
41d290a2 583 :defer 0.2
dca50cf5 584 ;; :config
9424b3d6 585 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
6eb104ff
AB
586 :config
587 (recentf-mode)
dca50cf5 588 :custom
1060413b 589 (recentf-max-saved-items 2000))
41d290a2 590
679463c6 591;; needed for history for counsel
6eb104ff
AB
592(use-package amx
593 :defer 0.3
594 :config
595 (amx-mode))
596
679463c6
AB
597;; (require 'bandali-ido)
598(require 'bandali-ivy)
41d290a2 599
679463c6 600(require 'bandali-eshell)
41d290a2 601
679463c6 602(require 'bandali-ibuffer)
41d290a2 603
47904cb7 604(use-package outline
2e81c51a 605 :disabled
41d290a2
AB
606 :hook (prog-mode . outline-minor-mode)
607 :bind
608 (:map
609 outline-minor-mode-map
610 ("<s-tab>" . outline-toggle-children)
611 ("M-p" . outline-previous-visible-heading)
612 ("M-n" . outline-next-visible-heading)
dca50cf5 613 :prefix-map b/outline-prefix-map
ed8c4fa9 614 :prefix "s-O"
41d290a2
AB
615 ("TAB" . outline-toggle-children)
616 ("a" . outline-hide-body)
617 ("H" . outline-hide-body)
618 ("S" . outline-show-all)
619 ("h" . outline-hide-subtree)
620 ("s" . outline-show-subtree)))
621
47904cb7 622(use-package ls-lisp
41d290a2
AB
623 :custom (ls-lisp-dirs-first t))
624
679463c6 625(require 'bandali-dired)
41d290a2 626
47904cb7 627(use-package help
41d290a2
AB
628 :config
629 (temp-buffer-resize-mode)
630 (setq help-window-select t))
631
47904cb7 632(use-package tramp
41d290a2
AB
633 :config
634 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
635 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
636 (add-to-list 'tramp-default-proxies-alist
637 (list (regexp-quote (system-name)) nil nil)))
638
47904cb7 639(use-package doc-view
41d290a2
AB
640 :bind (:map doc-view-mode-map
641 ("M-RET" . image-previous-line)))
642
e2178fd3 643;; Email (with Gnus, message, and EBDB)
2087ae39 644(require 'bandali-gnus)
2087ae39
AB
645(use-package sendmail
646 :config
647 (setq sendmail-program (executable-find "msmtp")
648 ;; message-sendmail-extra-arguments '("-v" "-d")
649 mail-specify-envelope-from t
650 mail-envelope-from 'header))
2087ae39 651(require 'bandali-message)
e2178fd3 652(require 'bandali-ebdb)
2087ae39 653
b57457b2
AB
654\f
655;;; Editing
2087ae39 656(comment
b57457b2 657;; highlight uncommitted changes in the left fringe
41d290a2 658(use-package diff-hl
df1c9bc8 659 :defer 0.6
41d290a2
AB
660 :config
661 (setq diff-hl-draw-borders nil)
662 (global-diff-hl-mode)
663 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
664
b57457b2 665;; display Lisp objects at point in the echo area
47904cb7 666(use-package eldoc
41d290a2
AB
667 :when (version< "25" emacs-version)
668 :config (global-eldoc-mode))
669
b57457b2 670;; highlight matching parens
47904cb7 671(use-package paren
41d290a2
AB
672 :demand
673 :config (show-paren-mode))
674
47904cb7 675(use-package elec-pair
40eddfea
AB
676 :demand
677 :config (electric-pair-mode))
678
47904cb7 679(use-package simple
60ff805e
AB
680 :config (column-number-mode)
681 :custom
682 ;; Save what I copy into clipboard from other applications into Emacs'
683 ;; kill-ring, which would allow me to still be able to easily access
684 ;; it in case I kill (cut or copy) something else inside Emacs before
685 ;; yanking (pasting) what I'd originally intended to.
686 (save-interprogram-paste-before-kill t))
41d290a2 687
b57457b2 688;; save minibuffer history
47904cb7 689(use-package savehist
1060413b 690 :demand
dca50cf5
AB
691 :config
692 (savehist-mode)
1060413b 693 (add-to-list 'savehist-additional-variables 'kill-ring))
41d290a2 694
b57457b2 695;; automatically save place in files
47904cb7 696(use-package saveplace
41d290a2 697 :when (version< "25" emacs-version)
1060413b 698 :config (save-place-mode))
41d290a2 699
47904cb7 700(use-package prog-mode
41d290a2
AB
701 :config (global-prettify-symbols-mode)
702 (defun indicate-buffer-boundaries-left ()
703 (setq indicate-buffer-boundaries 'left))
704 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
705
47904cb7 706(use-package text-mode
bc2f85e1 707 :bind (:map text-mode-map ("C-*" . b/insert-asterism))
93a86536
AB
708 :hook ((text-mode . indicate-buffer-boundaries-left)
709 (text-mode . flyspell-mode)))
41d290a2 710
47904cb7 711(use-package conf-mode
300b7363
AB
712 :mode "\\.*rc$")
713
47904cb7 714(use-package sh-mode
300b7363
AB
715 :mode "\\.bashrc$")
716
41d290a2 717(use-package company
ccade202 718 :disabled
41d290a2
AB
719 :bind
720 (:map company-active-map
721 ([tab] . company-complete-common-or-cycle)
d39234b9
AB
722 ([escape] . company-abort)
723 ("C-p" . company-select-previous-or-abort)
724 ("C-n" . company-select-next-or-abort))
41d290a2
AB
725 :custom
726 (company-minimum-prefix-length 1)
727 (company-selection-wrap-around t)
728 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
729 (company-dabbrev-downcase nil)
730 (company-dabbrev-ignore-case nil)
6eb104ff
AB
731 ;; :config
732 ;; (global-company-mode t)
733 )
41d290a2
AB
734
735(use-package flycheck
736 :defer 0.6
737 :hook (prog-mode . flycheck-mode)
738 :bind
739 (:map flycheck-mode-map
740 ("M-P" . flycheck-previous-error)
741 ("M-N" . flycheck-next-error))
742 :config
743 ;; Use the load-path from running Emacs when checking elisp files
744 (setq flycheck-emacs-lisp-load-path 'inherit)
745
746 ;; Only flycheck when I actually save the buffer
54209e74
AB
747 (setq flycheck-check-syntax-automatically '(mode-enabled save))
748 :custom (flycheck-mode-line-prefix "flyc"))
749
47904cb7 750(use-package flyspell)
41d290a2
AB
751
752;; http://endlessparentheses.com/ispell-and-apostrophes.html
47904cb7 753(use-package ispell
41d290a2
AB
754 :defer 0.6
755 :config
756 ;; ’ can be part of a word
757 (setq ispell-local-dictionary-alist
758 `((nil "[[:alpha:]]" "[^[:alpha:]]"
b1ed9ee8
AB
759 "['\x2019]" nil ("-B") nil utf-8))
760 ispell-program-name (executable-find "hunspell"))
41d290a2
AB
761 ;; don't send ’ to the subprocess
762 (defun endless/replace-apostrophe (args)
763 (cons (replace-regexp-in-string
764 "’" "'" (car args))
765 (cdr args)))
766 (advice-add #'ispell-send-string :filter-args
767 #'endless/replace-apostrophe)
768
769 ;; convert ' back to ’ from the subprocess
770 (defun endless/replace-quote (args)
771 (if (not (derived-mode-p 'org-mode))
772 args
773 (cons (replace-regexp-in-string
774 "'" "’" (car args))
775 (cdr args))))
776 (advice-add #'ispell-parse-output :filter-args
777 #'endless/replace-quote))
778
47904cb7 779(use-package abbrev
1060413b 780 :hook (text-mode . abbrev-mode))
54209e74 781
b57457b2
AB
782\f
783;;; Programming modes
784
47904cb7 785(use-package lisp-mode
41d290a2 786 :config
41d290a2
AB
787 (defun indent-spaces-mode ()
788 (setq indent-tabs-mode nil))
789 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
790
47904cb7 791(use-package reveal
54209e74
AB
792 :hook (emacs-lisp-mode . reveal-mode))
793
47904cb7
AB
794(use-package elisp-mode)
795
796;; (use-package alloy-mode
797;; :straight (:host github :repo "dwwmmn/alloy-mode")
798;; :mode "\\.\\(als\\|dsh\\)\\'"
799;; :config
800;; (setq alloy-basic-offset 2)
801;; ;; (defun b/alloy-simple-indent (start end)
802;; ;; (interactive "r")
803;; ;; ;; (if (region-active-p)
804;; ;; ;; (indent-rigidly start end alloy-basic-offset)
805;; ;; ;; (if (bolp)
806;; ;; ;; (indent-rigidly (line-beginning-position)
807;; ;; ;; (line-end-position)
808;; ;; ;; alloy-basic-offset)))
809;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
810;; :bind (:map alloy-mode-map
811;; ("RET" . electric-newline-and-maybe-indent)
812;; ;; ("TAB" . b/alloy-simple-indent)
813;; ("TAB" . indent-for-tab-command))
814;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
33273849
AB
815
816(eval-when-compile (defvar lean-mode-map))
817(use-package lean-mode
33273849
AB
818 :defer 0.4
819 :bind (:map lean-mode-map
820 ("S-SPC" . company-complete))
821 :config
822 (require 'lean-input)
823 (setq default-input-method "Lean"
824 lean-input-tweak-all '(lean-input-compose
825 (lean-input-prepend "/")
826 (lean-input-nonempty))
827 lean-input-user-translations '(("/" "/")))
828 (lean-input-setup))
829
68b2cdaa
AB
830(use-package mhtml-mode)
831
47904cb7 832(use-package sgml-mode
41d290a2 833 :config
5dfaee4c 834 (setq sgml-basic-offset 0))
41d290a2 835
47904cb7 836(use-package css-mode
41d290a2
AB
837 :config
838 (setq css-indent-offset 2))
839
41d290a2 840(use-package emmet-mode
68b2cdaa 841 :after (:any mhtml-mode css-mode sgml-mode)
41d290a2
AB
842 :bind* (("C-)" . emmet-next-edit-point)
843 ("C-(" . emmet-prev-edit-point))
844 :config
845 (unbind-key "C-j" emmet-mode-keymap)
846 (setq emmet-move-cursor-between-quotes t)
92ad9675 847 :hook (css-mode html-mode sgml-mode))
41d290a2 848
1060413b 849(use-package geiser)
41d290a2 850
47904cb7 851(use-package geiser-guile
41d290a2
AB
852 :config
853 (setq geiser-guile-load-path "~/src/git/guix"))
854
855(use-package guix)
856
b57457b2
AB
857(comment
858 (use-package auctex
859 :custom
860 (font-latex-fontify-sectioning 'color)))
861
47904cb7
AB
862(use-package go-mode
863 :disabled)
99473567 864
f704f564
AB
865(use-package po-mode
866 :hook
867 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
868
47904cb7 869(use-package tex-mode
748bd8ac
AB
870 :config
871 (cl-delete-if
872 (lambda (p) (string-match "^---?" (car p)))
0758ec38
AB
873 tex--prettify-symbols-alist)
874 :hook ((tex-mode . auto-fill-mode)
3457307b 875 (tex-mode . flyspell-mode)))
748bd8ac 876
47904cb7
AB
877;; (use-package george-mode
878;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
879;; :mode "\\.grg\\'")
1d01c927 880
b57457b2
AB
881\f
882;;; Theme
883
dca50cf5
AB
884(add-to-list 'custom-theme-load-path
885 (expand-file-name
886 (convert-standard-filename "lisp") user-emacs-directory))
b57457b2
AB
887(load-theme 'tangomod t)
888
889(use-package smart-mode-line
890 :commands (sml/apply-theme)
891 :demand
892 :config
8f2b3cb6
AB
893 ;; thanks, but no thnaks; don't make fixed-width fills.
894 (defun sml/fill-for-buffer-identification () "")
0f4b61b6 895 (setq sml/theme 'tangomod)
26906e22
AB
896 (sml/setup)
897 (smart-mode-line-enable))
b57457b2 898
cce35aca
AB
899(use-package doom-modeline
900 :disabled
901 :demand
902 :hook (after-init . doom-modeline-init)
903 :custom
904 (doom-modeline-buffer-file-name-style 'relative-to-project))
905
96611976 906(use-package doom-themes)
eb42934e 907
96611976 908(use-package moody
d4afaf1b 909 :disabled
eb42934e
AB
910 :demand
911 :config
96611976 912 (setq x-underline-at-descent-line t)
eb42934e
AB
913 (let ((line (face-attribute 'mode-line :underline)))
914 (set-face-attribute 'mode-line nil :overline line)
915 (set-face-attribute 'mode-line-inactive nil :overline line)
916 (set-face-attribute 'mode-line-inactive nil :underline line)
917 (set-face-attribute 'mode-line nil :box nil)
918 (set-face-attribute 'mode-line-inactive nil :box nil)
958286c5 919 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
eb42934e
AB
920 (moody-replace-mode-line-buffer-identification)
921 (moody-replace-vc-mode))
b57457b2 922
0b085e06
AB
923(use-package mini-modeline
924 :disabled
925 :demand
926 :config (mini-modeline-mode))
927
dca50cf5 928(defvar b/org-mode-font-lock-keywords
b57457b2
AB
929 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
930 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
931 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
96611976
AB
932 (4 '(:foreground "#c5c8c6") t))) ; title
933 "For use with the `doom-tomorrow-night' theme.")
b57457b2 934
dca50cf5 935(defun b/lights-on ()
b57457b2
AB
936 "Enable my favourite light theme."
937 (interactive)
938 (mapc #'disable-theme custom-enabled-themes)
96611976 939 (load-theme 'tangomod t)
22fff83b
AB
940 (when (featurep 'smart-mode-line)
941 (sml/apply-theme 'tangomod))
96611976 942 (font-lock-remove-keywords
e6c67861 943 'org-mode b/org-mode-font-lock-keywords)
d7e02391
AB
944 (when (featurep 'erc-hl-nicks)
945 (erc-hl-nicks-reset-face-table))
e6c67861
AB
946 (when (featurep 'exwm-systemtray)
947 (exwm-systemtray--refresh)))
b57457b2 948
dca50cf5 949(defun b/lights-off ()
b57457b2
AB
950 "Go dark."
951 (interactive)
952 (mapc #'disable-theme custom-enabled-themes)
96611976 953 (load-theme 'doom-one t)
22fff83b
AB
954 (when (featurep 'smart-mode-line)
955 (sml/apply-theme 'automatic))
96611976 956 (font-lock-add-keywords
e6c67861 957 'org-mode b/org-mode-font-lock-keywords t)
d7e02391
AB
958 (when (featurep 'erc-hl-nicks)
959 (erc-hl-nicks-reset-face-table))
e6c67861
AB
960 (when (featurep 'exwm-systemtray)
961 (exwm-systemtray--refresh)))
b57457b2
AB
962
963(bind-keys
2e81c51a
AB
964 ("C-c t d" . b/lights-off)
965 ("C-c t l" . b/lights-on))
b57457b2
AB
966
967\f
968;;; Emacs enhancements & auxiliary packages
969
dca50cf5 970(use-package man
41d290a2
AB
971 :config (setq Man-width 80))
972
973(use-package which-key
974 :defer 0.4
975 :config
976 (which-key-add-key-based-replacements
977 ;; prefixes for global prefixes and minor modes
978 "C-c @" "outline"
979 "C-c !" "flycheck"
b549b760 980 "C-x RET" "coding system"
41d290a2 981 "C-x 8" "unicode"
b549b760 982 "C-x @" "event modifiers"
41d290a2
AB
983 "C-x a" "abbrev/expand"
984 "C-x r" "rectangle/register/bookmark"
b549b760 985 "C-x t" "tabs"
41d290a2 986 "C-x v" "version control"
b549b760
AB
987 "C-x X" "edebug"
988 "C-x C-a" "edebug"
989 "C-x C-k" "kmacro"
41d290a2 990 ;; prefixes for my personal bindings
b549b760 991 "C-c &" "yasnippet"
41d290a2
AB
992 "C-c a" "applications"
993 "C-c a e" "erc"
994 "C-c a o" "org"
995 "C-c a s" "shells"
2e81c51a 996 "C-c b" "buffers"
41d290a2
AB
997 "C-c c" "compile-and-comments"
998 "C-c e" "eval"
999 "C-c f" "files"
1000 "C-c F" "frames"
ef6c487c 1001 "C-c g" "magit"
41d290a2
AB
1002 "C-S-h" "help(ful)"
1003 "C-c m" "multiple-cursors"
47904cb7
AB
1004 "C-c p" "projectile"
1005 "C-c p s" "projectile/search"
1006 "C-c p x" "projectile/execute"
1007 "C-c p 4" "projectile/other-window"
41d290a2 1008 "C-c q" "boxquote"
2e81c51a
AB
1009 "C-c t" "themes"
1010 ;; "s-O" "outline"
ef6c487c 1011 )
41d290a2
AB
1012
1013 ;; prefixes for major modes
1014 (which-key-add-major-mode-key-based-replacements 'message-mode
7cc51891 1015 "C-c f n" "footnote")
41d290a2
AB
1016 (which-key-add-major-mode-key-based-replacements 'org-mode
1017 "C-c C-v" "org-babel")
41d290a2
AB
1018
1019 (which-key-mode)
1020 :custom
1021 (which-key-add-column-padding 5)
1022 (which-key-max-description-length 32))
1023
b57457b2 1024(use-package crux ; results in Waiting for git... [2 times]
41d290a2 1025 :defer 0.4
2a816b71 1026 :bind (("C-c d" . crux-duplicate-current-line-or-region)
ba45b932 1027 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
205870c7
AB
1028 ("C-c f C" . crux-copy-file-preserve-attributes)
1029 ("C-c f D" . crux-delete-file-and-buffer)
1030 ("C-c f R" . crux-rename-file-and-buffer)
41d290a2
AB
1031 ("C-c j" . crux-top-join-line)
1032 ("C-S-j" . crux-top-join-line)))
1033
5b10d879
AB
1034(use-package mwim
1035 :bind (("C-a" . mwim-beginning-of-code-or-line)
1036 ("C-e" . mwim-end-of-code-or-line)
1037 ("<home>" . mwim-beginning-of-line-or-code)
1038 ("<end>" . mwim-end-of-line-or-code)))
41d290a2
AB
1039
1040(use-package projectile
ccade202 1041 :disabled
26906e22 1042 :defer 0.5
47904cb7 1043 :bind-keymap ("C-c p" . projectile-command-map)
41d290a2
AB
1044 :config
1045 (projectile-mode)
1046
dca50cf5 1047 (defun b/projectile-mode-line-fun ()
26906e22
AB
1048 "Report project name and type in the modeline."
1049 (let ((project-name (projectile-project-name))
1050 (project-type (projectile-project-type)))
1051 (format "%s%s"
1052 projectile-mode-line-prefix
1053 (if project-type
1054 (format ":%s" project-type)
1055 ""))))
dca50cf5 1056 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
26906e22 1057
41d290a2
AB
1058 (defun my-projectile-invalidate-cache (&rest _args)
1059 ;; ignore the args to `magit-checkout'
1060 (projectile-invalidate-cache nil))
1061
1062 (eval-after-load 'magit-branch
1063 '(progn
1064 (advice-add 'magit-checkout
1065 :after #'my-projectile-invalidate-cache)
1066 (advice-add 'magit-branch-and-checkout
1067 :after #'my-projectile-invalidate-cache)))
54209e74 1068 :custom
295b1b10 1069 (projectile-completion-system 'ivy)
54209e74 1070 (projectile-mode-line-prefix " proj"))
41d290a2
AB
1071
1072(use-package helpful
1073 :defer 0.6
1074 :bind
1075 (("C-S-h c" . helpful-command)
1076 ("C-S-h f" . helpful-callable) ; helpful-function
1077 ("C-S-h v" . helpful-variable)
1078 ("C-S-h k" . helpful-key)
1079 ("C-S-h p" . helpful-at-point)))
1080
5b10d879
AB
1081(use-package unkillable-scratch
1082 :defer 0.6
1083 :config
1084 (unkillable-scratch 1)
1085 :custom
1086 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
41d290a2 1087
5b10d879
AB
1088;; ,----
1089;; | make pretty boxed quotes like this
1090;; `----
1091(use-package boxquote
1092 :defer 0.6
1093 :bind
1094 (:prefix-map b/boxquote-prefix-map
1095 :prefix "C-c q"
1096 ("b" . boxquote-buffer)
1097 ("B" . boxquote-insert-buffer)
1098 ("d" . boxquote-defun)
1099 ("F" . boxquote-insert-file)
1100 ("hf" . boxquote-describe-function)
1101 ("hk" . boxquote-describe-key)
1102 ("hv" . boxquote-describe-variable)
1103 ("hw" . boxquote-where-is)
1104 ("k" . boxquote-kill)
1105 ("p" . boxquote-paragraph)
1106 ("q" . boxquote-boxquote)
1107 ("r" . boxquote-region)
1108 ("s" . boxquote-shell-command)
1109 ("t" . boxquote-text)
1110 ("T" . boxquote-title)
1111 ("u" . boxquote-unbox)
1112 ("U" . boxquote-unbox-region)
1113 ("y" . boxquote-yank)
1114 ("M-q" . boxquote-fill-paragraph)
1115 ("M-w" . boxquote-kill-ring-save)))
41d290a2
AB
1116
1117(use-package orgalist
3619fcff
AB
1118 ;; breaks auto-fill-mode, showing this error:
1119 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1120 :disabled
41d290a2
AB
1121 :after message
1122 :hook (message-mode . orgalist-mode))
1123
b57457b2 1124;; highlight TODOs in buffers
41d290a2
AB
1125(use-package hl-todo
1126 :defer 0.5
1127 :config
1128 (global-hl-todo-mode))
1129
41d290a2 1130(use-package multi-term
cce35aca 1131 :disabled
41d290a2 1132 :defer 0.6
fb078e63
AB
1133 :bind (("C-c a s m m" . multi-term)
1134 ("C-c a s m d" . multi-term-dedicated-toggle)
1135 ("C-c a s m p" . multi-term-prev)
1136 ("C-c a s m n" . multi-term-next)
41d290a2 1137 :map term-mode-map
0af1e91a 1138 ("C-c C-j" . term-char-mode))
41d290a2 1139 :config
96c704d7
AB
1140 (setq multi-term-program "screen"
1141 multi-term-program-switches (concat "-c"
1142 (getenv "XDG_CONFIG_HOME")
1143 "/screen/screenrc")
41d290a2
AB
1144 ;; TODO: add separate bindings for connecting to existing
1145 ;; session vs. always creating a new one
1146 multi-term-dedicated-select-after-open-p t
1147 multi-term-dedicated-window-height 20
1148 multi-term-dedicated-max-window-height 30
1149 term-bind-key-alist
1150 '(("C-c C-c" . term-interrupt-subjob)
1151 ("C-c C-e" . term-send-esc)
0af1e91a 1152 ("C-c C-j" . term-line-mode)
41d290a2 1153 ("C-k" . kill-line)
fb078e63
AB
1154 ;; ("C-y" . term-paste)
1155 ("C-y" . term-send-raw)
41d290a2
AB
1156 ("M-f" . term-send-forward-word)
1157 ("M-b" . term-send-backward-word)
1158 ("M-p" . term-send-up)
1159 ("M-n" . term-send-down)
fb078e63
AB
1160 ("M-j" . term-send-raw-meta)
1161 ("M-y" . term-send-raw-meta)
1162 ("M-/" . term-send-raw-meta)
1163 ("M-0" . term-send-raw-meta)
1164 ("M-1" . term-send-raw-meta)
1165 ("M-2" . term-send-raw-meta)
1166 ("M-3" . term-send-raw-meta)
1167 ("M-4" . term-send-raw-meta)
1168 ("M-5" . term-send-raw-meta)
1169 ("M-6" . term-send-raw-meta)
1170 ("M-7" . term-send-raw-meta)
1171 ("M-8" . term-send-raw-meta)
1172 ("M-9" . term-send-raw-meta)
41d290a2
AB
1173 ("<C-backspace>" . term-send-backward-kill-word)
1174 ("<M-DEL>" . term-send-backward-kill-word)
1175 ("M-d" . term-send-delete-word)
1176 ("M-," . term-send-raw)
1177 ("M-." . comint-dynamic-complete))
1178 term-unbind-key-alist
fb078e63
AB
1179 '("C-z" "C-x" "C-c" "C-h"
1180 ;; "C-y"
1181 "<ESC>")))
41d290a2
AB
1182
1183(use-package page-break-lines
b57457b2 1184 :defer 0.5
2f5d8190
AB
1185 :custom
1186 (page-break-lines-max-width fill-column)
41d290a2
AB
1187 :config
1188 (global-page-break-lines-mode))
1189
1190(use-package expand-region
1191 :bind ("C-=" . er/expand-region))
1192
1193(use-package multiple-cursors
1194 :bind
1195 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
dca50cf5 1196 (:prefix-map b/mc-prefix-map
41d290a2
AB
1197 :prefix "C-c m"
1198 ("c" . mc/edit-lines)
1199 ("n" . mc/mark-next-like-this)
1200 ("p" . mc/mark-previous-like-this)
1060413b 1201 ("a" . mc/mark-all-like-this))))
41d290a2 1202
41d290a2
AB
1203(use-package yasnippet
1204 :defer 0.6
1205 :config
1206 (defconst yas-verbosity-cur yas-verbosity)
1207 (setq yas-verbosity 2)
476f6228 1208 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
41d290a2
AB
1209 (yas-reload-all)
1210 (setq yas-verbosity yas-verbosity-cur)
5b185efa
AB
1211
1212 (defun b/yas--maybe-expand-key-filter (cmd)
1213 (when (and (yas--maybe-expand-key-filter cmd)
1214 (not (bound-and-true-p git-commit-mode)))
1215 cmd))
1216 (defconst b/yas-maybe-expand
1217 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1218 (define-key yas-minor-mode-map
1219 (kbd "SPC") b/yas-maybe-expand)
1220
476f6228 1221 (yas-global-mode))
41d290a2 1222
33273849 1223(use-package debbugs
ba45b932
AB
1224 :bind
1225 (("C-c D d" . debbugs-gnu)
8cee0db4 1226 ("C-c D b" . debbugs-gnu-bugs)
ba45b932
AB
1227 ("C-c D e" .
1228 (lambda ()
d6c37a13 1229 (interactive) ; bug-gnu-emacs
ba45b932
AB
1230 (setq debbugs-gnu-current-suppress t)
1231 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
d6c37a13 1232 ("C-c D g" . ; bug-gnuzilla
ba45b932
AB
1233 (lambda ()
1234 (interactive)
1235 (setq debbugs-gnu-current-suppress t)
64b53575 1236 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
d6c37a13
AB
1237 ("C-c D G b" . ; bug-guix
1238 (lambda ()
1239 (interactive)
1240 (setq debbugs-gnu-current-suppress t)
1241 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1242 ("C-c D G p" . ; guix-patches
64b53575
AB
1243 (lambda ()
1244 (interactive)
1245 (setq debbugs-gnu-current-suppress t)
d6c37a13 1246 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
41d290a2
AB
1247
1248(use-package org-ref
1249 :init
dca50cf5 1250 (b/setq-every '("~/usr/org/references.bib")
41d290a2
AB
1251 reftex-default-bibliography
1252 org-ref-default-bibliography)
1253 (setq
1254 org-ref-bibliography-notes "~/usr/org/notes.org"
1255 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1256
2f5d8190
AB
1257;; (use-package fill-column-indicator)
1258
47904cb7 1259(use-package window
ed8c4fa9 1260 :bind
edb03389
AB
1261 (("C-c w e" . (lambda ()
1262 (interactive)
1263 (split-window-right)
1264 (other-window 1)
1265 (erc-switch-to-buffer)))
1266 ("C-c w s l" . (lambda ()
1267 (interactive)
1268 (split-window-right)
1269 (other-window 1)))
1270 ("C-c w s j" . (lambda ()
1271 (interactive)
1272 (split-window-below)
1273 (other-window 1)))
446cb096 1274 ("C-c w q" . quit-window))
92df6c4f
AB
1275 :custom
1276 (split-width-threshold 150))
ed8c4fa9 1277
47904cb7 1278(use-package windmove
ed8c4fa9
AB
1279 :defer 0.6
1280 :bind
2e81c51a
AB
1281 (("C-c w h" . windmove-left)
1282 ("C-c w j" . windmove-down)
1283 ("C-c w k" . windmove-up)
1284 ("C-c w l" . windmove-right)
1285 ("C-c w H" . windmove-swap-states-left)
1286 ("C-c w J" . windmove-swap-states-down)
1287 ("C-c w K" . windmove-swap-states-up)
1288 ("C-c w L" . windmove-swap-states-right)))
ed8c4fa9 1289
05068e71
AB
1290(use-package pass
1291 :commands pass
1292 :bind ("C-c a p" . pass)
1293 :hook (pass-mode . View-exit))
1294
b188e798
AB
1295(use-package pdf-tools
1296 :defer 0.5
1297 :bind (:map pdf-view-mode-map
0365678c
AB
1298 ("<C-XF86Back>" . pdf-history-backward)
1299 ("<mouse-8>" . pdf-history-backward)
1300 ("<drag-mouse-8>" . pdf-history-backward)
1301 ("<C-XF86Forward>" . pdf-history-forward)
1302 ("<mouse-9>" . pdf-history-forward)
1303 ("<drag-mouse-9>" . pdf-history-forward)
4fa43cd8
AB
1304 ("M-RET" . image-previous-line)
1305 ("C-s" . isearch-forward)
1306 ("s s" . isearch-forward))
822ac360
AB
1307 :config (pdf-tools-install nil t)
1308 :custom (pdf-view-resize-factor 1.05))
b188e798 1309
62a2088e 1310(use-package org-pdftools
47904cb7 1311 :disabled
62a2088e
AB
1312 :straight (:host github :repo "fuxialexander/org-pdftools")
1313 :demand
1314 :after org
1315 :config
1316 (with-eval-after-load 'org
1317 (require 'org-pdftools)))
1318
9de75957
AB
1319(use-package biblio)
1320
47904cb7 1321(use-package reftex
9a5ffb33
AB
1322 :hook (latex-mode . reftex-mode))
1323
47904cb7 1324(use-package reftex-cite
9a5ffb33
AB
1325 :after reftex
1326 :disabled ; enable to disable
1327 ; reftex-cite's default choice
1328 ; of previous word
1329 :config
1330 (defun reftex-get-bibkey-default ()
1331 "If the cursor is in a citation macro, return the word before the macro."
1332 (let* ((macro (reftex-what-macro 1)))
1333 (save-excursion
1334 (when (and macro (string-match "cite" (car macro)))
1335 (goto-char (cdr macro)))
1336 (reftex-this-word)))))
1337
d141ce11
AB
1338(use-package minions
1339 :demand
1340 :config (minions-mode))
1341
fa9943dc 1342(use-package dmenu
fa9943dc 1343 :custom
fa9943dc
AB
1344 (dmenu-prompt-string "run: ")
1345 (dmenu-save-file (b/var "dmenu-items")))
1346
996bebf6
AB
1347(use-package eosd
1348 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1349 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1350 :disabled
1351 :straight (:host github :repo "clarete/eosd")
1352 :demand
1353 :after exwm
1354 :config
1355 (eosd-start))
1356
3280b75e
AB
1357(use-package scpaste
1358 :disabled
1359 :config
1360 (setq scpaste-http-destination "https://p.bndl.org"
1361 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1362
9ed5410e 1363(use-package eww
03745e6e 1364 :bind ("C-c a e w" . eww)
9ed5410e
AB
1365 :custom
1366 (eww-download-directory (file-name-as-directory
1367 (getenv "XDG_DOWNLOAD_DIR"))))
1368
b57457b2 1369\f
e3e5e846 1370;;; IRC (with ERC and ZNC)
b57457b2 1371
47904cb7 1372(use-package erc
e38333d9 1373 :bind (("C-c b b" . erc-switch-to-buffer)
96840c88
AB
1374 :map erc-mode-map
1375 ("M-a" . erc-track-switch-buffer))
1376 :custom
96840c88
AB
1377 (erc-join-buffer 'bury)
1378 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
1379 (erc-nick "bandali")
4d5a11b3 1380 (erc-prompt "erc>")
96840c88
AB
1381 (erc-rename-buffers t)
1382 (erc-server-reconnect-attempts 5)
1383 (erc-server-reconnect-timeout 3)
96840c88 1384 :config
96840c88
AB
1385 (defun erc-cmd-OPME ()
1386 "Request chanserv to op me."
1387 (erc-message "PRIVMSG"
1388 (format "chanserv op %s %s"
1389 (erc-default-target)
1390 (erc-current-nick)) nil))
1391 (defun erc-cmd-DEOPME ()
1392 "Deop myself from current channel."
1393 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
1394 (add-to-list 'erc-modules 'keep-place)
1395 (add-to-list 'erc-modules 'notifications)
b7d4b4b3 1396 (add-to-list 'erc-modules 'smiley)
96840c88 1397 (add-to-list 'erc-modules 'spelling)
5b10d879 1398 (add-to-list 'erc-modules 'scrolltoplace)
cb058d21 1399 (erc-update-modules))
96840c88 1400
47904cb7 1401(use-package erc-fill
e3e5e846
AB
1402 :after erc
1403 :custom
92df6c4f 1404 (erc-fill-column 77)
e3e5e846
AB
1405 (erc-fill-function 'erc-fill-static)
1406 (erc-fill-static-center 18))
1407
47904cb7 1408(use-package erc-pcomplete
e3e5e846
AB
1409 :after erc
1410 :custom
0562e97e 1411 (erc-pcomplete-nick-postfix ", "))
e3e5e846 1412
47904cb7 1413(use-package erc-track
e3e5e846 1414 :after erc
2e81c51a
AB
1415 :bind (("C-c a e t d" . erc-track-disable)
1416 ("C-c a e t e" . erc-track-enable))
e3e5e846 1417 :custom
2384d161 1418 (erc-track-enable-keybindings nil)
e3e5e846
AB
1419 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
1420 "324" "329" "332" "333" "353" "477"))
7ac2eb50 1421 (erc-track-position-in-mode-line t)
e3e5e846
AB
1422 (erc-track-priority-faces-only 'all)
1423 (erc-track-shorten-function nil))
1424
96840c88
AB
1425(use-package erc-hl-nicks
1426 :after erc)
1427
5b10d879
AB
1428(use-package erc-scrolltoplace
1429 :after erc)
96840c88 1430
925481f2
AB
1431(use-package znc
1432 :bind (("C-c a e e" . znc-erc)
1433 ("C-c a e a" . znc-all))
1434 :config
1435 (let ((pwd (let ((auth (auth-source-search :host "znca")))
1436 (cond
1437 ((null auth) (error "Couldn't find znca's authinfo"))
1438 (t (funcall (plist-get (car auth) :secret)))))))
1439 (setq znc-servers
1440 `(("znc.shemshak.org" 1337 t
1441 ((freenode "amin/freenode" ,pwd)))
925481f2
AB
1442 ("znc.shemshak.org" 1337 t
1443 ((oftc "amin/oftc" ,pwd)))))))
41d290a2 1444
b57457b2
AB
1445\f
1446;;; Post initialization
1447
8b1a2f32 1448)
41d290a2
AB
1449(message "Loading %s...done (%.3fs)" user-init-file
1450 (float-time (time-subtract (current-time)
dca50cf5 1451 b/before-user-init-time)))
41d290a2
AB
1452
1453;;; init.el ends here