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
)))
253 (defun b/join-line-top
()
254 "Like `join-line', but join next line to the current line."
258 (defun b/duplicate-line-or-region
(&optional n
)
259 "Duplicate the current line, or region (if active).
260 Make N (default: 1) copies of the current line or region."
262 (let ((u-r-p (use-region-p)) ; if region is active
267 (buffer-substring (region-beginning) (region-end))
268 (prog1 (thing-at-point 'line
)
272 (forward-line 1))))))
273 (dotimes (_ (abs n1
))
279 ;;;; C-level customizations
283 enable-recursive-minibuffers t
284 resize-mini-windows t
285 ;; more useful frame titles
286 frame-title-format
'("" invocation-name
" - "
288 (if (buffer-file-name)
289 (abbreviate-file-name (buffer-file-name))
291 ;; i don't feel like jumping out of my chair every now and again; so
292 ;; don't BEEP! at me, emacs
293 ring-bell-function
'ignore
296 ;; scroll-conservatively 10000
298 scroll-conservatively
101
299 scroll-preserve-screen-position
1
300 ;; focus follows mouse
301 mouse-autoselect-window t
)
304 ;; always use space for indentation
312 (dolist (ft (fontset-list))
316 (font-spec :name
"Source Code Pro" :size
14))
320 (font-spec :name
"DejaVu Sans Mono")
327 ;; :name "Symbola monospacified for DejaVu Sans Mono")
333 ;; (font-spec :name "DejaVu Sans Mono")
339 (font-spec :name
"DejaVu Sans Mono" :size
14)
343 ;;;; Elisp-level customizations
349 ;; don't need to see the startup echo area message
350 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
352 ;; i want *scratch* as my startup buffer
353 (initial-buffer-choice t
)
354 ;; i don't need the default hint
355 (initial-scratch-message nil
)
356 ;; use customizable text-mode as major mode for *scratch*
357 ;; (initial-major-mode 'text-mode)
358 ;; inhibit buffer list when more than 2 files are loaded
359 (inhibit-startup-buffer-menu t
)
360 ;; don't need to see the startup screen or echo area message
361 (inhibit-startup-screen t
)
362 (inhibit-startup-echo-area-message user-login-name
))
368 ;; backups (C-h v make-backup-files RET)
369 (backup-by-copying t
)
371 (delete-old-versions t
)
374 (auto-save-file-name-transforms
375 `((".*" ,(b/var
"auto-save/") t
)))
377 ;; insert newline at the end of files
378 (require-final-newline t
)
380 ;; open read-only file buffers in view-mode
381 ;; (enables niceties like `q' for quit)
384 ;; disable disabled commands
385 (setq disabled-command-function nil
)
387 ;; lazy-person-friendly yes/no prompts
388 (defalias 'yes-or-no-p
#'y-or-n-p
)
390 ;; enable automatic reloading of changed buffers and files
391 (use-package autorevert
394 (global-auto-revert-mode 1)
396 (auto-revert-verbose nil
)
397 (global-auto-revert-non-file-buffers nil
))
399 ;; time and battery in mode-line
405 (display-time-default-load-average nil
)
406 (display-time-format " %a %b %-e %-l:%M%P")
407 (display-time-mail-icon '(image :type xpm
:file
"gnus/gnus-pointer.xpm" :ascent center
))
408 (display-time-use-mail-icon t
))
413 (display-battery-mode)
415 (battery-mode-line-format "%p%% %t"))
421 ;; (fringe-mode '(3 . 1))
427 ;; enable winner-mode (C-h f winner-mode RET)
432 ;; don't display *compilation* buffer on success. based on
433 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
434 ;; instead of the now obsolete `flet'.
435 (defun b/compilation-finish-function
(buffer outstr
)
436 (unless (string-match "finished" outstr
)
437 (switch-to-buffer-other-window buffer
))
440 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
444 (defadvice compilation-start
445 (around inhibit-display
446 (command &optional mode name-function highlight-regexp
))
447 (if (not (string-match "^\\(find\\|grep\\)" command
))
448 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
449 (save-window-excursion ad-do-it
))
451 (ad-activate 'compilation-start
))
455 ;; allow scrolling in Isearch
456 (isearch-allow-scroll t
)
457 ;; search for non-ASCII characters: i’d like non-ASCII characters such
458 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
459 ;; counterpart. shoutout to
460 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
461 (search-default-mode #'char-fold-to-regexp
))
463 ;; uncomment to extend the above behaviour to query-replace
467 (replace-char-fold t
)))
470 :bind
("C-x v C-=" . vc-ediff
))
475 (vc-git-print-log-follow t
))
478 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
479 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
480 (ediff-split-window-function 'split-window-horizontally
)))
482 (use-package face-remap
484 ;; gentler font resizing
485 (text-scale-mode-step 1.05))
490 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
491 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
492 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
494 (use-package pixel-scroll
496 :config
(pixel-scroll-mode 1))
498 (use-package epg-config
500 ;; ask for GPG passphrase in minibuffer
501 ;; this will fail if gpg>=2.1 is not available
502 (setq epg-pinentry-mode
'loopback
)
504 (epg-gpg-program (executable-find "gpg")))
509 (use-package pinentry
512 :after
(epa epg server
)
514 ;; workaround for systemd-based distros:
515 ;; (setq pinentry--socket-dir server-socket-dir)
518 (use-package auth-source
520 (auth-sources '("~/.authinfo.gpg"))
521 (authinfo-hidden (regexp-opt '("password" "client-secret" "token"))))
527 ("C-a" . b
/move-indentation-or-beginning-of-line
)
529 ("C-c d" . b
/duplicate-line-or-region
)
531 ("C-c e b" . eval-buffer
)
532 ("C-c e e" . eval-last-sexp
)
533 ("C-c e p" . pp-macroexpand-last-sexp
)
534 ("C-c e r" . eval-region
)
536 ("C-c e i" . emacs-init-time
)
537 ("C-c e u" . emacs-uptime
)
538 ("C-c e v" . emacs-version
)
540 ("C-c f ." . find-file
)
541 ("C-c f d" . find-name-dired
)
542 ("C-c f l" . find-library
)
544 ("C-c F m" . make-frame-command
)
545 ("C-c F d" . delete-frame
)
547 ("C-S-h C" . describe-char
)
548 ("C-S-h F" . describe-face
)
550 ("C-S-j" . b
/join-line-top
)
552 ("C-c x" . execute-extended-command
)
554 ("C-x k" . b
/kill-current-buffer
)
555 ("C-x K" . kill-buffer
)
556 ("C-x s" . save-buffer
)
557 ("C-x S" . save-some-buffers
)
559 :map emacs-lisp-mode-map
560 ("<C-return>" . b
/add-elisp-section
))
562 (when (display-graphic-p)
563 (unbind-key "C-z" global-map
))
566 ;; for back and forward mouse keys
567 ("<XF86Back>" . previous-buffer
)
568 ("<mouse-8>" . previous-buffer
)
569 ;; ("<drag-mouse-8>" . previous-buffer)
570 ("<XF86Forward>" . next-buffer
)
571 ("<mouse-9>" . next-buffer
)
572 ;; ("<drag-mouse-9>" . next-buffer)
573 ;; ("<drag-mouse-2>" . kill-this-buffer)
574 ;; ("<drag-mouse-3>" . switch-to-buffer)
578 ;;; Essential packages
583 (convert-standard-filename "lisp") user-emacs-directory
))
586 (require 'bandali-exwm
))
588 (require 'bandali-org
)
590 (require 'bandali-theme
)
592 ;; *the* right way to do git
594 :bind
(("C-x g" . magit-status
)
595 ("C-c g g" . magit-status
)
596 ("C-c g b" . magit-blame-addition
)
597 ("C-c g l" . magit-log-buffer-file
))
599 (declare-function magit-add-section-hook
"magit-section"
600 (hook function
&optional at append local
))
601 (magit-add-section-hook 'magit-status-sections-hook
602 'magit-insert-modules
603 'magit-insert-stashes
605 ;; (magit-add-section-hook 'magit-status-sections-hook
606 ;; 'magit-insert-ignored-files
607 ;; 'magit-insert-untracked-files
609 (setq magit-repository-directories
'(("~/.emacs.d/" .
0)
611 (nconc magit-section-initial-visibility-alist
612 '(([unpulled status
] . show
)
613 ([unpushed status
] . show
)))
614 (declare-function magit-display-buffer-fullframe-status-v1
"magit-mode" (buffer))
616 (magit-diff-refine-hunk t
)
617 (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
618 ;; (magit-completing-read-function 'magit-ido-completing-read)
619 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
621 ;; recently opened files
625 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
629 (recentf-max-saved-items 2000))
631 ;; needed for history for counsel
637 ;; (require 'bandali-ido)
638 (require 'bandali-ivy
)
640 (require 'bandali-eshell
)
641 ;; (require 'bandali-multi-term)
643 (require 'bandali-ibuffer
)
647 :hook
(prog-mode . outline-minor-mode
)
650 outline-minor-mode-map
651 ("<s-tab>" . outline-toggle-children
)
652 ("M-p" . outline-previous-visible-heading
)
653 ("M-n" . outline-next-visible-heading
)
654 :prefix-map b
/outline-prefix-map
656 ("TAB" . outline-toggle-children
)
657 ("a" . outline-hide-body
)
658 ("H" . outline-hide-body
)
659 ("S" . outline-show-all
)
660 ("h" . outline-hide-subtree
)
661 ("s" . outline-show-subtree
))
663 (when (featurep 'which-key
)
664 (which-key-add-key-based-replacements
669 :custom
(ls-lisp-dirs-first t
))
671 (require 'bandali-dired
)
675 (temp-buffer-resize-mode)
676 (setq help-window-select t
))
680 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
681 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
682 (add-to-list 'tramp-default-proxies-alist
683 (list (regexp-quote (system-name)) nil nil
)))
685 (use-package doc-view
686 :bind
(:map doc-view-mode-map
687 ("M-RET" . image-previous-line
)))
689 ;; Email (with Gnus, message, and EBDB)
690 (require 'bandali-gnus
)
691 (use-package sendmail
693 (setq sendmail-program
(executable-find "msmtp")
694 ;; message-sendmail-extra-arguments '("-v" "-d")
695 mail-specify-envelope-from t
696 mail-envelope-from
'header
))
697 (require 'bandali-message
)
698 (require 'bandali-ebdb
)
700 ;; IRC (with ERC and ZNC)
701 (require 'bandali-erc
)
705 (setq scpaste-http-destination
"https://p.bndl.org"
706 scpaste-scp-destination
"p:~"))
711 ;; highlight uncommitted changes in the left fringe
715 (setq diff-hl-draw-borders nil
)
716 (global-diff-hl-mode)
718 ((magit-pre-refresh . diff-hl-magit-pre-refresh
)
719 (magit-post-refresh . diff-hl-magit-post-refresh
)))
721 ;; display Lisp objects at point in the echo area
723 :when
(version< "25" emacs-version
)
724 :config
(global-eldoc-mode))
726 ;; highlight matching parens
729 :config
(show-paren-mode))
731 (use-package elec-pair
733 :config
(electric-pair-mode))
736 :config
(column-number-mode)
738 ;; Save what I copy into clipboard from other applications into Emacs'
739 ;; kill-ring, which would allow me to still be able to easily access
740 ;; it in case I kill (cut or copy) something else inside Emacs before
741 ;; yanking (pasting) what I'd originally intended to.
742 (save-interprogram-paste-before-kill t
))
744 ;; save minibuffer history
745 (use-package savehist
749 (add-to-list 'savehist-additional-variables
'kill-ring
))
751 ;; automatically save place in files
752 (use-package saveplace
753 :when
(version< "25" emacs-version
)
754 :config
(save-place-mode))
756 (use-package prog-mode
757 :config
(global-prettify-symbols-mode)
758 (defun indicate-buffer-boundaries-left ()
759 (setq indicate-buffer-boundaries
'left
))
760 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
))
762 (use-package text-mode
763 :bind
(:map text-mode-map
("C-*" . b
/insert-asterism
))
764 :hook
((text-mode . indicate-buffer-boundaries-left
)
765 (text-mode . flyspell-mode
)))
767 (use-package conf-mode
770 (use-package sh-script
771 :mode
("\\.bashrc$" . sh-mode
))
776 (:map company-active-map
777 ([tab] . company-complete-common-or-cycle)
778 ([escape] . company-abort)
779 ("C-p" . company-select-previous-or-abort)
780 ("C-n" . company-select-next-or-abort))
782 (company-minimum-prefix-length 1)
783 (company-selection-wrap-around t)
784 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
785 (company-dabbrev-downcase nil)
786 (company-dabbrev-ignore-case nil)
788 ;; (global-company-mode t)
791 (use-package flycheck
794 :hook (prog-mode . flycheck-mode)
796 (:map flycheck-mode-map
797 ("M-P" . flycheck-previous-error)
798 ("M-N" . flycheck-next-error))
800 ;; Use the load-path from running Emacs when checking elisp files
801 (setq flycheck-emacs-lisp-load-path 'inherit)
803 ;; Only flycheck when I actually save the buffer
804 (setq flycheck-check-syntax-automatically '(mode-enabled save))
805 :custom (flycheck-mode-line-prefix "flyc"))
807 ;; (use-package flyspell)
809 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
814 ;; ’ can be part of a word
815 (setq ispell-local-dictionary-alist
816 `((nil "[[:alpha:]]" "[^[:alpha:]]"
817 "['\x2019]" nil ("-B") nil utf-8))
818 ispell-program-name (executable-find "hunspell"))
819 ;; don't send ’ to the subprocess
820 (defun endless/replace-apostrophe (args)
821 (cons (replace-regexp-in-string
824 (advice-add #'ispell-send-string :filter-args
825 #'endless/replace-apostrophe)
827 ;; convert ' back to ’ from the subprocess
828 (defun endless/replace-quote (args)
829 (if (not (derived-mode-p 'org-mode))
831 (cons (replace-regexp-in-string
834 (advice-add #'ispell-parse-output :filter-args
835 #'endless/replace-quote))
838 :hook (text-mode . abbrev-mode))
841 ;;; Programming modes
843 (use-package lisp-mode
845 (defun indent-spaces-mode ()
846 (setq indent-tabs-mode nil))
847 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
849 (use-package alloy-mode
850 :mode "\\.\\(als\\|dsh\\)\\'"
852 (setq alloy-basic-offset 2)
853 ;; (defun b/alloy-simple-indent (start end)
855 ;; ;; (if (region-active-p)
856 ;; ;; (indent-rigidly start end alloy-basic-offset)
858 ;; ;; (indent-rigidly (line-beginning-position)
859 ;; ;; (line-end-position)
860 ;; ;; alloy-basic-offset)))
861 ;; (indent-to (+ (current-column) alloy-basic-offset)))
862 :bind (:map alloy-mode-map
863 ("RET" . electric-newline-and-maybe-indent)
864 ;; ("TAB" . b/alloy-simple-indent)
865 ("TAB" . indent-for-tab-command))
866 :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil))))
868 (use-package lean-mode
871 :init (eval-when-compile (defvar lean-mode-map))
872 :bind (:map lean-mode-map
873 ("S-SPC" . company-complete))
875 (require 'lean-input)
876 (setq default-input-method "Lean"
877 lean-input-tweak-all '(lean-input-compose
878 (lean-input-prepend "/")
879 (lean-input-nonempty))
880 lean-input-user-translations '(("/" "/")))
883 (use-package sgml-mode
885 (setq sgml-basic-offset 0))
887 (use-package css-mode
889 (setq css-indent-offset 2))
894 (use-package geiser-guile
897 (setq geiser-guile-load-path "~/src/git/guix"))
908 (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit))))
913 (font-latex-fontify-sectioning 'color))
915 (use-package tex-mode
918 (lambda (p) (string-match "^---?" (car p)))
919 tex--prettify-symbols-alist)
920 :hook ((tex-mode . auto-fill-mode)
921 (tex-mode . flyspell-mode)))
923 ;; (use-package george-mode
924 ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode")
925 ;; :mode "\\.grg\\'")
928 ;;; Emacs enhancements & auxiliary packages
931 :config (setq Man-width 80))
933 (use-package which-key
936 (which-key-add-key-based-replacements
937 ;; prefixes for global prefixes and minor modes
939 "C-x RET" "coding system"
941 "C-x @" "event modifiers"
942 "C-x a" "abbrev/expand"
943 "C-x r" "rectangle/register/bookmark"
945 "C-x v" "version control"
949 ;; prefixes for my personal bindings
951 "C-c a" "applications"
956 "C-c c" "compile-and-comments"
965 ;; prefixes for major modes
966 (which-key-add-major-mode-key-based-replacements 'message-mode
967 "C-c f n" "footnote")
968 (which-key-add-major-mode-key-based-replacements 'org-mode
969 "C-c C-v" "org-babel")
973 (which-key-add-column-padding 5)
974 (which-key-idle-delay 10000)
975 (which-key-idle-secondary-delay 0.05)
976 (which-key-max-description-length 32)
977 (which-key-show-early-on-C-h t))
979 ;; (require 'bandali-projectile)
985 (("C-S-h c" . helpful-command)
986 ("C-S-h f" . helpful-callable) ; helpful-function
987 ("C-S-h v" . helpful-variable)
988 ("C-S-h k" . helpful-key)
989 ("C-S-h p" . helpful-at-point)))
991 (use-package unkillable-scratch
994 (unkillable-scratch 1)
996 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
999 ;; | make pretty boxed quotes like this
1001 (use-package boxquote
1005 b/boxquote-prefix-map
1007 ("b" . boxquote-buffer)
1008 ("B" . boxquote-insert-buffer)
1009 ("d" . boxquote-defun)
1010 ("F" . boxquote-insert-file)
1011 ("hf" . boxquote-describe-function)
1012 ("hk" . boxquote-describe-key)
1013 ("hv" . boxquote-describe-variable)
1014 ("hw" . boxquote-where-is)
1015 ("k" . boxquote-kill)
1016 ("p" . boxquote-paragraph)
1017 ("q" . boxquote-boxquote)
1018 ("r" . boxquote-region)
1019 ("s" . boxquote-shell-command)
1020 ("t" . boxquote-text)
1021 ("T" . boxquote-title)
1022 ("u" . boxquote-unbox)
1023 ("U" . boxquote-unbox-region)
1024 ("y" . boxquote-yank)
1025 ("M-q" . boxquote-fill-paragraph)
1026 ("M-w" . boxquote-kill-ring-save)))
1028 (use-package hl-todo
1029 ;; highlight TODOs in buffers
1032 (global-hl-todo-mode))
1034 (use-package page-break-lines
1037 (page-break-lines-max-width fill-column)
1039 (global-page-break-lines-mode))
1041 (use-package expand-region
1042 :bind ("C-=" . er/expand-region))
1044 (require 'bandali-yasnippet)
1048 (use-package debbugs
1050 (("C-c D d" . debbugs-gnu)
1051 ("C-c D b" . debbugs-gnu-bugs)
1054 (interactive) ; bug-gnu-emacs
1055 (setq debbugs-gnu-current-suppress t)
1056 (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
1057 ("C-c D g" . ; bug-gnuzilla
1060 (setq debbugs-gnu-current-suppress t)
1061 (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
1062 ("C-c D G b" . ; bug-guix
1065 (setq debbugs-gnu-current-suppress t)
1066 (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
1067 ("C-c D G p" . ; guix-patches
1070 (setq debbugs-gnu-current-suppress t)
1071 (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
1073 (use-package org-ref
1075 (b/setq-every '("~/usr/org/references.bib")
1076 reftex-default-bibliography
1077 org-ref-default-bibliography)
1079 org-ref-bibliography-notes "~/usr/org/notes.org"
1080 org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
1082 ;; (use-package fill-column-indicator)
1086 (("C-c w s l" . (lambda ()
1088 (split-window-right)
1090 ("C-c w s j" . (lambda ()
1092 (split-window-below)
1094 ("C-c w q" . quit-window))
1096 (split-width-threshold 150))
1098 (use-package windmove
1101 (("C-c w h" . windmove-left)
1102 ("C-c w j" . windmove-down)
1103 ("C-c w k" . windmove-up)
1104 ("C-c w l" . windmove-right)
1105 ("C-c w H" . windmove-swap-states-left)
1106 ("C-c w J" . windmove-swap-states-down)
1107 ("C-c w K" . windmove-swap-states-up)
1108 ("C-c w L" . windmove-swap-states-right)))
1112 :bind ("C-c a p" . pass)
1113 :hook (pass-mode . View-exit))
1115 (use-package pdf-tools
1117 :bind (:map pdf-view-mode-map
1118 ("<C-XF86Back>" . pdf-history-backward)
1119 ("<mouse-8>" . pdf-history-backward)
1120 ("<drag-mouse-8>" . pdf-history-backward)
1121 ("<C-XF86Forward>" . pdf-history-forward)
1122 ("<mouse-9>" . pdf-history-forward)
1123 ("<drag-mouse-9>" . pdf-history-forward)
1124 ("M-RET" . image-previous-line)
1125 ("C-s" . isearch-forward)
1126 ("s s" . isearch-forward))
1127 :config (pdf-tools-install nil t)
1128 :custom (pdf-view-resize-factor 1.05))
1130 (use-package org-pdftools
1132 :straight (:host github :repo "fuxialexander/org-pdftools")
1136 (with-eval-after-load 'org
1137 (require 'org-pdftools)))
1139 (use-package biblio)
1142 :hook (latex-mode . reftex-mode))
1144 (use-package reftex-cite
1146 :disabled ; enable to disable
1147 ; reftex-cite's default choice
1150 (defun reftex-get-bibkey-default ()
1151 "If the cursor is in a citation macro, return the word before the macro."
1152 (let* ((macro (reftex-what-macro 1)))
1154 (when (and macro (string-match "cite" (car macro)))
1155 (goto-char (cdr macro)))
1156 (reftex-this-word)))))
1160 (dmenu-prompt-string "run: ")
1161 (dmenu-save-file (b/var "dmenu-items")))
1164 ;; TODO: fix build by properly building the eosd-pixbuf.c module
1165 ;; e.g. see https://github.com/raxod502/straight.el/issues/386
1167 :straight (:host github :repo "clarete/eosd")
1174 :bind ("C-c a e w" . eww)
1176 (eww-download-directory (file-name-as-directory
1177 (getenv "XDG_DOWNLOAD_DIR"))))
1180 ;;; Post initialization
1183 (message "Loading %s...done (%.3fs)" user-init-file
1184 (float-time (time-subtract (current-time)
1185 b/before-user-init-time)))
1187 ;;; init.el ends here