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