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