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 ;; GNU Emacs configuration of Amin Bandali, computer scientist,
21 ;; Free Software activist, and GNU maintainer & webmaster. Packages
22 ;; are installed through using Borg for a fully reproducible setup.
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 (defvar b
/emacs-initialized nil
43 "Whether Emacs has been initialized.")
44 (defvar b
/exwm-p
(string= (system-name) "chaman")
45 "Whether or not we will be using `exwm'.")
47 (when (not (bound-and-true-p b
/emacs-initialized
))
48 (message "Loading Emacs...done (%.3fs)"
49 (float-time (time-subtract b
/before-user-init-time
52 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
53 ;; during startup to reduce garbage collection frequency. clearing
54 ;; `file-name-handler-alist' seems to help reduce startup time too.
55 (defvar b
/gc-cons-threshold gc-cons-threshold
)
56 (defvar b
/gc-cons-percentage gc-cons-percentage
)
57 (defvar b
/file-name-handler-alist file-name-handler-alist
)
58 (setq gc-cons-threshold
(* 30 1024 1024) ; 30 MiB
59 gc-cons-percentage
0.6
60 file-name-handler-alist nil
61 ;; sidesteps a bug when profiling with esup
62 esup-child-profile-require-level
0)
64 ;; set them back to their defaults once we're done initializing
66 "My post-initialize function, run after loading `user-init-file'."
67 (setq b
/emacs-initialized t
68 gc-cons-threshold b
/gc-cons-threshold
69 gc-cons-percentage b
/gc-cons-percentage
70 file-name-handler-alist b
/file-name-handler-alist
)
72 (with-eval-after-load 'exwm-workspace
79 "[%s]" (number-to-string
80 exwm-workspace-current-index
)))))))))
81 (add-hook 'after-init-hook
#'b
/post-init
)
83 ;; increase number of lines kept in *Messages* log
84 (setq message-log-max
20000)
86 ;; optionally, uncomment to supress some byte-compiler warnings
87 ;; (see C-h v byte-compile-warnings RET for more info)
88 ;; (setq byte-compile-warnings
89 ;; '(not free-vars unresolved noruntime lexical make-local))
94 (setq user-full-name
"Amin Bandali"
95 user-mail-address
"bandali@gnu.org")
100 ;; useful for commenting out multiple sexps at a time
101 (defmacro comment
(&rest _
)
102 "Comment out one or more s-expressions."
103 (declare (indent defun
))
107 ;;; Package management
110 (add-to-list 'load-path
111 (expand-file-name "lib/borg" user-emacs-directory
))
114 (setq borg-rewrite-urls-alist
115 '(("git@github.com:" .
"https://github.com/")
116 ("git@gitlab.com:" .
"https://gitlab.com/"))))
119 (if nil
; set to t when need to debug init
121 (setq use-package-verbose t
122 use-package-expand-minimally nil
123 use-package-compute-statistics t
125 (require 'use-package
))
126 (setq use-package-verbose nil
127 use-package-expand-minimally t
))
129 (setq use-package-always-defer t
)
135 ;; keep ~/.emacs.d clean
136 (use-package no-littering
139 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
140 (defalias 'b
/var
'no-littering-expand-var-file-name
))
142 (use-package auto-compile
145 (auto-compile-on-load-mode)
146 (auto-compile-on-save-mode)
147 (setq auto-compile-display-buffer nil
)
148 (setq auto-compile-mode-line-counter t
)
149 (setq auto-compile-source-recreate-deletes-dest t
)
150 (setq auto-compile-toggle-deletes-nonlib-dest t
)
151 (setq auto-compile-update-autoloads t
))
153 ;; separate custom file (don't want it mixing with init.el)
157 (setq custom-file
(b/etc
"custom.el"))
158 (when (file-exists-p custom-file
)
160 ;; while at it, treat themes as safe
161 (setf custom-safe-themes t
)
162 ;; only one custom theme at a time
164 (defadvice load-theme
(before clear-previous-themes activate
)
165 "Clear existing theme settings instead of layering them"
166 (mapc #'disable-theme custom-enabled-themes
))))
168 ;; load the secrets file if it exists, otherwise show a warning
171 (load (b/etc
"secrets"))))
173 ;; start up emacs server. see
174 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
178 (declare-function server-edit
"server")
179 (bind-key "C-c F D" 'server-edit
)
180 (declare-function server-running-p
"server")
181 (or (server-running-p) (server-mode)))
186 (defmacro b
/setq-every
(value &rest vars
)
187 "Set all the variables from VARS to value VALUE."
188 (declare (indent defun
) (debug t
))
189 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
191 (defun b/start-process
(program &rest args
)
192 "Same as `start-process', but doesn't bother about name and buffer."
193 (let ((process-name (concat program
"_process"))
194 (buffer-name (generate-new-buffer-name
195 (concat program
"_output"))))
196 (apply #'start-process
197 process-name buffer-name program args
)))
199 (defun b/dired-start-process
(program &optional args
)
200 "Open current file with a PROGRAM."
201 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
202 ;; be nil, so remove it).
203 (declare-function dired-get-file-for-visit
"dired")
204 (apply #'b
/start-process
206 (remove nil
(list args
(dired-get-file-for-visit)))))
208 (defun b/add-elisp-section
()
212 (insert "\n\f\n;;; "))
214 ;; (defvar b/fill-column 47
215 ;; "My custom `fill-column'.")
217 (defconst b
/asterism
"* * *")
219 (defun b/insert-asterism
()
220 "Insert a centred asterism."
225 (make-string (floor (/ (- fill-column
(length b
/asterism
)) 2))
230 (defun b/no-mouse-autoselect-window
()
231 "Conveniently disable `focus-follows-mouse'.
232 For disabling the behaviour for certain buffers and/or modes."
233 (make-local-variable 'mouse-autoselect-window
)
234 (setq mouse-autoselect-window nil
))
236 (defun b/kill-current-buffer
()
237 "Kill the current buffer."
238 ;; also see https://redd.it/64xb3q
240 (kill-buffer (current-buffer)))
245 ;;;; C-level customizations
249 enable-recursive-minibuffers t
250 resize-mini-windows t
251 ;; more useful frame titles
252 frame-title-format
'("" invocation-name
" - "
254 (if (buffer-file-name)
255 (abbreviate-file-name (buffer-file-name))
257 ;; i don't feel like jumping out of my chair every now and again; so
258 ;; don't BEEP! at me, emacs
259 ring-bell-function
'ignore
262 ;; scroll-conservatively 10000
264 scroll-conservatively
10
265 scroll-preserve-screen-position
1
266 ;; focus follows mouse
267 mouse-autoselect-window t
)
270 ;; always use space for indentation
278 (dolist (ft (fontset-list))
282 (font-spec :name
"Source Code Pro" :size
14))
286 (font-spec :name
"DejaVu Sans Mono")
293 ;; :name "Symbola monospacified for DejaVu Sans Mono")
299 ;; (font-spec :name "DejaVu Sans Mono")
305 (font-spec :name
"DejaVu Sans Mono" :size
14)
309 ;;;; Elisp-level customizations
315 ;; don't need to see the startup echo area message
316 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
318 ;; i want *scratch* as my startup buffer
319 (initial-buffer-choice t
)
320 ;; i don't need the default hint
321 (initial-scratch-message nil
)
322 ;; use customizable text-mode as major mode for *scratch*
323 ;; (initial-major-mode 'text-mode)
324 ;; inhibit buffer list when more than 2 files are loaded
325 (inhibit-startup-buffer-menu t
)
326 ;; don't need to see the startup screen or echo area message
327 (inhibit-startup-screen t
)
328 (inhibit-startup-echo-area-message user-login-name
))
334 ;; backups (C-h v make-backup-files RET)
335 (backup-by-copying t
)
337 (delete-old-versions t
)
340 (auto-save-file-name-transforms
341 `((".*" ,(b/var
"auto-save/") t
)))
343 ;; insert newline at the end of files
344 (require-final-newline t
)
346 ;; open read-only file buffers in view-mode
347 ;; (enables niceties like `q' for quit)
350 ;; disable disabled commands
351 (setq disabled-command-function nil
)
353 ;; lazy-person-friendly yes/no prompts
354 (defalias 'yes-or-no-p
#'y-or-n-p
)
356 ;; enable automatic reloading of changed buffers and files
357 (use-package autorevert
360 (global-auto-revert-mode 1)
362 (auto-revert-verbose nil
)
363 (global-auto-revert-non-file-buffers nil
))
365 ;; time and battery in mode-line
371 (display-time-default-load-average nil
)
372 (display-time-format " %a %b %-e %-l:%M%P")
373 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
374 (display-time-use-mail-icon t
))
379 (display-battery-mode)
381 (battery-mode-line-format "%p%% %t"))
387 ;; (fringe-mode '(3 . 1))
393 ;; enable winner-mode (C-h f winner-mode RET)
398 ;; don't display *compilation* buffer on success. based on
399 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
400 ;; instead of the now obsolete `flet'.
401 (defun b/compilation-finish-function
(buffer outstr
)
402 (unless (string-match "finished" outstr
)
403 (switch-to-buffer-other-window buffer
))
406 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
410 (defadvice compilation-start
411 (around inhibit-display
412 (command &optional mode name-function highlight-regexp
))
413 (if (not (string-match "^\\(find\\|grep\\)" command
))
414 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
415 (save-window-excursion ad-do-it
))
417 (ad-activate 'compilation-start
))
421 ;; allow scrolling in Isearch
422 (isearch-allow-scroll t
)
423 ;; search for non-ASCII characters: i’d like non-ASCII characters such
424 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
425 ;; counterpart. shoutout to
426 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
427 (search-default-mode #'char-fold-to-regexp
))
429 ;; uncomment to extend the above behaviour to query-replace
433 (replace-char-fold t
)))
436 :bind
("C-x v C-=" . vc-ediff
))
441 (vc-git-print-log-follow t
))
444 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
445 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
446 (ediff-split-window-function 'split-window-horizontally
)))
448 (use-package face-remap
450 ;; gentler font resizing
451 (text-scale-mode-step 1.05))
456 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
457 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
458 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
460 (use-package pixel-scroll
462 :config
(pixel-scroll-mode 1))
464 (use-package epg-config
466 ;; ask for GPG passphrase in minibuffer
467 ;; this will fail if gpg>=2.1 is not available
468 (setq epg-pinentry-mode
'loopback
)
470 (epg-gpg-program (executable-find "gpg")))
475 (use-package pinentry
478 :after
(epa epg server
)
480 ;; workaround for systemd-based distros:
481 ;; (setq pinentry--socket-dir server-socket-dir)
484 (use-package auth-source
486 (auth-sources '("~/.authinfo.gpg"))
487 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
495 ("C-c e b" . eval-buffer
)
496 ("C-c e e" . eval-last-sexp
)
497 ("C-c e p" . pp-macroexpand-last-sexp
)
498 ("C-c e r" . eval-region
)
500 ("C-c e i" . emacs-init-time
)
501 ("C-c e u" . emacs-uptime
)
502 ("C-c e v" . emacs-version
)
504 ("C-c f ." . find-file
)
505 ("C-c f d" . find-name-dired
)
506 ("C-c f l" . find-library
)
508 ("C-c F m" . make-frame-command
)
509 ("C-c F d" . delete-frame
)
511 ("C-S-h C" . describe-char
)
512 ("C-S-h F" . describe-face
)
514 ("C-c x" . execute-extended-command
)
516 ("C-x k" . b
/kill-current-buffer
)
517 ("C-x K" . kill-buffer
)
518 ("C-x s" . save-buffer
)
519 ("C-x S" . save-some-buffers
)
521 :map emacs-lisp-mode-map
522 ("<C-return>" . b
/add-elisp-section
))
524 (when (display-graphic-p)
525 (unbind-key "C-z" global-map
))
528 ;; for back and forward mouse keys
529 ("<XF86Back>" . previous-buffer
)
530 ("<mouse-8>" . previous-buffer
)
531 ;; ("<drag-mouse-8>" . previous-buffer)
532 ("<XF86Forward>" . next-buffer
)
533 ("<mouse-9>" . next-buffer
)
534 ;; ("<drag-mouse-9>" . next-buffer)
535 ;; ("<drag-mouse-2>" . kill-this-buffer)
536 ;; ("<drag-mouse-3>" . switch-to-buffer)
540 ;;; Essential packages
545 (convert-standard-filename "lisp") user-emacs-directory
))
548 (require 'bandali-exwm
))
550 (require 'bandali-org
)
552 ;; *the* right way to do git
554 :bind
(("C-x g" . magit-status
)
555 ("C-c g g" . magit-status
)
556 ("C-c g b" . magit-blame-addition
)
557 ("C-c g l" . magit-log-buffer-file
))
559 (declare-function magit-add-section-hook
"magit-section"
560 (hook function
&optional at append local
))
561 (magit-add-section-hook 'magit-status-sections-hook
562 'magit-insert-modules
563 'magit-insert-stashes
565 ;; (magit-add-section-hook 'magit-status-sections-hook
566 ;; 'magit-insert-ignored-files
567 ;; 'magit-insert-untracked-files
569 (setq magit-repository-directories
'(("~/.emacs.d/" .
0)
571 (nconc magit-section-initial-visibility-alist
572 '(([unpulled status
] . show
)
573 ([unpushed status
] . show
)))
574 (declare-function magit-display-buffer-fullframe-status-v1
"magit-mode" (buffer))
576 (magit-diff-refine-hunk t
)
577 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
578 ;; (magit-completing-read-function 'magit-ido-completing-read)
579 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
581 ;; recently opened files
585 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
589 (recentf-max-saved-items 2000))
591 ;; needed for history for counsel
597 ;; (require 'bandali-ido)
598 (require 'bandali-ivy
)
600 (require 'bandali-eshell
)
602 (require 'bandali-ibuffer
)
606 :hook
(prog-mode . outline-minor-mode
)
609 outline-minor-mode-map
610 ("<s-tab>" . outline-toggle-children
)
611 ("M-p" . outline-previous-visible-heading
)
612 ("M-n" . outline-next-visible-heading
)
613 :prefix-map b
/outline-prefix-map
615 ("TAB" . outline-toggle-children
)
616 ("a" . outline-hide-body
)
617 ("H" . outline-hide-body
)
618 ("S" . outline-show-all
)
619 ("h" . outline-hide-subtree
)
620 ("s" . outline-show-subtree
)))
623 :custom
(ls-lisp-dirs-first t
))
625 (require 'bandali-dired
)
629 (temp-buffer-resize-mode)
630 (setq help-window-select t
))
634 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
635 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
636 (add-to-list 'tramp-default-proxies-alist
637 (list (regexp-quote (system-name)) nil nil
)))
639 (use-package doc-view
640 :bind
(:map doc-view-mode-map
641 ("M-RET" . image-previous-line
)))
643 ;; Email (with Gnus, message, and EBDB)
644 (require 'bandali-gnus
)
645 (use-package sendmail
647 (setq sendmail-program
(executable-find "msmtp")
648 ;; message-sendmail-extra-arguments '("-v" "-d")
649 mail-specify-envelope-from t
650 mail-envelope-from
'header
))
651 (require 'bandali-message
)
652 (require 'bandali-ebdb
)
654 ;; IRC (with ERC and ZNC)
655 (require 'bandali-erc
)
660 ;; highlight uncommitted changes in the left fringe
664 (setq diff-hl-draw-borders nil
)
665 (global-diff-hl-mode)
667 ((magit-pre-refresh . diff-hl-magit-pre-refresh
)
668 (magit-post-refresh . diff-hl-magit-post-refresh
)))
670 ;; display Lisp objects at point in the echo area
672 :when
(version< "25" emacs-version
)
673 :config
(global-eldoc-mode))
675 ;; highlight matching parens
678 :config
(show-paren-mode))
680 (use-package elec-pair
682 :config
(electric-pair-mode))
685 :config
(column-number-mode)
687 ;; Save what I copy into clipboard from other applications into Emacs'
688 ;; kill-ring, which would allow me to still be able to easily access
689 ;; it in case I kill (cut or copy) something else inside Emacs before
690 ;; yanking (pasting) what I'd originally intended to.
691 (save-interprogram-paste-before-kill t
))
693 ;; save minibuffer history
694 (use-package savehist
698 (add-to-list 'savehist-additional-variables
'kill-ring
))
700 ;; automatically save place in files
701 (use-package saveplace
702 :when
(version< "25" emacs-version
)
703 :config
(save-place-mode))
705 (use-package prog-mode
706 :config
(global-prettify-symbols-mode)
707 (defun indicate-buffer-boundaries-left ()
708 (setq indicate-buffer-boundaries
'left
))
709 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
711 (use-package text-mode
712 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
713 :hook
((text-mode . indicate-buffer-boundaries-left
)
714 (text-mode . flyspell-mode
)))
716 (use-package conf-mode
725 (:map company-active-map
726 ([tab] . company-complete-common-or-cycle)
727 ([escape] . company-abort)
728 ("C-p" . company-select-previous-or-abort)
729 ("C-n" . company-select-next-or-abort))
731 (company-minimum-prefix-length 1)
732 (company-selection-wrap-around t)
733 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
734 (company-dabbrev-downcase nil)
735 (company-dabbrev-ignore-case nil)
737 ;; (global-company-mode t)
741 (use-package flycheck
743 :hook (prog-mode . flycheck-mode)
745 (:map flycheck-mode-map
746 ("M-P" . flycheck-previous-error)
747 ("M-N" . flycheck-next-error))
749 ;; Use the load-path from running Emacs when checking elisp files
750 (setq flycheck-emacs-lisp-load-path 'inherit)
752 ;; Only flycheck when I actually save the buffer
753 (setq flycheck-check-syntax-automatically '(mode-enabled save))
754 :custom (flycheck-mode-line-prefix "flyc"))
756 (use-package flyspell)
758 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
762 ;; ’ can be part of a word
763 (setq ispell-local-dictionary-alist
764 `((nil "[[:alpha:]]" "[^[:alpha:]]"
765 "['\x2019]" nil ("-B") nil utf-8))
766 ispell-program-name (executable-find "hunspell"))
767 ;; don't send ’ to the subprocess
768 (defun endless/replace-apostrophe (args)
769 (cons (replace-regexp-in-string
772 (advice-add #'ispell-send-string :filter-args
773 #'endless/replace-apostrophe)
775 ;; convert ' back to ’ from the subprocess
776 (defun endless/replace-quote (args)
777 (if (not (derived-mode-p 'org-mode))
779 (cons (replace-regexp-in-string
782 (advice-add #'ispell-parse-output :filter-args
783 #'endless/replace-quote))
786 :hook (text-mode . abbrev-mode))
789 ;;; Programming modes
791 (use-package lisp-mode
793 (defun indent-spaces-mode ()
794 (setq indent-tabs-mode nil))
795 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
798 :hook (emacs-lisp-mode . reveal-mode))
800 (use-package elisp-mode)
802 ;; (use-package alloy-mode
803 ;; :straight (:host github :repo "dwwmmn/alloy-mode")
804 ;; :mode "\\.\\(als\\|dsh\\)\\'"
806 ;; (setq alloy-basic-offset 2)
807 ;; ;; (defun b/alloy-simple-indent (start end)
808 ;; ;; (interactive "r")
809 ;; ;; ;; (if (region-active-p)
810 ;; ;; ;; (indent-rigidly start end alloy-basic-offset)
812 ;; ;; ;; (indent-rigidly (line-beginning-position)
813 ;; ;; ;; (line-end-position)
814 ;; ;; ;; alloy-basic-offset)))
815 ;; ;; (indent-to (+ (current-column) alloy-basic-offset)))
816 ;; :bind (:map alloy-mode-map
817 ;; ("RET" . electric-newline-and-maybe-indent)
818 ;; ;; ("TAB" . b/alloy-simple-indent)
819 ;; ("TAB" . indent-for-tab-command))
820 ;; :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
822 (eval-when-compile (defvar lean-mode-map))
823 (use-package lean-mode
825 :bind (:map lean-mode-map
826 ("S-SPC" . company-complete))
828 (require 'lean-input)
829 (setq default-input-method "Lean"
830 lean-input-tweak-all '(lean-input-compose
831 (lean-input-prepend "/")
832 (lean-input-nonempty))
833 lean-input-user-translations '(("/" "/")))
836 (use-package mhtml-mode)
838 (use-package sgml-mode
840 (setq sgml-basic-offset 0))
842 (use-package css-mode
844 (setq css-indent-offset 2))
846 (use-package emmet-mode
847 :after (:any mhtml-mode css-mode sgml-mode)
848 :bind* (("C-)" . emmet-next-edit-point)
849 ("C-(" . emmet-prev-edit-point))
851 (unbind-key "C-j" emmet-mode-keymap)
852 (setq emmet-move-cursor-between-quotes t)
853 :hook (css-mode html-mode sgml-mode))
857 (use-package geiser-guile
859 (setq geiser-guile-load-path "~/src/git/guix"))
866 (font-latex-fontify-sectioning 'color)))
873 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
875 (use-package tex-mode
878 (lambda (p) (string-match "^---?" (car p)))
879 tex--prettify-symbols-alist)
880 :hook ((tex-mode . auto-fill-mode)
881 (tex-mode . flyspell-mode)))
883 ;; (use-package george-mode
884 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
885 ;; :mode "\\.grg\\'")
890 (add-to-list 'custom-theme-load-path
892 (convert-standard-filename "lisp") user-emacs-directory))
893 (load-theme 'tangomod t)
895 (use-package smart-mode-line
896 :commands (sml/apply-theme)
899 ;; thanks, but no thnaks; don't make fixed-width fills.
900 (defun sml/fill-for-buffer-identification () "")
901 (setq sml/theme 'tangomod)
903 (smart-mode-line-enable))
905 (use-package doom-modeline
908 :hook (after-init . doom-modeline-init)
910 (doom-modeline-buffer-file-name-style 'relative-to-project))
912 (use-package doom-themes)
918 (setq x-underline-at-descent-line t)
919 (let ((line (face-attribute 'mode-line :underline)))
920 (set-face-attribute 'mode-line nil :overline line)
921 (set-face-attribute 'mode-line-inactive nil :overline line)
922 (set-face-attribute 'mode-line-inactive nil :underline line)
923 (set-face-attribute 'mode-line nil :box nil)
924 (set-face-attribute 'mode-line-inactive nil :box nil)
925 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
926 (moody-replace-mode-line-buffer-identification)
927 (moody-replace-vc-mode))
929 (use-package mini-modeline
932 :config (mini-modeline-mode))
934 (defvar b/org-mode-font-lock-keywords
935 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
936 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
937 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
938 (4 '(:foreground "#c5c8c6") t))) ; title
939 "For use with the `doom-tomorrow-night' theme.")
941 (defun b/lights-on ()
942 "Enable my favourite light theme."
944 (mapc #'disable-theme custom-enabled-themes)
945 (load-theme 'tangomod t)
946 (when (featurep 'smart-mode-line)
947 (sml/apply-theme 'tangomod))
948 (font-lock-remove-keywords
949 'org-mode b/org-mode-font-lock-keywords)
950 (when (featurep 'erc-hl-nicks)
951 (erc-hl-nicks-reset-face-table))
952 (when (featurep 'exwm-systemtray)
953 (exwm-systemtray--refresh)))
955 (defun b/lights-off ()
958 (mapc #'disable-theme custom-enabled-themes)
959 (load-theme 'doom-one t)
960 (when (featurep 'smart-mode-line)
961 (sml/apply-theme 'automatic))
962 (font-lock-add-keywords
963 'org-mode b/org-mode-font-lock-keywords t)
964 (when (featurep 'erc-hl-nicks)
965 (erc-hl-nicks-reset-face-table))
966 (when (featurep 'exwm-systemtray)
967 (exwm-systemtray--refresh)))
970 ("C-c t d" . b/lights-off)
971 ("C-c t l" . b/lights-on))
974 ;;; Emacs enhancements & auxiliary packages
977 :config (setq Man-width 80))
979 (use-package which-key
982 (which-key-add-key-based-replacements
983 ;; prefixes for global prefixes and minor modes
986 "C-x RET" "coding system"
988 "C-x @" "event modifiers"
989 "C-x a" "abbrev/expand"
990 "C-x r" "rectangle/register/bookmark"
992 "C-x v" "version control"
996 ;; prefixes for my personal bindings
998 "C-c a" "applications"
1003 "C-c c" "compile-and-comments"
1009 "C-c m" "multiple-cursors"
1010 "C-c p" "projectile"
1011 "C-c p s" "projectile/search"
1012 "C-c p x" "projectile/execute"
1013 "C-c p 4" "projectile/other-window"
1019 ;; prefixes for major modes
1020 (which-key-add-major-mode-key-based-replacements 'message-mode
1021 "C-c f n" "footnote")
1022 (which-key-add-major-mode-key-based-replacements 'org-mode
1023 "C-c C-v" "org-babel")
1027 (which-key-add-column-padding 5)
1028 (which-key-max-description-length 32))
1030 (use-package crux ; results in Waiting for git... [2 times]
1032 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1033 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1034 ("C-c f C" . crux-copy-file-preserve-attributes)
1035 ("C-c f D" . crux-delete-file-and-buffer)
1036 ("C-c f R" . crux-rename-file-and-buffer)
1037 ("C-c j" . crux-top-join-line)
1038 ("C-S-j" . crux-top-join-line)))
1041 :bind (("C-a" . mwim-beginning-of-code-or-line)
1042 ("C-e" . mwim-end-of-code-or-line)
1043 ("<home>" . mwim-beginning-of-line-or-code)
1044 ("<end>" . mwim-end-of-line-or-code)))
1046 (use-package projectile
1049 :bind-keymap ("C-c p" . projectile-command-map)
1053 (defun b/projectile-mode-line-fun ()
1054 "Report project name and type in the modeline."
1055 (let ((project-name (projectile-project-name))
1056 (project-type (projectile-project-type)))
1058 projectile-mode-line-prefix
1060 (format ":%s" project-type)
1062 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1064 (defun my-projectile-invalidate-cache (&rest _args)
1065 ;; ignore the args to `magit-checkout'
1066 (projectile-invalidate-cache nil))
1068 (eval-after-load 'magit-branch
1070 (advice-add 'magit-checkout
1071 :after #'my-projectile-invalidate-cache)
1072 (advice-add 'magit-branch-and-checkout
1073 :after #'my-projectile-invalidate-cache)))
1075 (projectile-completion-system 'ivy)
1076 (projectile-mode-line-prefix " proj"))
1078 (use-package helpful
1081 (("C-S-h c" . helpful-command)
1082 ("C-S-h f" . helpful-callable) ; helpful-function
1083 ("C-S-h v" . helpful-variable)
1084 ("C-S-h k" . helpful-key)
1085 ("C-S-h p" . helpful-at-point)))
1087 (use-package unkillable-scratch
1090 (unkillable-scratch 1)
1092 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1095 ;; | make pretty boxed quotes like this
1097 (use-package boxquote
1100 (:prefix-map b/boxquote-prefix-map
1102 ("b" . boxquote-buffer)
1103 ("B" . boxquote-insert-buffer)
1104 ("d" . boxquote-defun)
1105 ("F" . boxquote-insert-file)
1106 ("hf" . boxquote-describe-function)
1107 ("hk" . boxquote-describe-key)
1108 ("hv" . boxquote-describe-variable)
1109 ("hw" . boxquote-where-is)
1110 ("k" . boxquote-kill)
1111 ("p" . boxquote-paragraph)
1112 ("q" . boxquote-boxquote)
1113 ("r" . boxquote-region)
1114 ("s" . boxquote-shell-command)
1115 ("t" . boxquote-text)
1116 ("T" . boxquote-title)
1117 ("u" . boxquote-unbox)
1118 ("U" . boxquote-unbox-region)
1119 ("y" . boxquote-yank)
1120 ("M-q" . boxquote-fill-paragraph)
1121 ("M-w" . boxquote-kill-ring-save)))
1123 (use-package orgalist
1124 ;; breaks auto-fill-mode, showing this error:
1125 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1128 :hook (message-mode . orgalist-mode))
1130 ;; highlight TODOs in buffers
1131 (use-package hl-todo
1134 (global-hl-todo-mode))
1136 (use-package multi-term
1139 :bind (("C-c a s m m" . multi-term)
1140 ("C-c a s m d" . multi-term-dedicated-toggle)
1141 ("C-c a s m p" . multi-term-prev)
1142 ("C-c a s m n" . multi-term-next)
1144 ("C-c C-j" . term-char-mode))
1146 (setq multi-term-program "screen"
1147 multi-term-program-switches (concat "-c"
1148 (getenv "XDG_CONFIG_HOME")
1150 ;; TODO: add separate bindings for connecting to existing
1151 ;; session vs. always creating a new one
1152 multi-term-dedicated-select-after-open-p t
1153 multi-term-dedicated-window-height 20
1154 multi-term-dedicated-max-window-height 30
1156 '(("C-c C-c" . term-interrupt-subjob)
1157 ("C-c C-e" . term-send-esc)
1158 ("C-c C-j" . term-line-mode)
1160 ;; ("C-y" . term-paste)
1161 ("C-y" . term-send-raw)
1162 ("M-f" . term-send-forward-word)
1163 ("M-b" . term-send-backward-word)
1164 ("M-p" . term-send-up)
1165 ("M-n" . term-send-down)
1166 ("M-j" . term-send-raw-meta)
1167 ("M-y" . term-send-raw-meta)
1168 ("M-/" . term-send-raw-meta)
1169 ("M-0" . term-send-raw-meta)
1170 ("M-1" . term-send-raw-meta)
1171 ("M-2" . term-send-raw-meta)
1172 ("M-3" . term-send-raw-meta)
1173 ("M-4" . term-send-raw-meta)
1174 ("M-5" . term-send-raw-meta)
1175 ("M-6" . term-send-raw-meta)
1176 ("M-7" . term-send-raw-meta)
1177 ("M-8" . term-send-raw-meta)
1178 ("M-9" . term-send-raw-meta)
1179 ("<C-backspace>" . term-send-backward-kill-word)
1180 ("<M-DEL>" . term-send-backward-kill-word)
1181 ("M-d" . term-send-delete-word)
1182 ("M-," . term-send-raw)
1183 ("M-." . comint-dynamic-complete))
1184 term-unbind-key-alist
1185 '("C-z" "C-x" "C-c" "C-h"
1189 (use-package page-break-lines
1192 (page-break-lines-max-width fill-column)
1194 (global-page-break-lines-mode))
1196 (use-package expand-region
1197 :bind ("C-=" . er/expand-region))
1199 (use-package multiple-cursors
1201 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1202 (:prefix-map b/mc-prefix-map
1204 ("c" . mc/edit-lines)
1205 ("n" . mc/mark-next-like-this)
1206 ("p" . mc/mark-previous-like-this)
1207 ("a" . mc/mark-all-like-this))))
1209 (use-package yasnippet
1212 (defconst yas-verbosity-cur yas-verbosity)
1213 (setq yas-verbosity 2)
1214 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1216 (setq yas-verbosity yas-verbosity-cur)
1218 (defun b/yas--maybe-expand-key-filter (cmd)
1219 (when (and (yas--maybe-expand-key-filter cmd)
1220 (not (bound-and-true-p git-commit-mode)))
1222 (defconst b/yas-maybe-expand
1223 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1224 (define-key yas-minor-mode-map
1225 (kbd "SPC") b/yas-maybe-expand)
1229 (use-package debbugs
1231 (("C-c D d" . debbugs-gnu)
1232 ("C-c D b" . debbugs-gnu-bugs)
1235 (interactive) ; bug-gnu-emacs
1236 (setq debbugs-gnu-current-suppress t)
1237 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1238 ("C-c D g" . ; bug-gnuzilla
1241 (setq debbugs-gnu-current-suppress t)
1242 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1243 ("C-c D G b" . ; bug-guix
1246 (setq debbugs-gnu-current-suppress t)
1247 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1248 ("C-c D G p" . ; guix-patches
1251 (setq debbugs-gnu-current-suppress t)
1252 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1254 (use-package org-ref
1256 (b/setq-every '("~/usr/org/references.bib")
1257 reftex-default-bibliography
1258 org-ref-default-bibliography)
1260 org-ref-bibliography-notes "~/usr/org/notes.org"
1261 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1263 ;; (use-package fill-column-indicator)
1267 (("C-c w e" . (lambda ()
1269 (split-window-right)
1271 (erc-switch-to-buffer)))
1272 ("C-c w s l" . (lambda ()
1274 (split-window-right)
1276 ("C-c w s j" . (lambda ()
1278 (split-window-below)
1280 ("C-c w q" . quit-window))
1282 (split-width-threshold 150))
1284 (use-package windmove
1287 (("C-c w h" . windmove-left)
1288 ("C-c w j" . windmove-down)
1289 ("C-c w k" . windmove-up)
1290 ("C-c w l" . windmove-right)
1291 ("C-c w H" . windmove-swap-states-left)
1292 ("C-c w J" . windmove-swap-states-down)
1293 ("C-c w K" . windmove-swap-states-up)
1294 ("C-c w L" . windmove-swap-states-right)))
1298 :bind ("C-c a p" . pass)
1299 :hook (pass-mode . View-exit))
1301 (use-package pdf-tools
1303 :bind (:map pdf-view-mode-map
1304 ("<C-XF86Back>" . pdf-history-backward)
1305 ("<mouse-8>" . pdf-history-backward)
1306 ("<drag-mouse-8>" . pdf-history-backward)
1307 ("<C-XF86Forward>" . pdf-history-forward)
1308 ("<mouse-9>" . pdf-history-forward)
1309 ("<drag-mouse-9>" . pdf-history-forward)
1310 ("M-RET" . image-previous-line)
1311 ("C-s" . isearch-forward)
1312 ("s s" . isearch-forward))
1313 :config (pdf-tools-install nil t)
1314 :custom (pdf-view-resize-factor 1.05))
1316 (use-package org-pdftools
1318 :straight (:host github :repo "fuxialexander/org-pdftools")
1322 (with-eval-after-load 'org
1323 (require 'org-pdftools)))
1325 (use-package biblio)
1328 :hook (latex-mode . reftex-mode))
1330 (use-package reftex-cite
1332 :disabled ; enable to disable
1333 ; reftex-cite's default choice
1336 (defun reftex-get-bibkey-default ()
1337 "If the cursor is in a citation macro, return the word before the macro."
1338 (let* ((macro (reftex-what-macro 1)))
1340 (when (and macro (string-match "cite" (car macro)))
1341 (goto-char (cdr macro)))
1342 (reftex-this-word)))))
1344 (use-package minions
1346 :config (minions-mode))
1350 (dmenu-prompt-string "run: ")
1351 (dmenu-save-file (b/var "dmenu-items")))
1354 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1355 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1357 :straight (:host github :repo "clarete/eosd")
1363 (use-package scpaste
1366 (setq scpaste-http-destination "https://p.bndl.org"
1367 scpaste-scp-destination "nix:/var/www/p.bndl.org"))
1370 :bind ("C-c a e w" . eww)
1372 (eww-download-directory (file-name-as-directory
1373 (getenv "XDG_DOWNLOAD_DIR"))))
1376 ;;; Post initialization
1379 (message "Loading %s...done (%.3fs)" user-init-file
1380 (float-time (time-subtract (current-time)
1381 b/before-user-init-time)))
1383 ;;; init.el ends here