1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org>
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.
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.
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/>.
20 ;; Emacs configuration of Amin Bandali, computer scientist, functional
21 ;; programmer, and free software activist. Uses straight.el for
22 ;; purely functional and fully reproducible package management.
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:
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
38 ;;; Emacs initialization
40 (defvar b
/before-user-init-time
(current-time)
41 "Value of `current-time' when Emacs begins loading `user-init-file'.")
42 (message "Loading Emacs...done (%.3fs)"
43 (float-time (time-subtract b
/before-user-init-time
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.
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
)
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)
58 ;; set them back to their defaults once we're done initializing
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
)
65 ;; increase number of lines kept in *Messages* log
66 (setq message-log-max
20000)
68 ;; optionally, uncomment to supress some byte-compiler warnings
69 ;; (see C-h v byte-compile-warnings RET for more info)
70 ;; (setq byte-compile-warnings
71 ;; '(not free-vars unresolved noruntime lexical make-local))
76 (setq user-full-name
"Amin Bandali"
77 user-mail-address
"bandali@gnu.org")
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
))
89 ;;; Package management
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)
96 (not (featurep 'straight
))
97 (version< emacs-version
"27"))
98 (setq package-enable-at-startup nil
)
99 ;; (package-initialize)
102 ;; for emacs 27 and later, we use early-init.el. see
103 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
107 ;; Main engine start...
109 (setq straight-repository-branch
"develop"
110 straight-check-for-modifications
'(check-on-save find-when-checking
))
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
)
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
)))
126 ;; Solid rocket booster ignition...
128 (b/bootstrap-straight
)
132 (setq straight-use-package-by-default t
)
134 (defmacro use-feature
(name &rest args
)
135 "Like `use-package', but with `straight-use-package-by-default' disabled."
141 (with-eval-after-load 'use-package-core
142 (let ((upflk (car use-package-font-lock-keywords
)))
143 (font-lock-add-keywords
145 `((,(replace-regexp-in-string
146 "use-package" "use-feature"
150 (with-eval-after-load 'recentf
151 (add-to-list 'recentf-exclude
152 (expand-file-name "~/.emacs.d/straight/build/")))
154 (defun b/reload-init
()
157 (setq b
/file-name-handler-alist file-name-handler-alist
)
158 (load user-init-file nil
'nomessage
)
162 (straight-use-package 'use-package
)
164 (if nil
; set to t when need to debug init
166 (setq use-package-verbose t
167 use-package-expand-minimally nil
168 use-package-compute-statistics t
170 (require 'use-package
))
171 (setq use-package-verbose nil
172 use-package-expand-minimally t
))
174 (setq use-package-always-defer t
)
177 (use-package delight
)
182 ;; keep ~/.emacs.d clean
183 (use-package no-littering
186 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
187 (defalias 'b
/var
'no-littering-expand-var-file-name
))
189 ;; separate custom file (don't want it mixing with init.el)
193 (setq custom-file
(b/etc
"custom.el"))
194 (when (file-exists-p custom-file
)
196 ;; while at it, treat themes as safe
197 (setf custom-safe-themes t
)
198 ;; only one custom theme at a time
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
))))
204 ;; load the secrets file if it exists, otherwise show a warning
207 (load (b/etc
"secrets"))))
209 ;; better $PATH (and other environment variable) handling
210 (use-package exec-path-from-shell
213 (setq exec-path-from-shell-arguments nil
214 exec-path-from-shell-check-startup-files nil
)
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"))
221 ;; start up emacs server. see
222 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
225 :config
(or (server-running-p) (server-mode)))
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
)))
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
)))
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
253 (remove nil
(list args
(dired-get-file-for-visit)))))
255 (defun b/add-elisp-section
()
259 (insert "\n\f\n;;; "))
261 (defun b/no-mouse-autoselect-window
()
262 "Conveniently disable `focus-follows-mouse'.
263 For disabling the behaviour for certain buffers and/or modes."
264 (make-local-variable 'mouse-autoselect-window
)
265 (setq mouse-autoselect-window nil
))
270 ;;;; C-level customizations
274 enable-recursive-minibuffers t
275 resize-mini-windows t
276 ;; more useful frame titles
277 frame-title-format
'("" invocation-name
" - "
279 (if (buffer-file-name)
280 (abbreviate-file-name (buffer-file-name))
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
287 ;; scroll-conservatively 10000
289 scroll-conservatively
10
290 scroll-preserve-screen-position
1
291 ;; focus follows mouse
292 mouse-autoselect-window t
)
295 ;; always use space for indentation
303 (dolist (ft (fontset-list))
307 (font-spec :name
"Source Code Pro" :size
14))
311 (font-spec :name
"DejaVu Sans Mono")
318 ;; :name "Symbola monospacified for DejaVu Sans Mono")
324 ;; (font-spec :name "DejaVu Sans Mono")
330 (font-spec :name
"DejaVu Sans Mono" :size
14)
334 ;;;; Elisp-level customizations
340 ;; don't need to see the startup echo area message
341 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
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
))
359 ;; backups (C-h v make-backup-files RET)
360 (backup-by-copying t
)
362 (delete-old-versions t
)
365 (auto-save-file-name-transforms
366 `((".*" ,(b/var
"auto-save/") t
)))
368 ;; insert newline at the end of files
369 (require-final-newline t
)
371 ;; open read-only file buffers in view-mode
372 ;; (enables niceties like `q' for quit)
375 ;; disable disabled commands
376 (setq disabled-command-function nil
)
378 ;; lazy-person-friendly yes/no prompts
379 (defalias 'yes-or-no-p
#'y-or-n-p
)
381 ;; enable automatic reloading of changed buffers and files
382 (use-feature autorevert
385 (global-auto-revert-mode 1)
387 (auto-revert-verbose nil
)
388 (global-auto-revert-non-file-buffers nil
))
390 ;; time and battery in mode-line
394 (setq display-time-default-load-average nil
)
400 (display-battery-mode)))
406 ;; (fringe-mode '(3 . 1))
412 ;; enable winner-mode (C-h f winner-mode RET)
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'.
420 (defun b/compilation-finish-function
(buffer outstr
)
421 (unless (string-match "finished" outstr
)
422 (switch-to-buffer-other-window buffer
))
425 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
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
))
436 (ad-activate 'compilation-start
))
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
))
448 ;; uncomment to extend the above behaviour to query-replace
452 (replace-char-fold t
)))
455 :bind
("C-x v C-=" . vc-ediff
))
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
)))
462 (use-feature face-remap
464 ;; gentler font resizing
465 (text-scale-mode-step 1.05))
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
474 (use-feature pixel-scroll
476 :config
(pixel-scroll-mode 1))
478 (use-feature epg-config
480 ((epg-gpg-program (executable-find "gpg"))))
488 ("C-c e b" . eval-buffer
)
489 ("C-c e e" . eval-last-sexp
)
490 ("C-c e r" . eval-region
)
492 ("C-c e i" . emacs-init-time
)
493 ("C-c e u" . emacs-uptime
)
494 ("C-c e v" . emacs-version
)
496 ("C-c F m" . make-frame-command
)
497 ("C-c F d" . delete-frame
)
498 ("C-c F D" . server-edit
)
500 ("C-S-h C" . describe-char
)
501 ("C-S-h F" . describe-face
)
503 ("C-x k" . kill-this-buffer
)
504 ("C-x K" . kill-buffer
)
505 ("C-x s" . save-buffer
)
506 ("C-x S" . save-some-buffers
)
508 :map emacs-lisp-mode-map
509 ("<C-return>" . b
/add-elisp-section
))
511 (when (display-graphic-p)
512 (unbind-key "C-z" global-map
))
515 ;; for back and forward mouse keys
516 ("<XF86Back>" . previous-buffer
)
517 ("<mouse-8>" . previous-buffer
)
518 ("<drag-mouse-8>" . previous-buffer
)
519 ("<XF86Forward>" . next-buffer
)
520 ("<mouse-9>" . next-buffer
)
521 ("<drag-mouse-9>" . next-buffer
)
522 ("<drag-mouse-2>" . kill-this-buffer
)
523 ("<drag-mouse-3>" . ivy-switch-buffer
))
526 :prefix-map b
/straight-prefix-map
528 ("u" . straight-use-package
)
529 ("f" . straight-freeze-versions
)
530 ("t" . straight-thaw-versions
)
531 ("P" . straight-prune-build
)
532 ("g" . straight-get-recipe
)
533 ("r" . b
/reload-init
)
534 ;; M-x ^straight-.*-all$
535 ("a c" . straight-check-all
)
536 ("a f" . straight-fetch-all
)
537 ("a m" . straight-merge-all
)
538 ("a n" . straight-normalize-all
)
539 ("a F" . straight-pull-all
)
540 ("a P" . straight-push-all
)
541 ("a r" . straight-rebuild-all
)
542 ;; M-x ^straight-.*-package$
543 ("p c" . straight-check-package
)
544 ("p f" . straight-fetch-package
)
545 ("p m" . straight-merge-package
)
546 ("p n" . straight-normalize-package
)
547 ("p F" . straight-pull-package
)
548 ("p P" . straight-push-package
)
549 ("p r" . straight-rebuild-package
))
552 ;;; Essential packages
558 (require 'exwm-config
)
560 ;; Set the initial workspace number.
561 (setq exwm-workspace-number
4)
563 ;; Make class name the buffer name, truncating beyond 50 characters
564 (defun exwm-rename-buffer ()
566 (exwm-workspace-rename-buffer
567 (concat exwm-class-name
":"
568 (if (<= (length exwm-title
) 50) exwm-title
569 (concat (substring exwm-title
0 49) "...")))))
570 (add-hook 'exwm-update-class-hook
'exwm-rename-buffer
)
571 (add-hook 'exwm-update-title-hook
'exwm-rename-buffer
)
574 (exwm-input-set-key (kbd "s-R") #'exwm-reset
)
575 ;; 's-\': Switch workspace
576 (exwm-input-set-key (kbd "s-\\") #'exwm-workspace-switch
)
577 ;; 's-N': Switch to certain workspace
580 (kbd (format "s-%d" i
))
583 (exwm-workspace-switch-create i
))))
584 ;; 's-SPC': Launch application
585 ;; (exwm-input-set-key
588 ;; (interactive (list (read-shell-command "➜ ")))
589 ;; (start-process-shell-command command nil command)))
591 (exwm-input-set-key (kbd "M-s-SPC") #'counsel-linux-app
)
593 ;; Shorten 'C-c C-q' to 'C-q'
594 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
596 ;; Line-editing shortcuts
597 (setq exwm-input-simulation-keys
602 ([?\M-f] . [C-right])
610 ([?\C-k] . [S-end delete])
612 ;; ([?\C-w] . [?\C-x])
616 ([?\C-s] . [?\C-f])))
621 (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame)
623 (require 'exwm-systemtray)
624 (exwm-systemtray-enable)
626 (require 'exwm-randr)
629 ;; (exwm-input-set-key
630 ;; (kbd "s-<return>")
633 ;; (start-process "urxvt" nil "urxvt")))
635 ;; (exwm-input-set-key
636 ;; (kbd "s-SPC") ;; rofi doesn't properly launch programs when started from emacs
639 ;; (start-process-shell-command "rofi-run" nil "rofi -show run -display-run '> ' -display-window ' 🗔 '")))
641 ;; (exwm-input-set-key
645 ;; (start-process-shell-command "rofi-win" nil "rofi -show window -display-run '> ' -display-window ' 🗔 '")))
647 ;; (exwm-input-set-key
651 ;; (start-process "rofi-pass" nil "rofi-pass")))
653 ;; (exwm-input-set-key
654 ;; (kbd "<XF86AudioMute>")
657 ;; (start-process-shell-command "pamixer" nil "pamixer --toggle-mute")))
659 ;; (exwm-input-set-key
660 ;; (kbd "<XF86AudioLowerVolume>")
663 ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --decrease 5")))
665 ;; (exwm-input-set-key
666 ;; (kbd "<XF86AudioRaiseVolume>")
669 ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --increase 5")))
671 ;; (exwm-input-set-key
672 ;; (kbd "<XF86AudioPlay>")
675 ;; (start-process-shell-command "mpc" nil "mpc toggle")))
677 ;; (exwm-input-set-key
678 ;; (kbd "<XF86AudioPrev>")
681 ;; (start-process-shell-command "mpc" nil "mpc prev")))
683 ;; (exwm-input-set-key
684 ;; (kbd "<XF86AudioNext>")
687 ;; (start-process-shell-command "mpc" nil "mpv next")))
689 (defun b/exwm-pasystray ()
690 "A command used to start pasystray."
692 (if (executable-find "pasystray")
694 (message "EXWM: starting pasystray ...")
695 (start-process-shell-command "pasystray" nil "pasystray --notify=all"))
696 (message "EXWM: pasystray is not installed, abort!")))
698 (add-hook 'exwm-init-hook #'b/exwm-pasystray)
704 (exwm-floating-toggle-floating)))
710 (exwm-layout-toggle-fullscreen)))
716 (kill-buffer (current-buffer))))
722 (exwm-manage--kill-client))))
724 ;; use the org-plus-contrib package to get the whole deal
725 (use-package org-plus-contrib)
730 (setq org-src-tab-acts-natively t
731 org-src-preserve-indentation nil
732 org-edit-src-content-indentation 0
733 org-link-email-description-format "Email %c: %s" ; %.30s
734 org-highlight-latex-and-related '(entities)
735 org-use-speed-commands t
736 org-startup-folded 'content
737 org-catch-invisible-edits 'show-and-error
739 (when (version< org-version "9.3")
740 (setq org-email-link-description-format
741 org-link-email-description-format))
742 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
743 (add-to-list 'org-modules 'org-habit)
745 (("C-c a o a" . org-agenda)
747 ("M-L" . org-insert-last-stored-link)
748 ("M-O" . org-toggle-link-display))
749 :hook ((org-mode . org-indent-mode)
750 (org-mode . auto-fill-mode)
751 (org-mode . flyspell-mode))
753 (org-pretty-entities t)
754 (org-agenda-files '("~/usr/org/todos/personal.org"
755 "~/usr/org/todos/habits.org"
756 "~/src/git/masters-thesis/todo.org"))
757 (org-agenda-start-on-weekday 0)
758 (org-agenda-time-leading-zero t)
759 (org-habit-graph-column 44)
760 (org-latex-packages-alist '(("" "listings") ("" "color")))
762 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
763 '(org-block ((t (:background "#1d1f21"))))
764 '(org-latex-and-related ((t (:foreground "#b294bb")))))
766 (use-feature ox-latex
769 (setq org-latex-listings 'listings
770 ;; org-latex-prefer-user-labels t
772 (add-to-list 'org-latex-classes
773 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
774 ("\\section{%s}" . "\\section*{%s}")
775 ("\\subsection{%s}" . "\\subsection*{%s}")
776 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
777 ("\\paragraph{%s}" . "\\paragraph*{%s}")
778 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
780 (require 'ox-beamer))
782 (use-feature ox-extra
784 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
786 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
787 ;; org file. closely inspired by
788 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
789 (with-eval-after-load 'org
790 (defvar b/show-async-tangle-results nil
791 "Keep *emacs* async buffers around for later inspection.")
793 (defvar b/show-async-tangle-time nil
794 "Show the time spent tangling the file.")
796 (defun b/async-babel-tangle ()
797 "Tangle org file asynchronously."
799 (let* ((file-tangle-start-time (current-time))
800 (file (buffer-file-name))
801 (file-nodir (file-name-nondirectory file))
802 ;; (async-quiet-switch "-q")
803 (file-noext (file-name-sans-extension file)))
807 (org-babel-tangle-file ,file))
808 (unless b/show-async-tangle-results
811 (message "Tangled %s%s"
813 (if b/show-async-tangle-time
815 (float-time (time-subtract (current-time)
816 ',file-tangle-start-time)))
818 (message "Tangling %s failed" ,file-nodir))))))))
821 'safe-local-variable-values
822 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
824 ;; *the* right way to do git
827 :bind (("C-x g" . magit-status)
828 ("C-c g g" . magit-status)
829 ("C-c g b" . magit-blame-addition)
830 ("C-c g l" . magit-log-buffer-file))
832 (magit-add-section-hook 'magit-status-sections-hook
833 'magit-insert-modules
834 'magit-insert-stashes
836 ;; (magit-add-section-hook 'magit-status-sections-hook
837 ;; 'magit-insert-ignored-files
838 ;; 'magit-insert-untracked-files
840 (setq magit-repository-directories '(("~/" . 0)
842 (nconc magit-section-initial-visibility-alist
843 '(([unpulled status] . show)
844 ([unpushed status] . show)))
845 :custom (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
846 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
848 ;; recently opened files
852 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
854 (recentf-max-saved-items 2000))
856 ;; smart M-x enhancement (needed by counsel for history)
863 (:map ivy-minibuffer-map
864 ([escape] . keyboard-escape-quit)
865 ([S-up] . ivy-previous-history-element)
866 ([S-down] . ivy-next-history-element)
867 ("DEL" . ivy-backward-delete-char))
871 ivy-use-virtual-buffers t
872 ivy-virtual-abbreviate 'abbreviate
873 ivy-count-format "%d/%d ")
875 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
876 (defun b/ivy-ignore-buffer-p (str)
877 "Return non-nil if str names a buffer with a major mode
878 derived from one of `b/ivy-ignore-buffer-modes'.
880 This function is intended for use with `ivy-ignore-buffers'."
881 (let* ((buf (get-buffer str))
882 (mode (and buf (buffer-local-value 'major-mode buf))))
884 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
885 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
889 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
890 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
891 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
896 :bind (("C-s" . swiper-isearch)
898 ("C-S-s" . isearch-forward)))
903 :bind (([remap execute-extended-command] . counsel-M-x)
904 ([remap find-file] . counsel-find-file)
905 ("C-c b b" . ivy-switch-buffer)
906 ("C-c f ." . counsel-find-file)
907 ("C-c f l" . counsel-find-library)
908 ("C-c f r" . counsel-recentf)
909 ("C-c x" . counsel-M-x)
910 :map minibuffer-local-map
911 ("C-r" . counsel-minibuffer-history))
914 (defalias 'locate #'counsel-locate))
918 :commands (helm-M-x helm-mini helm-resume)
919 :bind (("M-x" . helm-M-x)
920 ("M-y" . helm-show-kill-ring)
921 ("C-x b" . helm-mini)
922 ("C-x C-b" . helm-buffers-list)
923 ("C-x C-f" . helm-find-files)
924 ("C-h r" . helm-info-emacs)
925 ("C-s-r" . helm-resume)
927 ("<tab>" . helm-execute-persistent-action)
928 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
929 ("C-z" . helm-select-action)) ; List actions
930 :config (helm-mode 1)))
935 :bind ("C-c a s e" . eshell)
937 (eval-when-compile (defvar eshell-prompt-regexp))
938 (defun b/eshell-quit-or-delete-char (arg)
940 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
941 (eshell-life-is-too-much)
944 (defun b/eshell-clear ()
946 (let ((inhibit-read-only t))
950 (defun b/eshell-setup ()
951 (make-local-variable 'company-idle-delay)
952 (defvar company-idle-delay)
953 (setq company-idle-delay nil)
954 (bind-keys :map eshell-mode-map
955 ("C-d" . b/eshell-quit-or-delete-char)
956 ("C-S-l" . b/eshell-clear)
957 ("M-r" . counsel-esh-history)
958 ([tab] . company-complete)))
960 :hook (eshell-mode . b/eshell-setup)
962 (eshell-hist-ignoredups t)
963 (eshell-input-filter 'eshell-input-filter-initial-space))
967 (("C-x C-b" . ibuffer)
968 :map ibuffer-mode-map
969 ("P" . ibuffer-backward-filter-group)
970 ("N" . ibuffer-forward-filter-group)
971 ("M-p" . ibuffer-do-print)
972 ("M-n" . ibuffer-do-shell-command-pipe-replace))
974 ;; Use human readable Size column instead of original one
975 (define-ibuffer-column size-h
976 (:name "Size" :inline t)
978 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
979 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
980 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
981 (t (format "%8d" (buffer-size)))))
983 (ibuffer-saved-filter-groups
985 ("dired" (mode . dired-mode))
986 ("org" (mode . org-mode))
989 (mode . gnus-group-mode)
990 (mode . gnus-summary-mode)
991 (mode . gnus-article-mode)
992 ;; not really, but...
993 (mode . message-mode)))
1002 (mode . eshell-mode)
1004 (mode . term-mode)))
1007 (mode . python-mode)
1011 (mode . emacs-lisp-mode)
1012 (mode . scheme-mode)
1013 (mode . haskell-mode)
1016 (mode . alloy-mode)))
1019 (mode . bibtex-mode)
1020 (mode . latex-mode)))
1023 (name . "^\\*scratch\\*$")
1024 (name . "^\\*Messages\\*$")))
1025 ("erc" (mode . erc-mode)))))
1027 '((mark modified read-only locked " "
1028 (name 18 18 :left :elide)
1030 (size-h 9 -1 :right)
1032 (mode 16 16 :left :elide)
1033 " " filename-and-process)
1037 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1039 (use-feature outline
1041 :hook (prog-mode . outline-minor-mode)
1042 :delight (outline-minor-mode " outl")
1045 outline-minor-mode-map
1046 ("<s-tab>" . outline-toggle-children)
1047 ("M-p" . outline-previous-visible-heading)
1048 ("M-n" . outline-next-visible-heading)
1049 :prefix-map b/outline-prefix-map
1051 ("TAB" . outline-toggle-children)
1052 ("a" . outline-hide-body)
1053 ("H" . outline-hide-body)
1054 ("S" . outline-show-all)
1055 ("h" . outline-hide-subtree)
1056 ("s" . outline-show-subtree)))
1058 (use-feature ls-lisp
1059 :custom (ls-lisp-dirs-first t))
1063 (setq dired-listing-switches "-alh"
1064 ls-lisp-use-insert-directory-program nil)
1066 ;; easily diff 2 marked files
1067 ;; https://oremacs.com/2017/03/18/dired-ediff/
1068 (defun dired-ediff-files ()
1070 (require 'dired-aux)
1071 (defvar ediff-after-quit-hook-internal)
1072 (let ((files (dired-get-marked-files))
1073 (wnd (current-window-configuration)))
1074 (if (<= (length files) 2)
1075 (let ((file1 (car files))
1076 (file2 (if (cdr files)
1080 (dired-dwim-target-directory)))))
1081 (if (file-newer-than-file-p file1 file2)
1082 (ediff-files file2 file1)
1083 (ediff-files file1 file2))
1084 (add-hook 'ediff-after-quit-hook-internal
1086 (setq ediff-after-quit-hook-internal nil)
1087 (set-window-configuration wnd))))
1088 (error "no more than 2 files should be marked"))))
1091 (setq dired-guess-shell-alist-user
1092 '(("\\.pdf\\'" "evince" "zathura" "okular")
1093 ("\\.doc\\'" "libreoffice")
1094 ("\\.docx\\'" "libreoffice")
1095 ("\\.ppt\\'" "libreoffice")
1096 ("\\.pptx\\'" "libreoffice")
1097 ("\\.xls\\'" "libreoffice")
1098 ("\\.xlsx\\'" "libreoffice")
1099 ("\\.flac\\'" "mpv")))
1100 :bind (:map dired-mode-map
1101 ("b" . dired-up-directory)
1102 ("e" . dired-ediff-files)
1103 ("E" . dired-toggle-read-only)
1104 ("\\" . dired-hide-details-mode)
1107 (b/dired-start-process "zathura"))))
1108 :hook (dired-mode . dired-hide-details-mode))
1112 (temp-buffer-resize-mode)
1113 (setq help-window-select t))
1117 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1118 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1119 (add-to-list 'tramp-default-proxies-alist
1120 (list (regexp-quote (system-name)) nil nil)))
1123 :config (dash-enable-font-lock))
1125 (use-feature doc-view
1126 :bind (:map doc-view-mode-map
1127 ("M-RET" . image-previous-line)))
1132 ;; highlight uncommitted changes in the left fringe
1133 (use-package diff-hl
1136 (setq diff-hl-draw-borders nil)
1137 (global-diff-hl-mode)
1138 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
1140 ;; display Lisp objects at point in the echo area
1142 :when (version< "25" emacs-version)
1144 :config (global-eldoc-mode))
1146 ;; highlight matching parens
1149 :config (show-paren-mode))
1151 (use-feature elec-pair
1153 :config (electric-pair-mode))
1156 :delight (auto-fill-function " fill")
1157 :config (column-number-mode)
1159 ;; Save what I copy into clipboard from other applications into Emacs'
1160 ;; kill-ring, which would allow me to still be able to easily access
1161 ;; it in case I kill (cut or copy) something else inside Emacs before
1162 ;; yanking (pasting) what I'd originally intended to.
1163 (save-interprogram-paste-before-kill t))
1165 ;; save minibuffer history
1166 (use-feature savehist
1170 (add-to-list 'savehist-additional-variables 'kill-ring))
1172 ;; automatically save place in files
1173 (use-feature saveplace
1174 :when (version< "25" emacs-version)
1175 :config (save-place-mode))
1177 (use-feature prog-mode
1178 :config (global-prettify-symbols-mode)
1179 (defun indicate-buffer-boundaries-left ()
1180 (setq indicate-buffer-boundaries 'left))
1181 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1183 (use-feature text-mode
1184 :hook (text-mode . indicate-buffer-boundaries-left))
1186 (use-feature conf-mode
1189 (use-feature sh-mode
1192 (use-package company
1196 (:map company-active-map
1197 ([tab] . company-complete-common-or-cycle)
1198 ([escape] . company-abort))
1200 (company-minimum-prefix-length 1)
1201 (company-selection-wrap-around t)
1202 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1203 (company-dabbrev-downcase nil)
1204 (company-dabbrev-ignore-case nil)
1206 (global-company-mode t))
1208 (use-package flycheck
1210 :hook (prog-mode . flycheck-mode)
1212 (:map flycheck-mode-map
1213 ("M-P" . flycheck-previous-error)
1214 ("M-N" . flycheck-next-error))
1216 ;; Use the load-path from running Emacs when checking elisp files
1217 (setq flycheck-emacs-lisp-load-path 'inherit)
1219 ;; Only flycheck when I actually save the buffer
1220 (setq flycheck-check-syntax-automatically '(mode-enabled save))
1221 :custom (flycheck-mode-line-prefix "flyc"))
1223 (use-feature flyspell
1226 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1230 ;; ’ can be part of a word
1231 (setq ispell-local-dictionary-alist
1232 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1233 "['\x2019]" nil ("-B") nil utf-8))
1234 ispell-program-name (executable-find "hunspell"))
1235 ;; don't send ’ to the subprocess
1236 (defun endless/replace-apostrophe (args)
1237 (cons (replace-regexp-in-string
1240 (advice-add #'ispell-send-string :filter-args
1241 #'endless/replace-apostrophe)
1243 ;; convert ' back to ’ from the subprocess
1244 (defun endless/replace-quote (args)
1245 (if (not (derived-mode-p 'org-mode))
1247 (cons (replace-regexp-in-string
1250 (advice-add #'ispell-parse-output :filter-args
1251 #'endless/replace-quote))
1255 :hook (text-mode . abbrev-mode))
1258 ;;; Programming modes
1260 (use-feature lisp-mode
1262 (defun indent-spaces-mode ()
1263 (setq indent-tabs-mode nil))
1264 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1267 :delight (reveal-mode " reveal")
1268 :hook (emacs-lisp-mode . reveal-mode))
1270 (use-feature elisp-mode
1271 :delight (emacs-lisp-mode "Elisp" :major))
1274 (use-package alloy-mode
1275 :straight (:host github :repo "dwwmmn/alloy-mode")
1277 :config (setq alloy-basic-offset 2))
1279 (eval-when-compile (defvar lean-mode-map))
1280 (use-package lean-mode
1281 :straight (:host github :repo "leanprover/lean-mode"
1282 :fork (:repo "notbandali/lean-mode" :branch "remove-cl"))
1284 :bind (:map lean-mode-map
1285 ("S-SPC" . company-complete))
1287 (require 'lean-input)
1288 (setq default-input-method "Lean"
1289 lean-input-tweak-all '(lean-input-compose
1290 (lean-input-prepend "/")
1291 (lean-input-nonempty))
1292 lean-input-user-translations '(("/" "/")))
1296 (use-package proof-site ; for Coq
1297 :straight proof-general)
1299 (use-package haskell-mode
1301 (setq haskell-indentation-layout-offset 4
1302 haskell-indentation-left-offset 4
1303 flycheck-checker 'haskell-hlint
1304 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1308 :commands dante-mode
1309 :hook (haskell-mode . dante-mode))
1311 (use-package hlint-refactor
1313 :bind (:map hlint-refactor-mode-map
1314 ("C-c l b" . hlint-refactor-refactor-buffer)
1315 ("C-c l r" . hlint-refactor-refactor-at-point))
1316 :hook (haskell-mode . hlint-refactor-mode))
1318 (use-package flycheck-haskell
1319 :after haskell-mode)
1320 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1323 (use-feature sgml-mode
1325 (setq sgml-basic-offset 2))
1327 (use-feature css-mode
1329 (setq css-indent-offset 2))
1331 (use-package web-mode
1335 web-mode-code-indent-offset
1336 web-mode-css-indent-offset
1337 web-mode-markup-indent-offset))
1339 (use-package emmet-mode
1340 :after (:any web-mode css-mode sgml-mode)
1341 :bind* (("C-)" . emmet-next-edit-point)
1342 ("C-(" . emmet-prev-edit-point))
1344 (unbind-key "C-j" emmet-mode-keymap)
1345 (setq emmet-move-cursor-between-quotes t)
1346 :hook (web-mode css-mode html-mode sgml-mode))
1349 (use-package meghanada
1351 (:map meghanada-mode-map
1352 (("C-M-o" . meghanada-optimize-import)
1353 ("C-M-t" . meghanada-import-all)))
1354 :hook (java-mode . meghanada-mode)))
1357 (use-package treemacs
1358 :config (setq treemacs-never-persist t))
1360 (use-package yasnippet
1362 ;; (yas-global-mode)
1365 (use-package lsp-mode
1366 :init (setq lsp-eldoc-render-all nil
1367 lsp-highlight-symbol-at-point nil)
1372 (use-package company-lsp
1375 (setq company-lsp-cache-candidates t
1376 company-lsp-async t))
1380 (setq lsp-ui-sideline-update-mode 'point))
1382 (use-package lsp-java
1384 (add-hook 'java-mode-hook
1386 (setq-local company-backends (list 'company-lsp))))
1388 (add-hook 'java-mode-hook 'lsp-java-enable)
1389 (add-hook 'java-mode-hook 'flycheck-mode)
1390 (add-hook 'java-mode-hook 'company-mode)
1391 (add-hook 'java-mode-hook 'lsp-ui-mode))
1393 (use-package dap-mode
1399 (use-package dap-java
1402 (use-package lsp-java-treemacs
1407 :bind (:map eclim-mode-map ("S-SPC" . company-complete))
1408 :hook ((java-mode . eclim-mode)
1409 (eclim-mode . (lambda ()
1410 (make-local-variable 'company-idle-delay)
1411 (defvar company-idle-delay)
1412 ;; (setq company-idle-delay 0.7)
1413 (setq company-idle-delay nil))))
1415 (eclim-auto-save nil)
1416 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1417 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1418 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1420 (use-package geiser)
1422 (use-feature geiser-guile
1424 (setq geiser-guile-load-path "~/src/git/guix"))
1431 (font-latex-fontify-sectioning 'color)))
1433 (use-package go-mode)
1435 (use-package po-mode
1437 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
1439 (use-feature tex-mode
1442 (lambda (p) (string-match "^---?" (car p)))
1443 tex--prettify-symbols-alist)
1444 :hook ((tex-mode . auto-fill-mode)
1445 (tex-mode . flyspell-mode)
1446 (tex-mode . (lambda () (electric-indent-local-mode -1)))))
1451 (add-to-list 'custom-theme-load-path
1453 (convert-standard-filename "lisp") user-emacs-directory))
1454 (load-theme 'tangomod t)
1456 (use-package smart-mode-line
1457 :commands (sml/apply-theme)
1461 (smart-mode-line-enable))
1463 (use-package doom-themes)
1465 (defvar b/org-mode-font-lock-keywords
1466 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1467 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1468 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1469 (4 '(:foreground "#c5c8c6") t)))) ; title
1471 (defun b/lights-on ()
1472 "Enable my favourite light theme."
1474 (mapc #'disable-theme custom-enabled-themes)
1475 (load-theme 'tangomod t)
1476 (sml/apply-theme 'automatic)
1477 (font-lock-remove-keywords
1478 'org-mode b/org-mode-font-lock-keywords))
1480 (defun b/lights-off ()
1483 (mapc #'disable-theme custom-enabled-themes)
1484 (load-theme 'doom-tomorrow-night t)
1485 (sml/apply-theme 'automatic)
1486 (font-lock-add-keywords
1487 'org-mode b/org-mode-font-lock-keywords t))
1490 ("C-c t d" . b/lights-off)
1491 ("C-c t l" . b/lights-on))
1494 ;;; Emacs enhancements & auxiliary packages
1497 :config (setq Man-width 80))
1499 (use-package which-key
1503 (which-key-add-key-based-replacements
1504 ;; prefixes for global prefixes and minor modes
1508 "C-c 8 -" "typo/dashes"
1509 "C-c 8 <" "typo/left-brackets"
1510 "C-c 8 >" "typo/right-brackets"
1512 "C-x a" "abbrev/expand"
1513 "C-x r" "rectangle/register/bookmark"
1514 "C-x v" "version control"
1515 ;; prefixes for my personal bindings
1516 "C-c a" "applications"
1521 "C-c c" "compile-and-comments"
1527 "C-c m" "multiple-cursors"
1528 "C-c P" "projectile"
1529 "C-c P s" "projectile/search"
1530 "C-c P x" "projectile/execute"
1531 "C-c P 4" "projectile/other-window"
1537 ;; prefixes for major modes
1538 (which-key-add-major-mode-key-based-replacements 'message-mode
1539 "C-c f n" "footnote")
1540 (which-key-add-major-mode-key-based-replacements 'org-mode
1541 "C-c C-v" "org-babel")
1542 (which-key-add-major-mode-key-based-replacements 'web-mode
1543 "C-c C-a" "web/attributes"
1544 "C-c C-b" "web/blocks"
1546 "C-c C-e" "web/element"
1547 "C-c C-t" "web/tags")
1551 (which-key-add-column-padding 5)
1552 (which-key-max-description-length 32))
1554 (use-package crux ; results in Waiting for git... [2 times]
1556 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1557 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
1558 ("C-c f c" . crux-copy-file-preserve-attributes)
1559 ("C-c f d" . crux-delete-file-and-buffer)
1560 ("C-c f r" . crux-rename-file-and-buffer)
1561 ("C-c j" . crux-top-join-line)
1562 ("C-S-j" . crux-top-join-line)))
1565 :bind (("C-a" . mwim-beginning-of-code-or-line)
1566 ("C-e" . mwim-end-of-code-or-line)
1567 ("<home>" . mwim-beginning-of-line-or-code)
1568 ("<end>" . mwim-end-of-line-or-code)))
1570 (use-package projectile
1572 :bind-keymap ("C-c P" . projectile-command-map)
1576 (defun b/projectile-mode-line-fun ()
1577 "Report project name and type in the modeline."
1578 (let ((project-name (projectile-project-name))
1579 (project-type (projectile-project-type)))
1581 projectile-mode-line-prefix
1583 (format ":%s" project-type)
1585 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1587 (defun my-projectile-invalidate-cache (&rest _args)
1588 ;; ignore the args to `magit-checkout'
1589 (projectile-invalidate-cache nil))
1591 (eval-after-load 'magit-branch
1593 (advice-add 'magit-checkout
1594 :after #'my-projectile-invalidate-cache)
1595 (advice-add 'magit-branch-and-checkout
1596 :after #'my-projectile-invalidate-cache)))
1598 (projectile-completion-system 'ivy)
1599 (projectile-mode-line-prefix " proj"))
1601 (use-package helpful
1604 (("C-S-h c" . helpful-command)
1605 ("C-S-h f" . helpful-callable) ; helpful-function
1606 ("C-S-h v" . helpful-variable)
1607 ("C-S-h k" . helpful-key)
1608 ("C-S-h p" . helpful-at-point)))
1610 (use-package unkillable-scratch
1613 (unkillable-scratch 1)
1615 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1618 ;; | make pretty boxed quotes like this
1620 (use-package boxquote
1623 (:prefix-map b/boxquote-prefix-map
1625 ("b" . boxquote-buffer)
1626 ("B" . boxquote-insert-buffer)
1627 ("d" . boxquote-defun)
1628 ("F" . boxquote-insert-file)
1629 ("hf" . boxquote-describe-function)
1630 ("hk" . boxquote-describe-key)
1631 ("hv" . boxquote-describe-variable)
1632 ("hw" . boxquote-where-is)
1633 ("k" . boxquote-kill)
1634 ("p" . boxquote-paragraph)
1635 ("q" . boxquote-boxquote)
1636 ("r" . boxquote-region)
1637 ("s" . boxquote-shell-command)
1638 ("t" . boxquote-text)
1639 ("T" . boxquote-title)
1640 ("u" . boxquote-unbox)
1641 ("U" . boxquote-unbox-region)
1642 ("y" . boxquote-yank)
1643 ("M-q" . boxquote-fill-paragraph)
1644 ("M-w" . boxquote-kill-ring-save)))
1646 (use-package orgalist
1647 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1650 :hook (message-mode . orgalist-mode))
1652 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1657 (typo-global-mode 1)
1658 :hook (((text-mode erc-mode) . typo-mode)
1659 (tex-mode . (lambda ()(typo-mode -1)))))
1661 ;; highlight TODOs in buffers
1662 (use-package hl-todo
1665 (global-hl-todo-mode))
1667 (use-package shrink-path
1671 (defvar user-@-host (concat (user-login-name) "@" (system-name) " "))
1672 (defun +eshell/prompt ()
1673 (let ((base/dir (shrink-path-prompt default-directory)))
1674 (concat (propertize user-@-host 'face 'default)
1675 (propertize (car base/dir)
1676 'face 'font-lock-comment-face)
1677 (propertize (cdr base/dir)
1678 'face 'font-lock-constant-face)
1679 (propertize "> " 'face 'default))))
1680 (setq eshell-prompt-regexp (concat user-@-host ".*> ")
1681 eshell-prompt-function #'+eshell/prompt))
1683 (use-package eshell-up
1685 :commands eshell-up)
1687 (use-package multi-term
1689 :bind (("C-c a s m m" . multi-term)
1690 ("C-c a s m d" . multi-term-dedicated-toggle)
1691 ("C-c a s m p" . multi-term-prev)
1692 ("C-c a s m n" . multi-term-next)
1694 ("C-c C-j" . term-char-mode))
1696 (setq multi-term-program "screen"
1697 multi-term-program-switches (concat "-c"
1698 (getenv "XDG_CONFIG_HOME")
1700 ;; TODO: add separate bindings for connecting to existing
1701 ;; session vs. always creating a new one
1702 multi-term-dedicated-select-after-open-p t
1703 multi-term-dedicated-window-height 20
1704 multi-term-dedicated-max-window-height 30
1706 '(("C-c C-c" . term-interrupt-subjob)
1707 ("C-c C-e" . term-send-esc)
1708 ("C-c C-j" . term-line-mode)
1710 ;; ("C-y" . term-paste)
1711 ("C-y" . term-send-raw)
1712 ("M-f" . term-send-forward-word)
1713 ("M-b" . term-send-backward-word)
1714 ("M-p" . term-send-up)
1715 ("M-n" . term-send-down)
1716 ("M-j" . term-send-raw-meta)
1717 ("M-y" . term-send-raw-meta)
1718 ("M-/" . term-send-raw-meta)
1719 ("M-0" . term-send-raw-meta)
1720 ("M-1" . term-send-raw-meta)
1721 ("M-2" . term-send-raw-meta)
1722 ("M-3" . term-send-raw-meta)
1723 ("M-4" . term-send-raw-meta)
1724 ("M-5" . term-send-raw-meta)
1725 ("M-6" . term-send-raw-meta)
1726 ("M-7" . term-send-raw-meta)
1727 ("M-8" . term-send-raw-meta)
1728 ("M-9" . term-send-raw-meta)
1729 ("<C-backspace>" . term-send-backward-kill-word)
1730 ("<M-DEL>" . term-send-backward-kill-word)
1731 ("M-d" . term-send-delete-word)
1732 ("M-," . term-send-raw)
1733 ("M-." . comint-dynamic-complete))
1734 term-unbind-key-alist
1735 '("C-z" "C-x" "C-c" "C-h"
1739 (use-package page-break-lines
1743 (page-break-lines-max-width fill-column)
1745 (global-page-break-lines-mode))
1747 (use-package expand-region
1748 :bind ("C-=" . er/expand-region))
1750 (use-package multiple-cursors
1752 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1753 (:prefix-map b/mc-prefix-map
1755 ("c" . mc/edit-lines)
1756 ("n" . mc/mark-next-like-this)
1757 ("p" . mc/mark-previous-like-this)
1758 ("a" . mc/mark-all-like-this))))
1766 (use-package yasnippet
1769 (defconst yas-verbosity-cur yas-verbosity)
1770 (setq yas-verbosity 2)
1771 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1773 (setq yas-verbosity yas-verbosity-cur)
1775 (defun b/yas--maybe-expand-key-filter (cmd)
1776 (when (and (yas--maybe-expand-key-filter cmd)
1777 (not (bound-and-true-p git-commit-mode)))
1779 (defconst b/yas-maybe-expand
1780 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1781 (define-key yas-minor-mode-map
1782 (kbd "SPC") b/yas-maybe-expand)
1786 (use-package debbugs
1789 :repo "emacs-straight/debbugs"
1790 :files (:defaults "Debbugs.wsdl")))
1792 (use-package org-ref
1794 (b/setq-every '("~/usr/org/references.bib")
1795 reftex-default-bibliography
1796 org-ref-default-bibliography)
1798 org-ref-bibliography-notes "~/usr/org/notes.org"
1799 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1803 :init (setq alert-default-style 'notifications))
1805 ;; (use-package fill-column-indicator)
1807 (use-package emojify
1808 :hook (erc-mode . emojify-mode))
1812 (("C-c w <right>" . split-window-right)
1813 ("C-c w <down>" . split-window-below)
1814 ("C-c w s l" . split-window-right)
1815 ("C-c w s j" . split-window-below)
1816 ("C-c w q" . quit-window))
1818 (split-width-threshold 150))
1820 (use-feature windmove
1823 (("C-c w h" . windmove-left)
1824 ("C-c w j" . windmove-down)
1825 ("C-c w k" . windmove-up)
1826 ("C-c w l" . windmove-right)
1827 ("C-c w H" . windmove-swap-states-left)
1828 ("C-c w J" . windmove-swap-states-down)
1829 ("C-c w K" . windmove-swap-states-up)
1830 ("C-c w L" . windmove-swap-states-right)))
1834 :bind ("C-c a p" . pass)
1835 :hook (pass-mode . View-exit))
1837 (use-package pdf-tools
1839 :bind (:map pdf-view-mode-map
1840 ("<C-XF86Back>" . pdf-history-backward)
1841 ("<mouse-8>" . pdf-history-backward)
1842 ("<drag-mouse-8>" . pdf-history-backward)
1843 ("<C-XF86Forward>" . pdf-history-forward)
1844 ("<mouse-9>" . pdf-history-forward)
1845 ("<drag-mouse-9>" . pdf-history-forward)
1846 ("M-RET" . image-previous-line))
1847 :config (pdf-tools-install nil t)
1848 :custom (pdf-view-resize-factor 1.05))
1850 (use-package biblio)
1853 :hook (latex-mode . reftex-mode))
1855 (use-feature reftex-cite
1857 :disabled ; enable to disable
1858 ; reftex-cite's default choice
1861 (defun reftex-get-bibkey-default ()
1862 "If the cursor is in a citation macro, return the word before the macro."
1863 (let* ((macro (reftex-what-macro 1)))
1865 (when (and macro (string-match "cite" (car macro)))
1866 (goto-char (cdr macro)))
1867 (reftex-this-word)))))
1870 ;;; Email (with Gnus)
1872 (defvar b/maildir (expand-file-name "~/mail/"))
1873 (with-eval-after-load 'recentf
1874 (add-to-list 'recentf-exclude b/maildir))
1877 b/gnus-init-file (b/etc "gnus")
1878 mail-user-agent 'gnus-user-agent
1879 read-mail-command 'gnus)
1882 :bind (("s-m" . gnus)
1883 ("s-M" . gnus-unplugged)
1885 ("C-c a M" . gnus-unplugged))
1888 gnus-select-method '(nnnil "")
1889 gnus-secondary-select-methods
1890 '((nnimap "shemshak"
1891 (nnimap-stream plain)
1892 (nnimap-address "127.0.0.1")
1893 (nnimap-server-port 143)
1894 (nnimap-authenticator plain)
1895 (nnimap-user "amin@shemshak.local"))
1897 (nnimap-stream plain)
1898 (nnimap-address "127.0.0.1")
1899 (nnimap-server-port 143)
1900 (nnimap-authenticator plain)
1901 (nnimap-user "bandali@gnu.local")
1902 (nnimap-inbox "INBOX")
1903 (nnimap-split-methods 'nnimap-split-fancy)
1904 (nnimap-split-fancy (|
1905 ;; (: gnus-registry-split-fancy-with-parent)
1906 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1908 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1909 ;; *@lists.sr.ht, omitting one dot if present
1910 ;; add more \\.?\\([^.@]*\\) if needed
1911 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1913 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1915 (list ".*atreus.freelists.org" "l.atreus")
1916 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1917 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1918 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1919 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1920 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1921 ;; ----------------------------------
1922 ;; legend: (u)nsubscribed | (d)ead
1923 ;; ----------------------------------
1924 ;; otherwise, leave mail in INBOX
1927 (nnimap-stream plain)
1928 (nnimap-address "127.0.0.1")
1929 (nnimap-server-port 143)
1930 (nnimap-authenticator plain)
1931 (nnimap-user "abandali@uw.local")
1932 (nnimap-inbox "INBOX")
1933 (nnimap-split-methods 'nnimap-split-fancy)
1934 (nnimap-split-fancy (|
1935 ;; (: gnus-registry-split-fancy-with-parent)
1937 ("subject" "SE\\s-?212" "course.se212-f19")
1938 (from "SE\\s-?212" "course.se212-f19")
1942 (nnimap-stream plain)
1943 (nnimap-address "127.0.0.1")
1944 (nnimap-server-port 143)
1945 (nnimap-authenticator plain)
1946 (nnimap-user "abandali@csc.uw.local")))
1947 gnus-message-archive-group "nnimap+shemshak:Sent"
1950 (to-address . "atreus@freelists.org")
1951 (to-list . "atreus@freelists.org"))
1953 (to-address . "deepspec@lists.cs.princeton.edu")
1954 (to-list . "deepspec@lists.cs.princeton.edu")
1955 (list-identifier . "\\[deepspec\\]"))
1957 (to-address . "emacs-devel@gnu.org")
1958 (to-list . "emacs-devel@gnu.org"))
1959 ("l\\.help-gnu-emacs"
1960 (to-address . "help-gnu-emacs@gnu.org")
1961 (to-list . "help-gnu-emacs@gnu.org"))
1962 ("l\\.info-gnu-emacs"
1963 (to-address . "info-gnu-emacs@gnu.org")
1964 (to-list . "info-gnu-emacs@gnu.org"))
1965 ("l\\.emacs-orgmode"
1966 (to-address . "emacs-orgmode@gnu.org")
1967 (to-list . "emacs-orgmode@gnu.org")
1968 (list-identifier . "\\[O\\]"))
1969 ("l\\.emacs-tangents"
1970 (to-address . "emacs-tangents@gnu.org")
1971 (to-list . "emacs-tangents@gnu.org"))
1972 ("l\\.emacsconf-discuss"
1973 (to-address . "emacsconf-discuss@gnu.org")
1974 (to-list . "emacsconf-discuss@gnu.org"))
1975 ("l\\.emacsconf-register"
1976 (to-address . "emacsconf-register@gnu.org")
1977 (to-list . "emacsconf-register@gnu.org"))
1978 ("l\\.emacsconf-submit"
1979 (to-address . "emacsconf-submit@gnu.org")
1980 (to-list . "emacsconf-submit@gnu.org"))
1981 ("l\\.fencepost-users"
1982 (to-address . "fencepost-users@gnu.org")
1983 (to-list . "fencepost-users@gnu.org")
1984 (list-identifier . "\\[Fencepost-users\\]"))
1985 ("l\\.gnewsense-art"
1986 (to-address . "gnewsense-art@nongnu.org")
1987 (to-list . "gnewsense-art@nongnu.org")
1988 (list-identifier . "\\[gNewSense-art\\]"))
1989 ("l\\.gnewsense-dev"
1990 (to-address . "gnewsense-dev@nongnu.org")
1991 (to-list . "gnewsense-dev@nongnu.org")
1992 (list-identifier . "\\[Gnewsense-dev\\]"))
1993 ("l\\.gnewsense-users"
1994 (to-address . "gnewsense-users@nongnu.org")
1995 (to-list . "gnewsense-users@nongnu.org")
1996 (list-identifier . "\\[gNewSense-users\\]"))
1997 ("l\\.gnunet-developers"
1998 (to-address . "gnunet-developers@gnu.org")
1999 (to-list . "gnunet-developers@gnu.org")
2000 (list-identifier . "\\[GNUnet-developers\\]"))
2002 (to-address . "help-gnunet@gnu.org")
2003 (to-list . "help-gnunet@gnu.org")
2004 (list-identifier . "\\[Help-gnunet\\]"))
2006 (to-address . "bug-gnuzilla@gnu.org")
2007 (to-list . "bug-gnuzilla@gnu.org")
2008 (list-identifier . "\\[Bug-gnuzilla\\]"))
2010 (to-address . "gnuzilla-dev@gnu.org")
2011 (to-list . "gnuzilla-dev@gnu.org")
2012 (list-identifier . "\\[Gnuzilla-dev\\]"))
2014 (to-address . "guile-devel@gnu.org")
2015 (to-list . "guile-devel@gnu.org"))
2017 (to-address . "guile-user@gnu.org")
2018 (to-list . "guile-user@gnu.org"))
2020 (to-address . "guix-devel@gnu.org")
2021 (to-list . "guix-devel@gnu.org"))
2023 (to-address . "help-guix@gnu.org")
2024 (to-list . "help-guix@gnu.org"))
2026 (to-address . "info-guix@gnu.org")
2027 (to-list . "info-guix@gnu.org"))
2028 ("l\\.savannah-hackers-public"
2029 (to-address . "savannah-hackers-public@gnu.org")
2030 (to-list . "savannah-hackers-public@gnu.org"))
2031 ("l\\.savannah-users"
2032 (to-address . "savannah-users@gnu.org")
2033 (to-list . "savannah-users@gnu.org"))
2035 (to-address . "www-commits@gnu.org")
2036 (to-list . "www-commits@gnu.org"))
2038 (to-address . "www-discuss@gnu.org")
2039 (to-list . "www-discuss@gnu.org"))
2041 (to-address . "haskell-art@we.lurk.org")
2042 (to-list . "haskell-art@we.lurk.org")
2043 (list-identifier . "\\[haskell-art\\]"))
2045 (to-address . "haskell-cafe@haskell.org")
2046 (to-list . "haskell-cafe@haskell.org")
2047 (list-identifier . "\\[Haskell-cafe\\]"))
2049 (to-address . "notmuch@notmuchmail.org")
2050 (to-list . "notmuch@notmuchmail.org"))
2052 (to-address . "dev@lists.parabola.nu")
2053 (to-list . "dev@lists.parabola.nu")
2054 (list-identifier . "\\[Dev\\]"))
2055 ("l\\.~bandali\\.public-inbox"
2056 (to-address . "~bandali/public-inbox@lists.sr.ht")
2057 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2058 ("l\\.~sircmpwn\\.free-writers-club"
2059 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2060 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2061 ("l\\.~sircmpwn\\.srht-admins"
2062 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2063 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2064 ("l\\.~sircmpwn\\.srht-announce"
2065 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2066 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2067 ("l\\.~sircmpwn\\.srht-dev"
2068 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2069 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2070 ("l\\.~sircmpwn\\.srht-discuss"
2071 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2072 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2074 (to-address . "webmasters@gnu.org")
2075 (to-list . "webmasters@gnu.org"))
2082 gnus-large-newsgroup 50
2083 gnus-home-directory (b/var "gnus/")
2084 gnus-directory (concat gnus-home-directory "news/")
2085 message-directory (concat gnus-home-directory "mail/")
2086 nndraft-directory (concat gnus-home-directory "drafts/")
2087 gnus-save-newsrc-file nil
2088 gnus-read-newsrc-file nil
2089 gnus-interactive-exit nil
2090 gnus-gcc-mark-as-read t)
2094 (require 'ebdb-gnus)
2096 (when (version< emacs-version "27")
2098 'nnmail-split-abbrev-alist
2099 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2102 ;; (gnus-registry-initialize)
2104 (with-eval-after-load 'recentf
2105 (add-to-list 'recentf-exclude gnus-home-directory)))
2107 (use-feature gnus-art
2110 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2111 gnus-visible-headers
2112 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
2113 gnus-sorted-header-list
2114 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
2115 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
2116 "^Newsgroups:" "List-Id:" "^Organization:"
2117 "^User-Agent:" "^Date:")
2118 ;; local-lapsed article dates
2119 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2120 gnus-article-date-headers '(user-defined)
2121 gnus-article-time-format
2123 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2124 (local (article-make-date-line date 'local))
2125 (combined-lapsed (article-make-date-line date
2128 (string-match " (.+" combined-lapsed)
2129 (match-string 0 combined-lapsed))))
2130 (concat local lapsed))))
2132 :map gnus-article-mode-map
2133 ("M-L" . org-store-link)))
2135 (use-feature gnus-sum
2136 :bind (:map gnus-summary-mode-map
2137 :prefix-map b/gnus-summary-prefix-map
2139 ("r" . gnus-summary-reply)
2140 ("w" . gnus-summary-wide-reply)
2141 ("v" . gnus-summary-show-raw-article))
2144 :map gnus-summary-mode-map
2145 ("M-L" . org-store-link))
2146 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2148 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2149 gnus-thread-sort-by-subject
2150 gnus-thread-sort-by-date)))
2152 (use-feature gnus-msg
2154 (defvar b/signature "Amin Bandali
2155 Free Software Activist | GNU Webmaster & Volunteer
2156 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2157 https://shemshak.org/~amin")
2158 (defvar b/gnu-signature "Amin Bandali
2159 Free Software Activist | GNU Webmaster & Volunteer
2160 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2161 https://bandali.eu.org")
2162 (defvar b/uw-signature "Amin Bandali, MMath Student
2163 Cheriton School of Computer Science
2164 University of Waterloo
2165 https://bandali.eu.org")
2166 (defvar b/csc-signature "Amin Bandali
2168 Computer Science Club, University of Waterloo
2169 https://csclub.uwaterloo.ca/~abandali")
2170 (setq gnus-posting-styles
2172 (address "amin@shemshak.org")
2174 (signature b/signature)
2175 (eval (setq b/message-cite-say-hi t)))
2177 (address "bandali@gnu.org")
2178 (signature b/gnu-signature)
2179 (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org")))
2180 ((header "subject" "ThankCRM")
2181 (to "webmasters-comment@gnu.org")
2183 (eval (setq b/message-cite-say-hi nil)))
2185 (address "abandali@uwaterloo.ca")
2186 (signature b/uw-signature))
2187 ("nnimap\\+uw:INBOX"
2188 (gcc "\"nnimap+uw:Sent Items\""))
2190 (address "abandali@csclub.uwaterloo.ca")
2191 (signature b/csc-signature)
2192 (gcc "nnimap+csc:Sent")))))
2194 (use-feature gnus-topic
2195 :hook (gnus-group-mode . gnus-topic-mode)
2196 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2198 (use-feature gnus-agent
2200 (setq gnus-agent-synchronize-flags 'ask)
2201 :hook (gnus-group-mode . gnus-agent-mode))
2203 (use-feature gnus-group
2205 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2208 ;; problematic with ebdb's popup, *EBDB-Gnus*
2209 (use-feature gnus-win
2211 (setq gnus-use-full-window nil)))
2213 (use-feature gnus-dired
2214 :commands gnus-dired-mode
2216 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2218 (use-feature mm-decode
2220 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2221 mm-decrypt-option 'known
2222 mm-verify-option 'known))
2224 (use-feature sendmail
2226 (setq sendmail-program (executable-find "msmtp")
2227 ;; message-sendmail-extra-arguments '("-v" "-d")
2228 mail-specify-envelope-from t
2229 mail-envelope-from 'header))
2231 (use-feature message
2233 ;; redefine for a simplified In-Reply-To header
2234 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2235 (defun message-make-in-reply-to ()
2236 "Return the In-Reply-To header for this message."
2237 (when message-reply-headers
2238 (let ((from (mail-header-from message-reply-headers))
2239 (msg-id (mail-header-id message-reply-headers)))
2243 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2244 (defconst message-cite-style-bandali
2245 '((message-cite-function 'message-cite-original)
2246 (message-citation-line-function 'message-insert-formatted-citation-line)
2247 (message-cite-reply-position 'traditional)
2248 (message-yank-prefix "> ")
2249 (message-yank-cited-prefix ">")
2250 (message-yank-empty-prefix ">")
2251 (message-citation-line-format
2252 (if b/message-cite-say-hi
2253 (concat "Hi %F,\n\n" b/message-cite-style-format)
2254 b/message-cite-style-format)))
2255 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2256 (setq ;; message-cite-style 'message-cite-style-bandali
2257 message-kill-buffer-on-exit t
2258 message-send-mail-function 'message-send-mail-with-sendmail
2259 message-sendmail-envelope-from 'header
2260 message-subscribed-address-functions
2261 '(gnus-find-subscribed-addresses)
2262 message-dont-reply-to-names
2263 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2264 (require 'company-ebdb)
2265 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2266 (message-mode . flyspell-mode)
2267 (message-mode . (lambda ()
2268 ;; (setq fill-column 65
2269 ;; message-fill-column 65)
2270 (make-local-variable 'company-idle-delay)
2271 (setq company-idle-delay 0.2))))
2273 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2274 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2275 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2281 (use-feature mml-sec
2283 (mml-secure-openpgp-encrypt-to-self t)
2284 (mml-secure-openpgp-sign-with-sender t))
2286 (use-feature footnote
2289 ;; (setq footnote-start-tag ""
2290 ;; footnote-end-tag ""
2291 ;; footnote-style 'unicode)
2293 (:map message-mode-map
2294 :prefix-map b/footnote-prefix-map
2296 ("a" . footnote-add-footnote)
2297 ("b" . footnote-back-to-message)
2298 ("c" . footnote-cycle-style)
2299 ("d" . footnote-delete-footnote)
2300 ("g" . footnote-goto-footnote)
2301 ("r" . footnote-renumber-footnotes)
2302 ("s" . footnote-set-style)))
2306 :bind (:map gnus-group-mode-map ("e" . ebdb))
2308 (setq ebdb-sources (b/var "ebdb"))
2309 (with-eval-after-load 'swiper
2310 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2312 (use-feature ebdb-com
2315 ;; (use-package ebdb-complete
2318 ;; (ebdb-complete-enable))
2320 (use-package company-ebdb
2322 (defun company-ebdb--post-complete (_) nil))
2324 (use-feature ebdb-gnus
2327 (ebdb-gnus-window-size 0.3))
2329 (use-feature ebdb-mua
2331 ;; :custom (ebdb-mua-pop-up nil)
2334 ;; (use-package ebdb-message
2337 ;; (use-package ebdb-vcard
2340 (use-package message-x)
2343 (use-package message-x
2345 (message-x-completion-alist
2347 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2350 (quote message-newgroups-header-regexp))
2351 message-newgroups-header-regexp message-newsgroups-header-regexp)
2352 . message-expand-group))))))
2355 (use-package gnus-harvest
2356 :commands gnus-harvest-install
2359 (if (featurep 'message-x)
2360 (gnus-harvest-install 'message-x)
2361 (gnus-harvest-install))))
2363 (use-feature gnus-article-treat-patch
2368 (setq ft/gnus-article-patch-conditions
2369 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2372 ;;; IRC (with ERC and ZNC)
2375 :bind (("C-c b e" . erc-switch-to-buffer)
2377 ("M-a" . erc-track-switch-buffer))
2379 (erc-join-buffer 'bury)
2380 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2381 (erc-nick "bandali")
2383 (erc-rename-buffers t)
2384 (erc-server-reconnect-attempts 5)
2385 (erc-server-reconnect-timeout 3)
2387 (defun erc-cmd-OPME ()
2388 "Request chanserv to op me."
2389 (erc-message "PRIVMSG"
2390 (format "chanserv op %s %s"
2391 (erc-default-target)
2392 (erc-current-nick)) nil))
2393 (defun erc-cmd-DEOPME ()
2394 "Deop myself from current channel."
2395 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2396 (add-to-list 'erc-modules 'keep-place)
2397 (add-to-list 'erc-modules 'notifications)
2398 (add-to-list 'erc-modules 'spelling)
2399 (add-to-list 'erc-modules 'scrolltoplace)
2400 (erc-update-modules)
2402 (when (and (version<= "24.4" emacs-version)
2403 (version< emacs-version "27"))
2404 ;; fix erc-lurker bug
2405 ;; patch submitted: https://bugs.gnu.org/36843#10
2406 ;; TODO: remove when patch is merged and emacs 27 is released
2407 (defvar erc-message-parsed)
2408 (defun erc-display-message (parsed type buffer msg &rest args)
2409 "Display MSG in BUFFER.
2411 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2413 See also `erc-format-message' and `erc-display-line'."
2414 (let ((string (if (symbolp msg)
2415 (apply #'erc-format-message msg args)
2417 (erc-message-parsed parsed))
2423 (mapc (lambda (type)
2425 (erc-display-message-highlight type string)))
2429 (erc-display-message-highlight type string))))
2431 (if (not (erc-response-p parsed))
2432 (erc-display-line string buffer)
2433 (unless (erc-hide-current-message-p parsed)
2434 (erc-put-text-property 0 (length string) 'erc-parsed parsed string)
2435 (erc-put-text-property 0 (length string) 'rear-sticky t string)
2436 (when (erc-response.tags parsed)
2437 (erc-put-text-property 0 (length string) 'tags (erc-response.tags parsed)
2439 (erc-display-line string buffer)))))
2441 (defun erc-lurker-update-status (_message)
2442 "Update `erc-lurker-state' if necessary.
2444 This function is called from `erc-insert-pre-hook'. If the
2445 current message is a PRIVMSG, update `erc-lurker-state' to
2446 reflect the fact that its sender has issued a PRIVMSG at the
2447 current time. Otherwise, take no action.
2449 This function depends on the fact that `erc-display-message'
2450 lexically binds `erc-message-parsed', which is used to check if
2451 the current message is a PRIVMSG and to determine its sender.
2452 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2454 In order to limit memory consumption, this function also calls
2455 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2456 updates of `erc-lurker-state'."
2457 (when (and (boundp 'erc-message-parsed)
2458 (erc-response-p erc-message-parsed))
2459 (let* ((command (erc-response.command erc-message-parsed))
2461 (erc-lurker-maybe-trim
2462 (car (erc-parse-user (erc-response.sender erc-message-parsed)))))
2464 (erc-canonicalize-server-name erc-server-announced-name)))
2465 (when (equal command "PRIVMSG")
2466 (when (>= (cl-incf erc-lurker-cleanup-count)
2467 erc-lurker-cleanup-interval)
2468 (setq erc-lurker-cleanup-count 0)
2469 (erc-lurker-cleanup))
2470 (unless (gethash server erc-lurker-state)
2471 (puthash server (make-hash-table :test 'equal) erc-lurker-state))
2472 (puthash sender (current-time)
2473 (gethash server erc-lurker-state))))))))
2475 (use-feature erc-fill
2478 (erc-fill-column 77)
2479 (erc-fill-function 'erc-fill-static)
2480 (erc-fill-static-center 18))
2482 (use-feature erc-pcomplete
2485 (erc-pcomplete-nick-postfix ","))
2487 (use-feature erc-track
2489 :bind (("C-c a e t d" . erc-track-disable)
2490 ("C-c a e t e" . erc-track-enable))
2492 (erc-track-enable-keybindings nil)
2493 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2494 "324" "329" "332" "333" "353" "477"))
2495 (erc-track-priority-faces-only 'all)
2496 (erc-track-shorten-function nil))
2498 (use-package erc-hl-nicks
2501 (use-package erc-scrolltoplace
2505 :straight (:host nil :repo "https://git.shemshak.org/amin/znc.el")
2506 :bind (("C-c a e e" . znc-erc)
2507 ("C-c a e a" . znc-all))
2509 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2511 ((null auth) (error "Couldn't find znca's authinfo"))
2512 (t (funcall (plist-get (car auth) :secret)))))))
2514 `(("znc.shemshak.org" 1337 t
2515 ((freenode "amin/freenode" ,pwd)))
2516 ("znc.shemshak.org" 1337 t
2517 ((moznet "amin/moznet" ,pwd)))
2518 ("znc.shemshak.org" 1337 t
2519 ((oftc "amin/oftc" ,pwd)))))))
2522 ;;; Post initialization
2524 (message "Loading %s...done (%.3fs)" user-init-file
2525 (float-time (time-subtract (current-time)
2526 b/before-user-init-time)))
2528 ;;; init.el ends here