1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2020 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)))
242 (defun b/move-indentation-or-beginning-of-line
(arg)
243 "Move to the indentation or to the beginning of line."
246 ;; (back-to-indentation)
247 ;; (move-beginning-of-line arg))
249 (progn (back-to-indentation)
251 (move-beginning-of-line arg
)))
256 ;;;; C-level customizations
260 enable-recursive-minibuffers t
261 resize-mini-windows t
262 ;; more useful frame titles
263 frame-title-format
'("" invocation-name
" - "
265 (if (buffer-file-name)
266 (abbreviate-file-name (buffer-file-name))
268 ;; i don't feel like jumping out of my chair every now and again; so
269 ;; don't BEEP! at me, emacs
270 ring-bell-function
'ignore
273 ;; scroll-conservatively 10000
275 scroll-conservatively
10
276 scroll-preserve-screen-position
1
277 ;; focus follows mouse
278 mouse-autoselect-window t
)
281 ;; always use space for indentation
289 (dolist (ft (fontset-list))
293 (font-spec :name
"Source Code Pro" :size
14))
297 (font-spec :name
"DejaVu Sans Mono")
304 ;; :name "Symbola monospacified for DejaVu Sans Mono")
310 ;; (font-spec :name "DejaVu Sans Mono")
316 (font-spec :name
"DejaVu Sans Mono" :size
14)
320 ;;;; Elisp-level customizations
326 ;; don't need to see the startup echo area message
327 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
329 ;; i want *scratch* as my startup buffer
330 (initial-buffer-choice t
)
331 ;; i don't need the default hint
332 (initial-scratch-message nil
)
333 ;; use customizable text-mode as major mode for *scratch*
334 ;; (initial-major-mode 'text-mode)
335 ;; inhibit buffer list when more than 2 files are loaded
336 (inhibit-startup-buffer-menu t
)
337 ;; don't need to see the startup screen or echo area message
338 (inhibit-startup-screen t
)
339 (inhibit-startup-echo-area-message user-login-name
))
345 ;; backups (C-h v make-backup-files RET)
346 (backup-by-copying t
)
348 (delete-old-versions t
)
351 (auto-save-file-name-transforms
352 `((".*" ,(b/var
"auto-save/") t
)))
354 ;; insert newline at the end of files
355 (require-final-newline t
)
357 ;; open read-only file buffers in view-mode
358 ;; (enables niceties like `q' for quit)
361 ;; disable disabled commands
362 (setq disabled-command-function nil
)
364 ;; lazy-person-friendly yes/no prompts
365 (defalias 'yes-or-no-p
#'y-or-n-p
)
367 ;; enable automatic reloading of changed buffers and files
368 (use-package autorevert
371 (global-auto-revert-mode 1)
373 (auto-revert-verbose nil
)
374 (global-auto-revert-non-file-buffers nil
))
376 ;; time and battery in mode-line
382 (display-time-default-load-average nil
)
383 (display-time-format " %a %b %-e %-l:%M%P")
384 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
385 (display-time-use-mail-icon t
))
390 (display-battery-mode)
392 (battery-mode-line-format "%p%% %t"))
398 ;; (fringe-mode '(3 . 1))
404 ;; enable winner-mode (C-h f winner-mode RET)
409 ;; don't display *compilation* buffer on success. based on
410 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
411 ;; instead of the now obsolete `flet'.
412 (defun b/compilation-finish-function
(buffer outstr
)
413 (unless (string-match "finished" outstr
)
414 (switch-to-buffer-other-window buffer
))
417 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
421 (defadvice compilation-start
422 (around inhibit-display
423 (command &optional mode name-function highlight-regexp
))
424 (if (not (string-match "^\\(find\\|grep\\)" command
))
425 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
426 (save-window-excursion ad-do-it
))
428 (ad-activate 'compilation-start
))
432 ;; allow scrolling in Isearch
433 (isearch-allow-scroll t
)
434 ;; search for non-ASCII characters: i’d like non-ASCII characters such
435 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
436 ;; counterpart. shoutout to
437 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
438 (search-default-mode #'char-fold-to-regexp
))
440 ;; uncomment to extend the above behaviour to query-replace
444 (replace-char-fold t
)))
447 :bind
("C-x v C-=" . vc-ediff
))
452 (vc-git-print-log-follow t
))
455 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
456 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
457 (ediff-split-window-function 'split-window-horizontally
)))
459 (use-package face-remap
461 ;; gentler font resizing
462 (text-scale-mode-step 1.05))
467 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
468 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
469 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
471 (use-package pixel-scroll
473 :config
(pixel-scroll-mode 1))
475 (use-package epg-config
477 ;; ask for GPG passphrase in minibuffer
478 ;; this will fail if gpg>=2.1 is not available
479 (setq epg-pinentry-mode
'loopback
)
481 (epg-gpg-program (executable-find "gpg")))
486 (use-package pinentry
489 :after
(epa epg server
)
491 ;; workaround for systemd-based distros:
492 ;; (setq pinentry--socket-dir server-socket-dir)
495 (use-package auth-source
497 (auth-sources '("~/.authinfo.gpg"))
498 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
504 ("C-a" . b
/move-indentation-or-beginning-of-line
)
507 ("C-c e b" . eval-buffer
)
508 ("C-c e e" . eval-last-sexp
)
509 ("C-c e p" . pp-macroexpand-last-sexp
)
510 ("C-c e r" . eval-region
)
512 ("C-c e i" . emacs-init-time
)
513 ("C-c e u" . emacs-uptime
)
514 ("C-c e v" . emacs-version
)
516 ("C-c f ." . find-file
)
517 ("C-c f d" . find-name-dired
)
518 ("C-c f l" . find-library
)
520 ("C-c F m" . make-frame-command
)
521 ("C-c F d" . delete-frame
)
523 ("C-S-h C" . describe-char
)
524 ("C-S-h F" . describe-face
)
526 ("C-c x" . execute-extended-command
)
528 ("C-x k" . b
/kill-current-buffer
)
529 ("C-x K" . kill-buffer
)
530 ("C-x s" . save-buffer
)
531 ("C-x S" . save-some-buffers
)
533 :map emacs-lisp-mode-map
534 ("<C-return>" . b
/add-elisp-section
))
536 (when (display-graphic-p)
537 (unbind-key "C-z" global-map
))
540 ;; for back and forward mouse keys
541 ("<XF86Back>" . previous-buffer
)
542 ("<mouse-8>" . previous-buffer
)
543 ;; ("<drag-mouse-8>" . previous-buffer)
544 ("<XF86Forward>" . next-buffer
)
545 ("<mouse-9>" . next-buffer
)
546 ;; ("<drag-mouse-9>" . next-buffer)
547 ;; ("<drag-mouse-2>" . kill-this-buffer)
548 ;; ("<drag-mouse-3>" . switch-to-buffer)
552 ;;; Essential packages
557 (convert-standard-filename "lisp") user-emacs-directory
))
560 (require 'bandali-exwm
))
562 (require 'bandali-org
)
564 ;; *the* right way to do git
566 :bind
(("C-x g" . magit-status
)
567 ("C-c g g" . magit-status
)
568 ("C-c g b" . magit-blame-addition
)
569 ("C-c g l" . magit-log-buffer-file
))
571 (declare-function magit-add-section-hook
"magit-section"
572 (hook function
&optional at append local
))
573 (magit-add-section-hook 'magit-status-sections-hook
574 'magit-insert-modules
575 'magit-insert-stashes
577 ;; (magit-add-section-hook 'magit-status-sections-hook
578 ;; 'magit-insert-ignored-files
579 ;; 'magit-insert-untracked-files
581 (setq magit-repository-directories
'(("~/.emacs.d/" .
0)
583 (nconc magit-section-initial-visibility-alist
584 '(([unpulled status
] . show
)
585 ([unpushed status
] . show
)))
586 (declare-function magit-display-buffer-fullframe-status-v1
"magit-mode" (buffer))
588 (magit-diff-refine-hunk t
)
589 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
590 ;; (magit-completing-read-function 'magit-ido-completing-read)
591 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
593 ;; recently opened files
597 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
601 (recentf-max-saved-items 2000))
603 ;; needed for history for counsel
609 ;; (require 'bandali-ido)
610 (require 'bandali-ivy
)
612 (require 'bandali-eshell
)
614 (require 'bandali-ibuffer
)
618 :hook
(prog-mode . outline-minor-mode
)
621 outline-minor-mode-map
622 ("<s-tab>" . outline-toggle-children
)
623 ("M-p" . outline-previous-visible-heading
)
624 ("M-n" . outline-next-visible-heading
)
625 :prefix-map b
/outline-prefix-map
627 ("TAB" . outline-toggle-children
)
628 ("a" . outline-hide-body
)
629 ("H" . outline-hide-body
)
630 ("S" . outline-show-all
)
631 ("h" . outline-hide-subtree
)
632 ("s" . outline-show-subtree
)))
635 :custom
(ls-lisp-dirs-first t
))
637 (require 'bandali-dired
)
641 (temp-buffer-resize-mode)
642 (setq help-window-select t
))
646 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
647 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
648 (add-to-list 'tramp-default-proxies-alist
649 (list (regexp-quote (system-name)) nil nil
)))
651 (use-package doc-view
652 :bind
(:map doc-view-mode-map
653 ("M-RET" . image-previous-line
)))
655 ;; Email (with Gnus, message, and EBDB)
656 (require 'bandali-gnus
)
657 (use-package sendmail
659 (setq sendmail-program
(executable-find "msmtp")
660 ;; message-sendmail-extra-arguments '("-v" "-d")
661 mail-specify-envelope-from t
662 mail-envelope-from
'header
))
663 (require 'bandali-message
)
664 (require 'bandali-ebdb
)
666 ;; IRC (with ERC and ZNC)
667 (require 'bandali-erc
)
671 (setq scpaste-http-destination
"https://p.bndl.org"
672 scpaste-scp-destination
"p:~"))
677 ;; highlight uncommitted changes in the left fringe
681 (setq diff-hl-draw-borders nil
)
682 (global-diff-hl-mode)
684 ((magit-pre-refresh . diff-hl-magit-pre-refresh
)
685 (magit-post-refresh . diff-hl-magit-post-refresh
)))
687 ;; display Lisp objects at point in the echo area
689 :when
(version< "25" emacs-version
)
690 :config
(global-eldoc-mode))
692 ;; highlight matching parens
695 :config
(show-paren-mode))
697 (use-package elec-pair
699 :config
(electric-pair-mode))
702 :config
(column-number-mode)
704 ;; Save what I copy into clipboard from other applications into Emacs'
705 ;; kill-ring, which would allow me to still be able to easily access
706 ;; it in case I kill (cut or copy) something else inside Emacs before
707 ;; yanking (pasting) what I'd originally intended to.
708 (save-interprogram-paste-before-kill t
))
710 ;; save minibuffer history
711 (use-package savehist
715 (add-to-list 'savehist-additional-variables
'kill-ring
))
717 ;; automatically save place in files
718 (use-package saveplace
719 :when
(version< "25" emacs-version
)
720 :config
(save-place-mode))
722 (use-package prog-mode
723 :config
(global-prettify-symbols-mode)
724 (defun indicate-buffer-boundaries-left ()
725 (setq indicate-buffer-boundaries
'left
))
726 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
728 (use-package text-mode
729 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
730 :hook
((text-mode . indicate-buffer-boundaries-left
)
731 (text-mode . flyspell-mode
)))
733 (use-package conf-mode
736 (use-package sh-script
737 :mode
("\\.bashrc$" . sh-mode
))
742 (:map company-active-map
743 ([tab] . company-complete-common-or-cycle)
744 ([escape] . company-abort)
745 ("C-p" . company-select-previous-or-abort)
746 ("C-n" . company-select-next-or-abort))
748 (company-minimum-prefix-length 1)
749 (company-selection-wrap-around t)
750 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
751 (company-dabbrev-downcase nil)
752 (company-dabbrev-ignore-case nil)
754 ;; (global-company-mode t)
757 (use-package flycheck
760 :hook (prog-mode . flycheck-mode)
762 (:map flycheck-mode-map
763 ("M-P" . flycheck-previous-error)
764 ("M-N" . flycheck-next-error))
766 ;; Use the load-path from running Emacs when checking elisp files
767 (setq flycheck-emacs-lisp-load-path 'inherit)
769 ;; Only flycheck when I actually save the buffer
770 (setq flycheck-check-syntax-automatically '(mode-enabled save))
771 :custom (flycheck-mode-line-prefix "flyc"))
773 ;; (use-package flyspell)
775 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
780 ;; ’ can be part of a word
781 (setq ispell-local-dictionary-alist
782 `((nil "[[:alpha:]]" "[^[:alpha:]]"
783 "['\x2019]" nil ("-B") nil utf-8))
784 ispell-program-name (executable-find "hunspell"))
785 ;; don't send ’ to the subprocess
786 (defun endless/replace-apostrophe (args)
787 (cons (replace-regexp-in-string
790 (advice-add #'ispell-send-string :filter-args
791 #'endless/replace-apostrophe)
793 ;; convert ' back to ’ from the subprocess
794 (defun endless/replace-quote (args)
795 (if (not (derived-mode-p 'org-mode))
797 (cons (replace-regexp-in-string
800 (advice-add #'ispell-parse-output :filter-args
801 #'endless/replace-quote))
804 :hook (text-mode . abbrev-mode))
807 ;;; Programming modes
809 (use-package lisp-mode
811 (defun indent-spaces-mode ()
812 (setq indent-tabs-mode nil))
813 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
816 :hook (emacs-lisp-mode . reveal-mode))
818 ;; (use-package elisp-mode)
820 (use-package alloy-mode
821 :mode "\\.\\(als\\|dsh\\)\\'"
823 (setq alloy-basic-offset 2)
824 ;; (defun b/alloy-simple-indent (start end)
826 ;; ;; (if (region-active-p)
827 ;; ;; (indent-rigidly start end alloy-basic-offset)
829 ;; ;; (indent-rigidly (line-beginning-position)
830 ;; ;; (line-end-position)
831 ;; ;; alloy-basic-offset)))
832 ;; (indent-to (+ (current-column) alloy-basic-offset)))
833 :bind (:map alloy-mode-map
834 ("RET" . electric-newline-and-maybe-indent)
835 ;; ("TAB" . b/alloy-simple-indent)
836 ("TAB" . indent-for-tab-command))
837 :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
840 (eval-when-compile (defvar lean-mode-map))
841 (use-package lean-mode
843 :bind (:map lean-mode-map
844 ("S-SPC" . company-complete))
846 (require 'lean-input)
847 (setq default-input-method "Lean"
848 lean-input-tweak-all '(lean-input-compose
849 (lean-input-prepend "/")
850 (lean-input-nonempty))
851 lean-input-user-translations '(("/" "/")))
854 ;; (use-package mhtml-mode)
856 (use-package sgml-mode
858 (setq sgml-basic-offset 0))
860 (use-package css-mode
862 (setq css-indent-offset 2))
864 (use-package emmet-mode
865 :after (:any mhtml-mode css-mode sgml-mode)
866 :bind* (("C-)" . emmet-next-edit-point)
867 ("C-(" . emmet-prev-edit-point))
869 (unbind-key "C-j" emmet-mode-keymap)
870 (setq emmet-move-cursor-between-quotes t)
871 :hook (css-mode html-mode sgml-mode))
875 (use-package geiser-guile
877 (setq geiser-guile-load-path "~/src/git/guix"))
884 (font-latex-fontify-sectioning 'color)))
891 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
893 (use-package tex-mode
896 (lambda (p) (string-match "^---?" (car p)))
897 tex--prettify-symbols-alist)
898 :hook ((tex-mode . auto-fill-mode)
899 (tex-mode . flyspell-mode)))
901 ;; (use-package george-mode
902 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
903 ;; :mode "\\.grg\\'")
908 (add-to-list 'custom-theme-load-path
910 (convert-standard-filename "lisp") user-emacs-directory))
911 (load-theme 'tangomod t)
913 (use-package smart-mode-line
914 :commands (sml/apply-theme)
917 ;; thanks, but no thnaks; don't make fixed-width fills.
918 (defun sml/fill-for-buffer-identification () "")
919 (setq sml/theme 'tangomod)
921 (smart-mode-line-enable))
923 (use-package doom-modeline
926 :hook (after-init . doom-modeline-init)
928 (doom-modeline-buffer-file-name-style 'relative-to-project))
930 (use-package doom-themes)
936 (setq x-underline-at-descent-line t)
937 (let ((line (face-attribute 'mode-line :underline)))
938 (set-face-attribute 'mode-line nil :overline line)
939 (set-face-attribute 'mode-line-inactive nil :overline line)
940 (set-face-attribute 'mode-line-inactive nil :underline line)
941 (set-face-attribute 'mode-line nil :box nil)
942 (set-face-attribute 'mode-line-inactive nil :box nil)
943 (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf
944 (moody-replace-mode-line-buffer-identification)
945 (moody-replace-vc-mode))
947 (use-package mini-modeline
950 :config (mini-modeline-mode))
952 (defvar b/org-mode-font-lock-keywords
953 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
954 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
955 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
956 (4 '(:foreground "#c5c8c6") t))) ; title
957 "For use with the `doom-tomorrow-night' theme.")
959 (defun b/lights-on ()
960 "Enable my favourite light theme."
962 (mapc #'disable-theme custom-enabled-themes)
963 (load-theme 'tangomod t)
964 (when (featurep 'smart-mode-line)
965 (sml/apply-theme 'tangomod))
966 (font-lock-remove-keywords
967 'org-mode b/org-mode-font-lock-keywords)
968 (when (featurep 'erc-hl-nicks)
969 (erc-hl-nicks-reset-face-table))
970 (when (featurep 'exwm-systemtray)
971 (exwm-systemtray--refresh)))
973 (defun b/lights-off ()
976 (mapc #'disable-theme custom-enabled-themes)
977 (load-theme 'doom-one t)
978 (when (featurep 'smart-mode-line)
979 (sml/apply-theme 'automatic))
980 (font-lock-add-keywords
981 'org-mode b/org-mode-font-lock-keywords t)
982 (when (featurep 'erc-hl-nicks)
983 (erc-hl-nicks-reset-face-table))
984 (when (featurep 'exwm-systemtray)
985 (exwm-systemtray--refresh)))
988 ("C-c t d" . b/lights-off)
989 ("C-c t l" . b/lights-on))
992 ;;; Emacs enhancements & auxiliary packages
995 :config (setq Man-width 80))
997 (use-package which-key
1000 (which-key-add-key-based-replacements
1001 ;; prefixes for global prefixes and minor modes
1004 "C-x RET" "coding system"
1006 "C-x @" "event modifiers"
1007 "C-x a" "abbrev/expand"
1008 "C-x r" "rectangle/register/bookmark"
1010 "C-x v" "version control"
1014 ;; prefixes for my personal bindings
1016 "C-c a" "applications"
1021 "C-c c" "compile-and-comments"
1027 "C-c m" "multiple-cursors"
1028 "C-c p" "projectile"
1029 "C-c p s" "projectile/search"
1030 "C-c p x" "projectile/execute"
1031 "C-c p 4" "projectile/other-window"
1037 ;; prefixes for major modes
1038 (which-key-add-major-mode-key-based-replacements 'message-mode
1039 "C-c f n" "footnote")
1040 (which-key-add-major-mode-key-based-replacements 'org-mode
1041 "C-c C-v" "org-babel")
1045 (which-key-add-column-padding 5)
1046 (which-key-max-description-length 32))
1048 (use-package crux ; results in Waiting for git... [2 times]
1050 :bind (("C-c d" . crux-duplicate-current-line-or-region)
1051 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
1052 ("C-c f C" . crux-copy-file-preserve-attributes)
1053 ("C-c f D" . crux-delete-file-and-buffer)
1054 ("C-c f R" . crux-rename-file-and-buffer)
1055 ("C-c j" . crux-top-join-line)
1056 ("C-S-j" . crux-top-join-line)))
1059 :bind (("C-a" . mwim-beginning-of-code-or-line)
1060 ("C-e" . mwim-end-of-code-or-line)
1061 ("<home>" . mwim-beginning-of-line-or-code)
1062 ("<end>" . mwim-end-of-line-or-code)))
1064 (use-package projectile
1067 :bind-keymap ("C-c p" . projectile-command-map)
1071 (defun b/projectile-mode-line-fun ()
1072 "Report project name and type in the modeline."
1073 (let ((project-name (projectile-project-name))
1074 (project-type (projectile-project-type)))
1076 projectile-mode-line-prefix
1078 (format ":%s" project-type)
1080 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
1082 (defun my-projectile-invalidate-cache (&rest _args)
1083 ;; ignore the args to `magit-checkout'
1084 (projectile-invalidate-cache nil))
1086 (eval-after-load 'magit-branch
1088 (advice-add 'magit-checkout
1089 :after #'my-projectile-invalidate-cache)
1090 (advice-add 'magit-branch-and-checkout
1091 :after #'my-projectile-invalidate-cache)))
1093 (projectile-completion-system 'ivy)
1094 (projectile-mode-line-prefix " proj"))
1096 (use-package helpful
1099 (("C-S-h c" . helpful-command)
1100 ("C-S-h f" . helpful-callable) ; helpful-function
1101 ("C-S-h v" . helpful-variable)
1102 ("C-S-h k" . helpful-key)
1103 ("C-S-h p" . helpful-at-point)))
1105 (use-package unkillable-scratch
1108 (unkillable-scratch 1)
1110 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1113 ;; | make pretty boxed quotes like this
1115 (use-package boxquote
1118 (:prefix-map b/boxquote-prefix-map
1120 ("b" . boxquote-buffer)
1121 ("B" . boxquote-insert-buffer)
1122 ("d" . boxquote-defun)
1123 ("F" . boxquote-insert-file)
1124 ("hf" . boxquote-describe-function)
1125 ("hk" . boxquote-describe-key)
1126 ("hv" . boxquote-describe-variable)
1127 ("hw" . boxquote-where-is)
1128 ("k" . boxquote-kill)
1129 ("p" . boxquote-paragraph)
1130 ("q" . boxquote-boxquote)
1131 ("r" . boxquote-region)
1132 ("s" . boxquote-shell-command)
1133 ("t" . boxquote-text)
1134 ("T" . boxquote-title)
1135 ("u" . boxquote-unbox)
1136 ("U" . boxquote-unbox-region)
1137 ("y" . boxquote-yank)
1138 ("M-q" . boxquote-fill-paragraph)
1139 ("M-w" . boxquote-kill-ring-save)))
1141 (use-package orgalist
1142 ;; breaks auto-fill-mode, showing this error:
1143 ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’
1146 :hook (message-mode . orgalist-mode))
1148 ;; highlight TODOs in buffers
1149 (use-package hl-todo
1152 (global-hl-todo-mode))
1154 (use-package multi-term
1157 :bind (("C-c a s m m" . multi-term)
1158 ("C-c a s m d" . multi-term-dedicated-toggle)
1159 ("C-c a s m p" . multi-term-prev)
1160 ("C-c a s m n" . multi-term-next)
1162 ("C-c C-j" . term-char-mode))
1164 (setq multi-term-program "screen"
1165 multi-term-program-switches (concat "-c"
1166 (getenv "XDG_CONFIG_HOME")
1168 ;; TODO: add separate bindings for connecting to existing
1169 ;; session vs. always creating a new one
1170 multi-term-dedicated-select-after-open-p t
1171 multi-term-dedicated-window-height 20
1172 multi-term-dedicated-max-window-height 30
1174 '(("C-c C-c" . term-interrupt-subjob)
1175 ("C-c C-e" . term-send-esc)
1176 ("C-c C-j" . term-line-mode)
1178 ;; ("C-y" . term-paste)
1179 ("C-y" . term-send-raw)
1180 ("M-f" . term-send-forward-word)
1181 ("M-b" . term-send-backward-word)
1182 ("M-p" . term-send-up)
1183 ("M-n" . term-send-down)
1184 ("M-j" . term-send-raw-meta)
1185 ("M-y" . term-send-raw-meta)
1186 ("M-/" . term-send-raw-meta)
1187 ("M-0" . term-send-raw-meta)
1188 ("M-1" . term-send-raw-meta)
1189 ("M-2" . term-send-raw-meta)
1190 ("M-3" . term-send-raw-meta)
1191 ("M-4" . term-send-raw-meta)
1192 ("M-5" . term-send-raw-meta)
1193 ("M-6" . term-send-raw-meta)
1194 ("M-7" . term-send-raw-meta)
1195 ("M-8" . term-send-raw-meta)
1196 ("M-9" . term-send-raw-meta)
1197 ("<C-backspace>" . term-send-backward-kill-word)
1198 ("<M-DEL>" . term-send-backward-kill-word)
1199 ("M-d" . term-send-delete-word)
1200 ("M-," . term-send-raw)
1201 ("M-." . comint-dynamic-complete))
1202 term-unbind-key-alist
1203 '("C-z" "C-x" "C-c" "C-h"
1207 (use-package page-break-lines
1210 (page-break-lines-max-width fill-column)
1212 (global-page-break-lines-mode))
1214 (use-package expand-region
1215 :bind ("C-=" . er/expand-region))
1217 (use-package multiple-cursors
1219 (("C-S-<mouse-1>" . mc/add-cursor-on-click)
1220 (:prefix-map b/mc-prefix-map
1222 ("c" . mc/edit-lines)
1223 ("n" . mc/mark-next-like-this)
1224 ("p" . mc/mark-previous-like-this)
1225 ("a" . mc/mark-all-like-this))))
1227 (use-package yasnippet
1230 (defconst yas-verbosity-cur yas-verbosity)
1231 (setq yas-verbosity 2)
1232 (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
1234 (setq yas-verbosity yas-verbosity-cur)
1236 (defun b/yas--maybe-expand-key-filter (cmd)
1237 (when (and (yas--maybe-expand-key-filter cmd)
1238 (not (bound-and-true-p git-commit-mode)))
1240 (defconst b/yas-maybe-expand
1241 '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter))
1242 (define-key yas-minor-mode-map
1243 (kbd "SPC") b/yas-maybe-expand)
1247 (use-package debbugs
1249 (("C-c D d" . debbugs-gnu)
1250 ("C-c D b" . debbugs-gnu-bugs)
1253 (interactive) ; bug-gnu-emacs
1254 (setq debbugs-gnu-current-suppress t)
1255 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1256 ("C-c D g" . ; bug-gnuzilla
1259 (setq debbugs-gnu-current-suppress t)
1260 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1261 ("C-c D G b" . ; bug-guix
1264 (setq debbugs-gnu-current-suppress t)
1265 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1266 ("C-c D G p" . ; guix-patches
1269 (setq debbugs-gnu-current-suppress t)
1270 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1272 (use-package org-ref
1274 (b/setq-every '("~/usr/org/references.bib")
1275 reftex-default-bibliography
1276 org-ref-default-bibliography)
1278 org-ref-bibliography-notes "~/usr/org/notes.org"
1279 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1281 ;; (use-package fill-column-indicator)
1285 (("C-c w s l" . (lambda ()
1287 (split-window-right)
1289 ("C-c w s j" . (lambda ()
1291 (split-window-below)
1293 ("C-c w q" . quit-window))
1295 (split-width-threshold 150))
1297 (use-package windmove
1300 (("C-c w h" . windmove-left)
1301 ("C-c w j" . windmove-down)
1302 ("C-c w k" . windmove-up)
1303 ("C-c w l" . windmove-right)
1304 ("C-c w H" . windmove-swap-states-left)
1305 ("C-c w J" . windmove-swap-states-down)
1306 ("C-c w K" . windmove-swap-states-up)
1307 ("C-c w L" . windmove-swap-states-right)))
1311 :bind ("C-c a p" . pass)
1312 :hook (pass-mode . View-exit))
1314 (use-package pdf-tools
1316 :bind (:map pdf-view-mode-map
1317 ("<C-XF86Back>" . pdf-history-backward)
1318 ("<mouse-8>" . pdf-history-backward)
1319 ("<drag-mouse-8>" . pdf-history-backward)
1320 ("<C-XF86Forward>" . pdf-history-forward)
1321 ("<mouse-9>" . pdf-history-forward)
1322 ("<drag-mouse-9>" . pdf-history-forward)
1323 ("M-RET" . image-previous-line)
1324 ("C-s" . isearch-forward)
1325 ("s s" . isearch-forward))
1326 :config (pdf-tools-install nil t)
1327 :custom (pdf-view-resize-factor 1.05))
1329 (use-package org-pdftools
1331 :straight (:host github :repo "fuxialexander/org-pdftools")
1335 (with-eval-after-load 'org
1336 (require 'org-pdftools)))
1338 (use-package biblio)
1341 :hook (latex-mode . reftex-mode))
1343 (use-package reftex-cite
1345 :disabled ; enable to disable
1346 ; reftex-cite's default choice
1349 (defun reftex-get-bibkey-default ()
1350 "If the cursor is in a citation macro, return the word before the macro."
1351 (let* ((macro (reftex-what-macro 1)))
1353 (when (and macro (string-match "cite" (car macro)))
1354 (goto-char (cdr macro)))
1355 (reftex-this-word)))))
1357 (use-package minions
1359 :config (minions-mode))
1363 (dmenu-prompt-string "run: ")
1364 (dmenu-save-file (b/var "dmenu-items")))
1367 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1368 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1370 :straight (:host github :repo "clarete/eosd")
1377 :bind ("C-c a e w" . eww)
1379 (eww-download-directory (file-name-as-directory
1380 (getenv "XDG_DOWNLOAD_DIR"))))
1383 ;;; Post initialization
1386 (message "Loading %s...done (%.3fs)" user-init-file
1387 (float-time (time-subtract (current-time)
1388 b/before-user-init-time)))
1390 ;;; init.el ends here