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)))
1450 (add-to-list 'custom-theme-load-path
1452 (convert-standard-filename "lisp") user-emacs-directory))
1453 (load-theme 'tangomod t)
1455 (use-package smart-mode-line
1456 :commands (sml/apply-theme)
1460 (smart-mode-line-enable))
1462 (use-package doom-themes)
1464 (defvar b/org-mode-font-lock-keywords
1465 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1466 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
1467 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
1468 (4 '(:foreground "#c5c8c6") t)))) ; title
1470 (defun b/lights-on ()
1471 "Enable my favourite light theme."
1473 (mapc #'disable-theme custom-enabled-themes)
1474 (load-theme 'tangomod t)
1475 (sml/apply-theme 'automatic)
1476 (font-lock-remove-keywords
1477 'org-mode b/org-mode-font-lock-keywords))
1479 (defun b/lights-off ()
1482 (mapc #'disable-theme custom-enabled-themes)
1483 (load-theme 'doom-tomorrow-night t)
1484 (sml/apply-theme 'automatic)
1485 (font-lock-add-keywords
1486 'org-mode b/org-mode-font-lock-keywords t))
1489 ("C-c t d" . b/lights-off)
1490 ("C-c t l" . b/lights-on))
1493 ;;; Emacs enhancements & auxiliary packages
1496 :config (setq Man-width 80))
1498 (use-package which-key
1502 (which-key-add-key-based-replacements
1503 ;; prefixes for global prefixes and minor modes
1507 "C-c 8 -" "typo/dashes"
1508 "C-c 8 <" "typo/left-brackets"
1509 "C-c 8 >" "typo/right-brackets"
1511 "C-x a" "abbrev/expand"
1512 "C-x r" "rectangle/register/bookmark"
1513 "C-x v" "version control"
1514 ;; prefixes for my personal bindings
1515 "C-c a" "applications"
1520 "C-c c" "compile-and-comments"
1526 "C-c m" "multiple-cursors"
1527 "C-c P" "projectile"
1528 "C-c P s" "projectile/search"
1529 "C-c P x" "projectile/execute"
1530 "C-c P 4" "projectile/other-window"
1536 ;; prefixes for major modes
1537 (which-key-add-major-mode-key-based-replacements 'message-mode
1538 "C-c f n" "footnote")
1539 (which-key-add-major-mode-key-based-replacements 'org-mode
1540 "C-c C-v" "org-babel")
1541 (which-key-add-major-mode-key-based-replacements 'web-mode
1542 "C-c C-a" "web/attributes"
1543 "C-c C-b" "web/blocks"
1545 "C-c C-e" "web/element"
1546 "C-c C-t" "web/tags")
1550 (which-key-add-column-padding 5)
1551 (which-key-max-description-length 32))
1553 (use-package crux ; results in Waiting for git... [2 times]
1555 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1556 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
1557 ("C-c f c" . crux-copy-file-preserve-attributes)
1558 ("C-c f d" . crux-delete-file-and-buffer)
1559 ("C-c f r" . crux-rename-file-and-buffer)
1560 ("C-c j" . crux-top-join-line)
1561 ("C-S-j" . crux-top-join-line)))
1564 :bind (("C-a" . mwim-beginning-of-code-or-line)
1565 ("C-e" . mwim-end-of-code-or-line)
1566 ("<home>" . mwim-beginning-of-line-or-code)
1567 ("<end>" . mwim-end-of-line-or-code)))
1569 (use-package projectile
1571 :bind-keymap ("C-c P" . projectile-command-map)
1575 (defun b/projectile-mode-line-fun ()
1576 "Report project name and type in the modeline."
1577 (let ((project-name (projectile-project-name))
1578 (project-type (projectile-project-type)))
1580 projectile-mode-line-prefix
1582 (format ":%s" project-type)
1584 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1586 (defun my-projectile-invalidate-cache (&rest _args)
1587 ;; ignore the args to `magit-checkout'
1588 (projectile-invalidate-cache nil))
1590 (eval-after-load 'magit-branch
1592 (advice-add 'magit-checkout
1593 :after #'my-projectile-invalidate-cache)
1594 (advice-add 'magit-branch-and-checkout
1595 :after #'my-projectile-invalidate-cache)))
1597 (projectile-completion-system 'ivy)
1598 (projectile-mode-line-prefix " proj"))
1600 (use-package helpful
1603 (("C-S-h c" . helpful-command)
1604 ("C-S-h f" . helpful-callable) ; helpful-function
1605 ("C-S-h v" . helpful-variable)
1606 ("C-S-h k" . helpful-key)
1607 ("C-S-h p" . helpful-at-point)))
1609 (use-package unkillable-scratch
1612 (unkillable-scratch 1)
1614 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1617 ;; | make pretty boxed quotes like this
1619 (use-package boxquote
1622 (:prefix-map b/boxquote-prefix-map
1624 ("b" . boxquote-buffer)
1625 ("B" . boxquote-insert-buffer)
1626 ("d" . boxquote-defun)
1627 ("F" . boxquote-insert-file)
1628 ("hf" . boxquote-describe-function)
1629 ("hk" . boxquote-describe-key)
1630 ("hv" . boxquote-describe-variable)
1631 ("hw" . boxquote-where-is)
1632 ("k" . boxquote-kill)
1633 ("p" . boxquote-paragraph)
1634 ("q" . boxquote-boxquote)
1635 ("r" . boxquote-region)
1636 ("s" . boxquote-shell-command)
1637 ("t" . boxquote-text)
1638 ("T" . boxquote-title)
1639 ("u" . boxquote-unbox)
1640 ("U" . boxquote-unbox-region)
1641 ("y" . boxquote-yank)
1642 ("M-q" . boxquote-fill-paragraph)
1643 ("M-w" . boxquote-kill-ring-save)))
1645 (use-package orgalist
1646 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1649 :hook (message-mode . orgalist-mode))
1651 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1656 (typo-global-mode 1)
1657 :hook (((text-mode erc-mode) . typo-mode)
1658 (tex-mode . (lambda ()(typo-mode -1)))))
1660 ;; highlight TODOs in buffers
1661 (use-package hl-todo
1664 (global-hl-todo-mode))
1666 (use-package shrink-path
1670 (defvar user-@-host (concat (user-login-name) "@" (system-name) " "))
1671 (defun +eshell/prompt ()
1672 (let ((base/dir (shrink-path-prompt default-directory)))
1673 (concat (propertize user-@-host 'face 'default)
1674 (propertize (car base/dir)
1675 'face 'font-lock-comment-face)
1676 (propertize (cdr base/dir)
1677 'face 'font-lock-constant-face)
1678 (propertize "> " 'face 'default))))
1679 (setq eshell-prompt-regexp (concat user-@-host ".*> ")
1680 eshell-prompt-function #'+eshell/prompt))
1682 (use-package eshell-up
1684 :commands eshell-up)
1686 (use-package multi-term
1688 :bind (("C-c a s m m" . multi-term)
1689 ("C-c a s m d" . multi-term-dedicated-toggle)
1690 ("C-c a s m p" . multi-term-prev)
1691 ("C-c a s m n" . multi-term-next)
1693 ("C-c C-j" . term-char-mode))
1695 (setq multi-term-program "screen"
1696 multi-term-program-switches (concat "-c"
1697 (getenv "XDG_CONFIG_HOME")
1699 ;; TODO: add separate bindings for connecting to existing
1700 ;; session vs. always creating a new one
1701 multi-term-dedicated-select-after-open-p t
1702 multi-term-dedicated-window-height 20
1703 multi-term-dedicated-max-window-height 30
1705 '(("C-c C-c" . term-interrupt-subjob)
1706 ("C-c C-e" . term-send-esc)
1707 ("C-c C-j" . term-line-mode)
1709 ;; ("C-y" . term-paste)
1710 ("C-y" . term-send-raw)
1711 ("M-f" . term-send-forward-word)
1712 ("M-b" . term-send-backward-word)
1713 ("M-p" . term-send-up)
1714 ("M-n" . term-send-down)
1715 ("M-j" . term-send-raw-meta)
1716 ("M-y" . term-send-raw-meta)
1717 ("M-/" . term-send-raw-meta)
1718 ("M-0" . term-send-raw-meta)
1719 ("M-1" . term-send-raw-meta)
1720 ("M-2" . term-send-raw-meta)
1721 ("M-3" . term-send-raw-meta)
1722 ("M-4" . term-send-raw-meta)
1723 ("M-5" . term-send-raw-meta)
1724 ("M-6" . term-send-raw-meta)
1725 ("M-7" . term-send-raw-meta)
1726 ("M-8" . term-send-raw-meta)
1727 ("M-9" . term-send-raw-meta)
1728 ("<C-backspace>" . term-send-backward-kill-word)
1729 ("<M-DEL>" . term-send-backward-kill-word)
1730 ("M-d" . term-send-delete-word)
1731 ("M-," . term-send-raw)
1732 ("M-." . comint-dynamic-complete))
1733 term-unbind-key-alist
1734 '("C-z" "C-x" "C-c" "C-h"
1738 (use-package page-break-lines
1742 (page-break-lines-max-width fill-column)
1744 (global-page-break-lines-mode))
1746 (use-package expand-region
1747 :bind ("C-=" . er/expand-region))
1749 (use-package multiple-cursors
1751 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1752 (:prefix-map b/mc-prefix-map
1754 ("c" . mc/edit-lines)
1755 ("n" . mc/mark-next-like-this)
1756 ("p" . mc/mark-previous-like-this)
1757 ("a" . mc/mark-all-like-this))))
1765 (use-package yasnippet
1768 (defconst yas-verbosity-cur yas-verbosity)
1769 (setq yas-verbosity 2)
1770 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1772 (setq yas-verbosity yas-verbosity-cur)
1774 (defun b/yas--maybe-expand-key-filter (cmd)
1775 (when (and (yas--maybe-expand-key-filter cmd)
1776 (not (bound-and-true-p git-commit-mode)))
1778 (defconst b/yas-maybe-expand
1779 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1780 (define-key yas-minor-mode-map
1781 (kbd "SPC") b/yas-maybe-expand)
1785 (use-package debbugs
1788 :repo "emacs-straight/debbugs"
1789 :files (:defaults "Debbugs.wsdl")))
1791 (use-package org-ref
1793 (b/setq-every '("~/usr/org/references.bib")
1794 reftex-default-bibliography
1795 org-ref-default-bibliography)
1797 org-ref-bibliography-notes "~/usr/org/notes.org"
1798 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1802 :init (setq alert-default-style 'notifications))
1804 ;; (use-package fill-column-indicator)
1806 (use-package emojify
1807 :hook (erc-mode . emojify-mode))
1811 (("C-c w <right>" . split-window-right)
1812 ("C-c w <down>" . split-window-below)
1813 ("C-c w s l" . split-window-right)
1814 ("C-c w s j" . split-window-below)
1815 ("C-c w q" . quit-window))
1817 (split-width-threshold 150))
1819 (use-feature windmove
1822 (("C-c w h" . windmove-left)
1823 ("C-c w j" . windmove-down)
1824 ("C-c w k" . windmove-up)
1825 ("C-c w l" . windmove-right)
1826 ("C-c w H" . windmove-swap-states-left)
1827 ("C-c w J" . windmove-swap-states-down)
1828 ("C-c w K" . windmove-swap-states-up)
1829 ("C-c w L" . windmove-swap-states-right)))
1833 :bind ("C-c a p" . pass)
1834 :hook (pass-mode . View-exit))
1836 (use-package pdf-tools
1838 :bind (:map pdf-view-mode-map
1839 ("<C-XF86Back>" . pdf-history-backward)
1840 ("<mouse-8>" . pdf-history-backward)
1841 ("<drag-mouse-8>" . pdf-history-backward)
1842 ("<C-XF86Forward>" . pdf-history-forward)
1843 ("<mouse-9>" . pdf-history-forward)
1844 ("<drag-mouse-9>" . pdf-history-forward)
1845 ("M-RET" . image-previous-line))
1846 :config (pdf-tools-install nil t)
1847 :custom (pdf-view-resize-factor 1.05))
1849 (use-package biblio)
1852 :hook (latex-mode . reftex-mode))
1854 (use-feature reftex-cite
1856 :disabled ; enable to disable
1857 ; reftex-cite's default choice
1860 (defun reftex-get-bibkey-default ()
1861 "If the cursor is in a citation macro, return the word before the macro."
1862 (let* ((macro (reftex-what-macro 1)))
1864 (when (and macro (string-match "cite" (car macro)))
1865 (goto-char (cdr macro)))
1866 (reftex-this-word)))))
1869 ;;; Email (with Gnus)
1871 (defvar b/maildir (expand-file-name "~/mail/"))
1872 (with-eval-after-load 'recentf
1873 (add-to-list 'recentf-exclude b/maildir))
1876 b/gnus-init-file (b/etc "gnus")
1877 mail-user-agent 'gnus-user-agent
1878 read-mail-command 'gnus)
1881 :bind (("s-m" . gnus)
1882 ("s-M" . gnus-unplugged)
1884 ("C-c a M" . gnus-unplugged))
1887 gnus-select-method '(nnnil "")
1888 gnus-secondary-select-methods
1889 '((nnimap "shemshak"
1890 (nnimap-stream plain)
1891 (nnimap-address "127.0.0.1")
1892 (nnimap-server-port 143)
1893 (nnimap-authenticator plain)
1894 (nnimap-user "amin@shemshak.local"))
1896 (nnimap-stream plain)
1897 (nnimap-address "127.0.0.1")
1898 (nnimap-server-port 143)
1899 (nnimap-authenticator plain)
1900 (nnimap-user "bandali@gnu.local")
1901 (nnimap-inbox "INBOX")
1902 (nnimap-split-methods 'nnimap-split-fancy)
1903 (nnimap-split-fancy (|
1904 ;; (: gnus-registry-split-fancy-with-parent)
1905 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1907 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1908 ;; *@lists.sr.ht, omitting one dot if present
1909 ;; add more \\.?\\([^.@]*\\) if needed
1910 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1912 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1914 (list ".*atreus.freelists.org" "l.atreus")
1915 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1916 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1917 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1918 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1919 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1920 ;; ----------------------------------
1921 ;; legend: (u)nsubscribed | (d)ead
1922 ;; ----------------------------------
1923 ;; otherwise, leave mail in INBOX
1926 (nnimap-stream plain)
1927 (nnimap-address "127.0.0.1")
1928 (nnimap-server-port 143)
1929 (nnimap-authenticator plain)
1930 (nnimap-user "abandali@uw.local")
1931 (nnimap-inbox "INBOX")
1932 (nnimap-split-methods 'nnimap-split-fancy)
1933 (nnimap-split-fancy (|
1934 ;; (: gnus-registry-split-fancy-with-parent)
1936 ("subject" "SE\\s-?212" "course.se212-f19")
1937 (from "SE\\s-?212" "course.se212-f19")
1941 (nnimap-stream plain)
1942 (nnimap-address "127.0.0.1")
1943 (nnimap-server-port 143)
1944 (nnimap-authenticator plain)
1945 (nnimap-user "abandali@csc.uw.local")))
1946 gnus-message-archive-group "nnimap+shemshak:Sent"
1949 (to-address . "atreus@freelists.org")
1950 (to-list . "atreus@freelists.org"))
1952 (to-address . "deepspec@lists.cs.princeton.edu")
1953 (to-list . "deepspec@lists.cs.princeton.edu")
1954 (list-identifier . "\\[deepspec\\]"))
1956 (to-address . "emacs-devel@gnu.org")
1957 (to-list . "emacs-devel@gnu.org"))
1958 ("l\\.help-gnu-emacs"
1959 (to-address . "help-gnu-emacs@gnu.org")
1960 (to-list . "help-gnu-emacs@gnu.org"))
1961 ("l\\.info-gnu-emacs"
1962 (to-address . "info-gnu-emacs@gnu.org")
1963 (to-list . "info-gnu-emacs@gnu.org"))
1964 ("l\\.emacs-orgmode"
1965 (to-address . "emacs-orgmode@gnu.org")
1966 (to-list . "emacs-orgmode@gnu.org")
1967 (list-identifier . "\\[O\\]"))
1968 ("l\\.emacs-tangents"
1969 (to-address . "emacs-tangents@gnu.org")
1970 (to-list . "emacs-tangents@gnu.org"))
1971 ("l\\.emacsconf-discuss"
1972 (to-address . "emacsconf-discuss@gnu.org")
1973 (to-list . "emacsconf-discuss@gnu.org"))
1974 ("l\\.emacsconf-register"
1975 (to-address . "emacsconf-register@gnu.org")
1976 (to-list . "emacsconf-register@gnu.org"))
1977 ("l\\.emacsconf-submit"
1978 (to-address . "emacsconf-submit@gnu.org")
1979 (to-list . "emacsconf-submit@gnu.org"))
1980 ("l\\.fencepost-users"
1981 (to-address . "fencepost-users@gnu.org")
1982 (to-list . "fencepost-users@gnu.org")
1983 (list-identifier . "\\[Fencepost-users\\]"))
1984 ("l\\.gnewsense-art"
1985 (to-address . "gnewsense-art@nongnu.org")
1986 (to-list . "gnewsense-art@nongnu.org")
1987 (list-identifier . "\\[gNewSense-art\\]"))
1988 ("l\\.gnewsense-dev"
1989 (to-address . "gnewsense-dev@nongnu.org")
1990 (to-list . "gnewsense-dev@nongnu.org")
1991 (list-identifier . "\\[Gnewsense-dev\\]"))
1992 ("l\\.gnewsense-users"
1993 (to-address . "gnewsense-users@nongnu.org")
1994 (to-list . "gnewsense-users@nongnu.org")
1995 (list-identifier . "\\[gNewSense-users\\]"))
1996 ("l\\.gnunet-developers"
1997 (to-address . "gnunet-developers@gnu.org")
1998 (to-list . "gnunet-developers@gnu.org")
1999 (list-identifier . "\\[GNUnet-developers\\]"))
2001 (to-address . "help-gnunet@gnu.org")
2002 (to-list . "help-gnunet@gnu.org")
2003 (list-identifier . "\\[Help-gnunet\\]"))
2005 (to-address . "bug-gnuzilla@gnu.org")
2006 (to-list . "bug-gnuzilla@gnu.org")
2007 (list-identifier . "\\[Bug-gnuzilla\\]"))
2009 (to-address . "gnuzilla-dev@gnu.org")
2010 (to-list . "gnuzilla-dev@gnu.org")
2011 (list-identifier . "\\[Gnuzilla-dev\\]"))
2013 (to-address . "guile-devel@gnu.org")
2014 (to-list . "guile-devel@gnu.org"))
2016 (to-address . "guile-user@gnu.org")
2017 (to-list . "guile-user@gnu.org"))
2019 (to-address . "guix-devel@gnu.org")
2020 (to-list . "guix-devel@gnu.org"))
2022 (to-address . "help-guix@gnu.org")
2023 (to-list . "help-guix@gnu.org"))
2025 (to-address . "info-guix@gnu.org")
2026 (to-list . "info-guix@gnu.org"))
2027 ("l\\.savannah-hackers-public"
2028 (to-address . "savannah-hackers-public@gnu.org")
2029 (to-list . "savannah-hackers-public@gnu.org"))
2030 ("l\\.savannah-users"
2031 (to-address . "savannah-users@gnu.org")
2032 (to-list . "savannah-users@gnu.org"))
2034 (to-address . "www-commits@gnu.org")
2035 (to-list . "www-commits@gnu.org"))
2037 (to-address . "www-discuss@gnu.org")
2038 (to-list . "www-discuss@gnu.org"))
2040 (to-address . "haskell-art@we.lurk.org")
2041 (to-list . "haskell-art@we.lurk.org")
2042 (list-identifier . "\\[haskell-art\\]"))
2044 (to-address . "haskell-cafe@haskell.org")
2045 (to-list . "haskell-cafe@haskell.org")
2046 (list-identifier . "\\[Haskell-cafe\\]"))
2048 (to-address . "notmuch@notmuchmail.org")
2049 (to-list . "notmuch@notmuchmail.org"))
2051 (to-address . "dev@lists.parabola.nu")
2052 (to-list . "dev@lists.parabola.nu")
2053 (list-identifier . "\\[Dev\\]"))
2054 ("l\\.~bandali\\.public-inbox"
2055 (to-address . "~bandali/public-inbox@lists.sr.ht")
2056 (to-list . "~bandali/public-inbox@lists.sr.ht"))
2057 ("l\\.~sircmpwn\\.free-writers-club"
2058 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
2059 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
2060 ("l\\.~sircmpwn\\.srht-admins"
2061 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
2062 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
2063 ("l\\.~sircmpwn\\.srht-announce"
2064 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
2065 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
2066 ("l\\.~sircmpwn\\.srht-dev"
2067 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
2068 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
2069 ("l\\.~sircmpwn\\.srht-discuss"
2070 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
2071 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
2073 (to-address . "webmasters@gnu.org")
2074 (to-list . "webmasters@gnu.org"))
2081 gnus-large-newsgroup 50
2082 gnus-home-directory (b/var "gnus/")
2083 gnus-directory (concat gnus-home-directory "news/")
2084 message-directory (concat gnus-home-directory "mail/")
2085 nndraft-directory (concat gnus-home-directory "drafts/")
2086 gnus-save-newsrc-file nil
2087 gnus-read-newsrc-file nil
2088 gnus-interactive-exit nil
2089 gnus-gcc-mark-as-read t)
2093 (require 'ebdb-gnus)
2095 (when (version< emacs-version "27")
2097 'nnmail-split-abbrev-alist
2098 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
2101 ;; (gnus-registry-initialize)
2103 (with-eval-after-load 'recentf
2104 (add-to-list 'recentf-exclude gnus-home-directory)))
2106 (use-feature gnus-art
2109 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
2110 gnus-visible-headers
2111 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
2112 gnus-sorted-header-list
2113 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
2114 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
2115 "^Newsgroups:" "List-Id:" "^Organization:"
2116 "^User-Agent:" "^Date:")
2117 ;; local-lapsed article dates
2118 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
2119 gnus-article-date-headers '(user-defined)
2120 gnus-article-time-format
2122 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
2123 (local (article-make-date-line date 'local))
2124 (combined-lapsed (article-make-date-line date
2127 (string-match " (.+" combined-lapsed)
2128 (match-string 0 combined-lapsed))))
2129 (concat local lapsed))))
2131 :map gnus-article-mode-map
2132 ("M-L" . org-store-link)))
2134 (use-feature gnus-sum
2135 :bind (:map gnus-summary-mode-map
2136 :prefix-map b/gnus-summary-prefix-map
2138 ("r" . gnus-summary-reply)
2139 ("w" . gnus-summary-wide-reply)
2140 ("v" . gnus-summary-show-raw-article))
2143 :map gnus-summary-mode-map
2144 ("M-L" . org-store-link))
2145 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
2147 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
2148 gnus-thread-sort-by-subject
2149 gnus-thread-sort-by-date)))
2151 (use-feature gnus-msg
2153 (defvar b/signature "Amin Bandali
2154 Free Software Activist | GNU Webmaster & Volunteer
2155 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2156 https://shemshak.org/~amin")
2157 (defvar b/gnu-signature "Amin Bandali
2158 Free Software Activist | GNU Webmaster & Volunteer
2159 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2160 https://bandali.eu.org")
2161 (defvar b/uw-signature "Amin Bandali, MMath Student
2162 Cheriton School of Computer Science
2163 University of Waterloo
2164 https://bandali.eu.org")
2165 (defvar b/csc-signature "Amin Bandali
2167 Computer Science Club, University of Waterloo
2168 https://csclub.uwaterloo.ca/~abandali")
2169 (setq gnus-posting-styles
2171 (address "amin@shemshak.org")
2173 (signature b/signature)
2174 (eval (setq b/message-cite-say-hi t)))
2176 (address "bandali@gnu.org")
2177 (signature b/gnu-signature)
2178 (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org")))
2179 ((header "subject" "ThankCRM")
2180 (to "webmasters-comment@gnu.org")
2182 (eval (setq b/message-cite-say-hi nil)))
2184 (address "abandali@uwaterloo.ca")
2185 (signature b/uw-signature))
2186 ("nnimap\\+uw:INBOX"
2187 (gcc "\"nnimap+uw:Sent Items\""))
2189 (address "abandali@csclub.uwaterloo.ca")
2190 (signature b/csc-signature)
2191 (gcc "nnimap+csc:Sent")))))
2193 (use-feature gnus-topic
2194 :hook (gnus-group-mode . gnus-topic-mode)
2195 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
2197 (use-feature gnus-agent
2199 (setq gnus-agent-synchronize-flags 'ask)
2200 :hook (gnus-group-mode . gnus-agent-mode))
2202 (use-feature gnus-group
2204 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
2207 ;; problematic with ebdb's popup, *EBDB-Gnus*
2208 (use-feature gnus-win
2210 (setq gnus-use-full-window nil)))
2212 (use-feature gnus-dired
2213 :commands gnus-dired-mode
2215 (add-hook 'dired-mode-hook 'gnus-dired-mode))
2217 (use-feature mm-decode
2219 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
2220 mm-decrypt-option 'known
2221 mm-verify-option 'known))
2225 (mm-uu-diff-groups-regexp
2226 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
2228 (use-feature sendmail
2230 (setq sendmail-program (executable-find "msmtp")
2231 ;; message-sendmail-extra-arguments '("-v" "-d")
2232 mail-specify-envelope-from t
2233 mail-envelope-from 'header))
2235 (use-feature message
2237 ;; redefine for a simplified In-Reply-To header
2238 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2239 (defun message-make-in-reply-to ()
2240 "Return the In-Reply-To header for this message."
2241 (when message-reply-headers
2242 (let ((from (mail-header-from message-reply-headers))
2243 (msg-id (mail-header-id message-reply-headers)))
2247 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2248 (defconst message-cite-style-bandali
2249 '((message-cite-function 'message-cite-original)
2250 (message-citation-line-function 'message-insert-formatted-citation-line)
2251 (message-cite-reply-position 'traditional)
2252 (message-yank-prefix "> ")
2253 (message-yank-cited-prefix ">")
2254 (message-yank-empty-prefix ">")
2255 (message-citation-line-format
2256 (if b/message-cite-say-hi
2257 (concat "Hi %F,\n\n" b/message-cite-style-format)
2258 b/message-cite-style-format)))
2259 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2260 (setq ;; message-cite-style 'message-cite-style-bandali
2261 message-kill-buffer-on-exit t
2262 message-send-mail-function 'message-send-mail-with-sendmail
2263 message-sendmail-envelope-from 'header
2264 message-subscribed-address-functions
2265 '(gnus-find-subscribed-addresses)
2266 message-dont-reply-to-names
2267 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2268 (require 'company-ebdb)
2269 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2270 (message-mode . flyspell-mode)
2271 (message-mode . (lambda ()
2272 ;; (setq fill-column 65
2273 ;; message-fill-column 65)
2274 (make-local-variable 'company-idle-delay)
2275 (setq company-idle-delay 0.2))))
2277 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2278 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2279 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2281 (message-elide-ellipsis "[...]\n"))
2286 (use-feature mml-sec
2288 (mml-secure-openpgp-encrypt-to-self t)
2289 (mml-secure-openpgp-sign-with-sender t))
2291 (use-feature footnote
2294 ;; (setq footnote-start-tag ""
2295 ;; footnote-end-tag ""
2296 ;; footnote-style 'unicode)
2298 (:map message-mode-map
2299 :prefix-map b/footnote-prefix-map
2301 ("a" . footnote-add-footnote)
2302 ("b" . footnote-back-to-message)
2303 ("c" . footnote-cycle-style)
2304 ("d" . footnote-delete-footnote)
2305 ("g" . footnote-goto-footnote)
2306 ("r" . footnote-renumber-footnotes)
2307 ("s" . footnote-set-style)))
2311 :bind (:map gnus-group-mode-map ("e" . ebdb))
2313 (setq ebdb-sources (b/var "ebdb"))
2314 (with-eval-after-load 'swiper
2315 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2317 (use-feature ebdb-com
2320 ;; (use-package ebdb-complete
2323 ;; (ebdb-complete-enable))
2325 (use-package company-ebdb
2327 (defun company-ebdb--post-complete (_) nil))
2329 (use-feature ebdb-gnus
2332 (ebdb-gnus-window-size 0.3))
2334 (use-feature ebdb-mua
2336 ;; :custom (ebdb-mua-pop-up nil)
2339 ;; (use-package ebdb-message
2342 ;; (use-package ebdb-vcard
2345 (use-package message-x)
2348 (use-package message-x
2350 (message-x-completion-alist
2352 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2355 (quote message-newgroups-header-regexp))
2356 message-newgroups-header-regexp message-newsgroups-header-regexp)
2357 . message-expand-group))))))
2360 (use-package gnus-harvest
2361 :commands gnus-harvest-install
2364 (if (featurep 'message-x)
2365 (gnus-harvest-install 'message-x)
2366 (gnus-harvest-install))))
2368 (use-feature gnus-article-treat-patch
2373 ;; note: be sure to customize faces with `:foreground "white"' when
2374 ;; using a theme with a white/light background :)
2375 (setq ft/gnus-article-patch-conditions
2376 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
2379 ;;; IRC (with ERC and ZNC)
2382 :bind (("C-c b e" . erc-switch-to-buffer)
2384 ("M-a" . erc-track-switch-buffer))
2386 (erc-join-buffer 'bury)
2387 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2388 (erc-nick "bandali")
2390 (erc-rename-buffers t)
2391 (erc-server-reconnect-attempts 5)
2392 (erc-server-reconnect-timeout 3)
2394 (defun erc-cmd-OPME ()
2395 "Request chanserv to op me."
2396 (erc-message "PRIVMSG"
2397 (format "chanserv op %s %s"
2398 (erc-default-target)
2399 (erc-current-nick)) nil))
2400 (defun erc-cmd-DEOPME ()
2401 "Deop myself from current channel."
2402 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2403 (add-to-list 'erc-modules 'keep-place)
2404 (add-to-list 'erc-modules 'notifications)
2405 (add-to-list 'erc-modules 'spelling)
2406 (add-to-list 'erc-modules 'scrolltoplace)
2407 (erc-update-modules)
2409 (when (and (version<= "24.4" emacs-version)
2410 (version< emacs-version "27"))
2411 ;; fix erc-lurker bug
2412 ;; patch submitted: https://bugs.gnu.org/36843#10
2413 ;; TODO: remove when patch is merged and emacs 27 is released
2414 (defvar erc-message-parsed)
2415 (defun erc-display-message (parsed type buffer msg &rest args)
2416 "Display MSG in BUFFER.
2418 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2420 See also `erc-format-message' and `erc-display-line'."
2421 (let ((string (if (symbolp msg)
2422 (apply #'erc-format-message msg args)
2424 (erc-message-parsed parsed))
2430 (mapc (lambda (type)
2432 (erc-display-message-highlight type string)))
2436 (erc-display-message-highlight type string))))
2438 (if (not (erc-response-p parsed))
2439 (erc-display-line string buffer)
2440 (unless (erc-hide-current-message-p parsed)
2441 (erc-put-text-property 0 (length string) 'erc-parsed parsed string)
2442 (erc-put-text-property 0 (length string) 'rear-sticky t string)
2443 (when (erc-response.tags parsed)
2444 (erc-put-text-property 0 (length string) 'tags (erc-response.tags parsed)
2446 (erc-display-line string buffer)))))
2448 (defun erc-lurker-update-status (_message)
2449 "Update `erc-lurker-state' if necessary.
2451 This function is called from `erc-insert-pre-hook'. If the
2452 current message is a PRIVMSG, update `erc-lurker-state' to
2453 reflect the fact that its sender has issued a PRIVMSG at the
2454 current time. Otherwise, take no action.
2456 This function depends on the fact that `erc-display-message'
2457 lexically binds `erc-message-parsed', which is used to check if
2458 the current message is a PRIVMSG and to determine its sender.
2459 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2461 In order to limit memory consumption, this function also calls
2462 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2463 updates of `erc-lurker-state'."
2464 (when (and (boundp 'erc-message-parsed)
2465 (erc-response-p erc-message-parsed))
2466 (let* ((command (erc-response.command erc-message-parsed))
2468 (erc-lurker-maybe-trim
2469 (car (erc-parse-user (erc-response.sender erc-message-parsed)))))
2471 (erc-canonicalize-server-name erc-server-announced-name)))
2472 (when (equal command "PRIVMSG")
2473 (when (>= (cl-incf erc-lurker-cleanup-count)
2474 erc-lurker-cleanup-interval)
2475 (setq erc-lurker-cleanup-count 0)
2476 (erc-lurker-cleanup))
2477 (unless (gethash server erc-lurker-state)
2478 (puthash server (make-hash-table :test 'equal) erc-lurker-state))
2479 (puthash sender (current-time)
2480 (gethash server erc-lurker-state))))))))
2482 (use-feature erc-fill
2485 (erc-fill-column 77)
2486 (erc-fill-function 'erc-fill-static)
2487 (erc-fill-static-center 18))
2489 (use-feature erc-pcomplete
2492 (erc-pcomplete-nick-postfix ","))
2494 (use-feature erc-track
2496 :bind (("C-c a e t d" . erc-track-disable)
2497 ("C-c a e t e" . erc-track-enable))
2499 (erc-track-enable-keybindings nil)
2500 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2501 "324" "329" "332" "333" "353" "477"))
2502 (erc-track-priority-faces-only 'all)
2503 (erc-track-shorten-function nil))
2505 (use-package erc-hl-nicks
2508 (use-package erc-scrolltoplace
2512 :straight (:host nil :repo "https://git.shemshak.org/amin/znc.el")
2513 :bind (("C-c a e e" . znc-erc)
2514 ("C-c a e a" . znc-all))
2516 (let ((pwd (let ((auth (auth-source-search :host "znca")))
2518 ((null auth) (error "Couldn't find znca's authinfo"))
2519 (t (funcall (plist-get (car auth) :secret)))))))
2521 `(("znc.shemshak.org" 1337 t
2522 ((freenode "amin/freenode" ,pwd)))
2523 ("znc.shemshak.org" 1337 t
2524 ((moznet "amin/moznet" ,pwd)))
2525 ("znc.shemshak.org" 1337 t
2526 ((oftc "amin/oftc" ,pwd)))))))
2529 ;;; Post initialization
2531 (message "Loading %s...done (%.3fs)" user-init-file
2532 (float-time (time-subtract (current-time)
2533 b/before-user-init-time)))
2535 ;;; init.el ends here