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