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.")
45 (when (not (bound-and-true-p b
/emacs-initialized
))
46 (message "Loading Emacs...done (%.3fs)"
47 (float-time (time-subtract b
/before-user-init-time
50 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
51 ;; during startup to reduce garbage collection frequency. clearing
52 ;; `file-name-handler-alist' seems to help reduce startup time too.
53 (defvar b
/gc-cons-threshold gc-cons-threshold
)
54 (defvar b
/gc-cons-percentage gc-cons-percentage
)
55 (defvar b
/file-name-handler-alist file-name-handler-alist
)
56 (setq gc-cons-threshold
(* 30 1024 1024) ; 30 MiB
57 gc-cons-percentage
0.6
58 file-name-handler-alist nil
59 ;; sidesteps a bug when profiling with esup
60 esup-child-profile-require-level
0)
62 ;; set them back to their defaults once we're done initializing
64 "My post-initialize function, run after loading `user-init-file'."
65 (setq b
/emacs-initialized t
66 gc-cons-threshold b
/gc-cons-threshold
67 gc-cons-percentage b
/gc-cons-percentage
68 file-name-handler-alist b
/file-name-handler-alist
)
69 (when (featurep 'exwm-workspace
)
70 (with-eval-after-load 'exwm-workspace
77 "[%s]" (number-to-string
78 exwm-workspace-current-index
))))))))
80 ;; make some mode-line spaces smaller
85 (if (and (stringp x
) (or (string= x
" ") (string= x
" ")))
89 mode-line-buffer-identification
90 (propertized-buffer-identification "%10b")))
91 (add-hook 'after-init-hook
#'b
/post-init
)
93 ;; increase number of lines kept in *Messages* log
94 (setq message-log-max
20000)
96 ;; optionally, uncomment to supress some byte-compiler warnings
97 ;; (see C-h v byte-compile-warnings RET for more info)
98 ;; (setq byte-compile-warnings
99 ;; '(not free-vars unresolved noruntime lexical make-local))
104 (setq user-full-name
"Amin Bandali"
105 user-mail-address
"bandali@gnu.org")
108 ;;; Package management
110 ;; variables of interest:
111 ;; package-archive-priorities
113 ;; package-pinned-packages
115 ;; (let* ((b (find-file-noselect "refinery-theme.el"))
116 ;; (d (with-current-buffer b (package-buffer-info))))
117 ;; (package-generate-description-file d "refinery-theme-pkg.el"))
118 (run-with-idle-timer 0.01 nil
#'require
'package
)
119 (with-eval-after-load 'package
120 (when (= (length package-archives
) 1)
124 ;; ("bndl" . "https://p.bndl.org/elpa/")
125 ("org" .
"https://orgmode.org/elpa/"))
135 (rt-liberation "1.31")
138 (refinery-theme "0.1.1")
140 (org-plus-contrib "20200921"))))
141 (package-initialize))
143 (csetq package-archive-upload-base
"/ssh:caffeine:~/www/p/elpa")
148 ;; keep ~/.emacs.d clean
151 (convert-standard-filename "etc/") user-emacs-directory
)
152 "The directory where packages place their configuration files.")
155 (convert-standard-filename "var/") user-emacs-directory
)
156 "The directory where packages place their persistent data files.")
159 (convert-standard-filename "lisp/") user-emacs-directory
)
160 "The directory where packages place their persistent data files.")
162 "Expand filename FILE relative to `b/etc-dir'."
163 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
165 "Expand filename FILE relative to `b/var-dir'."
166 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
168 "Expand filename FILE relative to `b/lisp-dir'."
169 (expand-file-name (convert-standard-filename file
) b
/lisp-dir
))
172 auto-save-list-file-prefix
(b/var
"auto-save/sessions/")
173 nsm-settings-file
(b/var
"nsm-settings.el"))
175 ;; separate custom file (don't want it mixing with init.el)
176 (with-eval-after-load 'custom
177 (setq custom-file
(b/etc
"custom.el"))
178 (when (file-exists-p custom-file
)
180 ;; while at it, treat themes as safe
181 ;; (setf custom-safe-themes t)
182 ;; only one custom theme at a time
184 (defadvice load-theme
(before clear-previous-themes activate
)
185 "Clear existing theme settings instead of layering them"
186 (mapc #'disable-theme custom-enabled-themes
))))
188 ;; load the secrets file if it exists, otherwise show a warning
191 (load (b/etc
"secrets"))))
193 ;; start up emacs server. see
194 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
195 (run-with-idle-timer 0.5 nil
#'require
'server
)
196 (with-eval-after-load 'server
197 (declare-function server-edit
"server")
198 (global-set-key (kbd "C-c F D") #'server-edit
)
199 (declare-function server-running-p
"server")
200 (or (server-running-p) (server-mode)))
205 ;;;; C-level customizations
209 enable-recursive-minibuffers t
210 resize-mini-windows t
211 ;; more useful frame titles
212 ;; frame-title-format '("" invocation-name " - "
214 ;; (if (buffer-file-name)
215 ;; (abbreviate-file-name (buffer-file-name))
217 ;; i don't feel like jumping out of my chair every now and again; so
218 ;; don't BEEP! at me, emacs
219 ring-bell-function
'ignore
222 ;; scroll-conservatively 10000
224 scroll-conservatively
101
225 scroll-preserve-screen-position
1
226 ;; focus follows mouse
227 mouse-autoselect-window t
)
230 ;; always use space for indentation
233 ;; case-sensitive search (and `dabbrev-expand')
234 ;; case-fold-search nil
238 (set-fontset-font t
'arabic
"Vazir")
242 (dolist (ft (fontset-list))
246 (font-spec :name
"Source Code Pro" :size
14))
250 (font-spec :name
"DejaVu Sans Mono")
257 ;; :name "Symbola monospacified for DejaVu Sans Mono")
263 ;; (font-spec :name "DejaVu Sans Mono")
269 (font-spec :name
"DejaVu Sans Mono" :size
14)
273 ;;;; Elisp-level customizations
276 ;; don't need to see the startup echo area message
277 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
279 ;; i want *scratch* as my startup buffer
280 initial-buffer-choice t
281 ;; i don't need the default hint
282 initial-scratch-message nil
283 ;; use customizable text-mode as major mode for *scratch*
284 ;; (initial-major-mode 'text-mode)
285 ;; inhibit buffer list when more than 2 files are loaded
286 inhibit-startup-buffer-menu t
287 ;; don't need to see the startup screen or echo area message
288 inhibit-startup-screen t
289 inhibit-startup-echo-area-message user-login-name
)
293 ;; backups (C-h v make-backup-files RET)
295 backup-directory-alist
(list (cons "." (b/var
"backup/")))
297 delete-old-versions t
299 auto-save-file-name-transforms
`((".*" ,(b/var
"auto-save/") t
))
300 ;; insert newline at the end of files
301 require-final-newline t
302 ;; open read-only file buffers in view-mode
303 ;; (enables niceties like `q' for quit)
307 ;; disable disabled commands
308 (csetq disabled-command-function nil
)
310 ;; lazy-person-friendly yes/no prompts
311 (defalias 'yes-or-no-p
#'y-or-n-p
)
313 ;; autorevert: enable automatic reloading of changed buffers and files
314 (csetq auto-revert-verbose nil
315 global-auto-revert-non-file-buffers nil
)
316 (require 'autorevert
)
317 (global-auto-revert-mode 1)
319 ;; time and battery in mode-line
321 display-time-default-load-average nil
322 display-time-format
" %a %b %-e %-l:%M%P"
323 display-time-mail-icon
'(image :type xpm
324 :file
"gnus/gnus-pointer.xpm"
326 display-time-use-mail-icon t
)
330 (csetq battery-mode-line-format
" %p%% %t")
332 (display-battery-mode)
336 ;; (fringe-mode '(3 . 1))
340 ;; enable winner-mode (C-h f winner-mode RET)
343 (with-eval-after-load 'compile
344 ;; don't display *compilation* buffer on success. based on
345 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
346 ;; instead of the now obsolete `flet'.
347 (defun b/compilation-finish-function
(buffer outstr
)
348 (unless (string-match "finished" outstr
)
349 (switch-to-buffer-other-window buffer
))
352 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
356 (defadvice compilation-start
357 (around inhibit-display
358 (command &optional mode name-function highlight-regexp
))
359 (if (not (string-match "^\\(find\\|grep\\)" command
))
360 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
361 (save-window-excursion ad-do-it
))
363 (ad-activate 'compilation-start
))
367 ;; allow scrolling in Isearch
368 isearch-allow-scroll t
369 ;; search for non-ASCII characters: i’d like non-ASCII characters such
370 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
371 ;; counterpart. shoutout to
372 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
373 search-default-mode
#'char-fold-to-regexp
)
376 ;; uncomment to extend the above behaviour to query-replace
377 ;; (csetq replace-char-fold t)
380 (global-set-key (kbd "C-x v C-=") #'vc-ediff
)
382 (with-eval-after-load 'vc-git
383 (csetq vc-git-print-log-follow t
384 vc-git-show-stash
0))
386 (csetq ediff-window-setup-function
'ediff-setup-windows-plain
387 ediff-split-window-function
'split-window-horizontally
)
388 (with-eval-after-load 'ediff
389 (add-hook 'ediff-after-quit-hook-internal
#'winner-undo
))
393 ;; gentler font resizing
394 text-scale-mode-step
1.05)
396 (run-with-idle-timer 0.4 nil
#'require
'mwheel
)
397 (csetq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
398 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
399 mouse-wheel-follow-mouse t
) ; scroll window under mouse
401 (run-with-idle-timer 0.4 nil
#'require
'pixel-scroll
)
402 (with-eval-after-load 'pixel-scroll
403 (pixel-scroll-mode 1))
407 epg-gpg-program
(executable-find "gpg")
408 ;; ask for GPG passphrase in minibuffer
409 ;; this will fail if gpg>=2.1 is not available
410 epg-pinentry-mode
'loopback
)
412 ;; (require 'pinentry)
413 ;; workaround for systemd-based distros:
414 ;; (setq pinentry--socket-dir server-socket-dir)
419 auth-sources
'("~/.authinfo.gpg")
420 authinfo-hidden
(regexp-opt '("password" "client-secret" "token")))
423 ;;; General key bindings
425 (global-set-key (kbd "C-a") #'b
/move-indentation-or-beginning-of-line
)
426 (global-set-key (kbd "C-c a i") #'ielm
)
427 (global-set-key (kbd "C-c d") #'b
/duplicate-line-or-region
)
428 (global-set-key (kbd "C-S-j") #'b
/join-line-top
)
429 (global-set-key (kbd "C-c x") #'execute-extended-command
)
431 ;; evaling and macro-expanding
432 (global-set-key (kbd "C-c e b") #'eval-buffer
)
433 (global-set-key (kbd "C-c e e") #'eval-last-sexp
)
434 (global-set-key (kbd "C-c e p") #'pp-macroexpand-last-sexp
)
435 (global-set-key (kbd "C-c e r") #'eval-region
)
438 (global-set-key (kbd "C-c e i") #'emacs-init-time
)
439 (global-set-key (kbd "C-c e u") #'emacs-uptime
)
440 (global-set-key (kbd "C-c e v") #'emacs-version
)
443 (global-set-key (kbd "C-c f .") #'find-file
)
444 (global-set-key (kbd "C-c f d") #'find-name-dired
)
445 (global-set-key (kbd "C-c f l") #'find-library
)
448 (global-set-key (kbd "C-c F m") #'make-frame-command
)
449 (global-set-key (kbd "C-c F d") #'delete-frame
)
452 (global-set-key (kbd "C-S-h C") #'describe-char
)
453 (global-set-key (kbd "C-S-h F") #'describe-face
)
455 ;; (global-set-key (kbd "C-x k") #'b/kill-current-buffer)
456 ;; (global-set-key (kbd "C-x K") #'kill-buffer)
457 ;; (global-set-key (kbd "C-x s") #'save-buffer)
458 ;; (global-set-key (kbd "C-x S") #'save-some-buffers)
460 (define-key emacs-lisp-mode-map
(kbd "<C-return>") #'b
/add-elisp-section
)
462 (when (display-graphic-p)
463 (global-unset-key (kbd "C-z")))
466 ;;; Essential packages
468 ;; (require 'bandali-exwm)
470 (require 'bandali-org
)
472 (require 'bandali-theme
)
474 ;; (require 'bandali-magit)
476 ;; recently opened files
477 (csetq recentf-max-saved-items
2000
478 recentf-save-file
(b/var
"recentf-save.el"))
479 (run-with-idle-timer 0.2 nil
#'require
'recentf
)
480 (with-eval-after-load 'recentf
481 ;; (add-to-list 'recentf-keep #'file-remote-p)
484 ;; needed for history for counsel
485 (csetq amx-save-file
(b/var
"amx-save.el"))
486 (add-to-list 'load-path
(b/lisp
"s"))
487 (add-to-list 'load-path
(b/lisp
"amx"))
488 (run-with-idle-timer 0.3 nil
#'require
'amx
)
489 (with-eval-after-load 'amx
492 (require 'bandali-ivy
)
494 (require 'bandali-eshell
)
496 (require 'bandali-ibuffer
)
499 ;; (with-eval-after-load 'outline
500 ;; (when (featurep 'which-key)
501 ;; (which-key-add-key-based-replacements
504 ;; (define-key outline-minor-mode-map (kbd "<s-tab>")
505 ;; #'outline-toggle-children)
506 ;; (define-key outline-minor-mode-map (kbd "M-p")
507 ;; #'outline-previous-visible-heading)
508 ;; (define-key outline-minor-mode-map (kbd "M-n")
509 ;; #'outline-next-visible-heading)
510 ;; (defvar b/outline-prefix-map)
511 ;; (define-prefix-command 'b/outline-prefix-map)
512 ;; (define-key outline-minor-mode-map (kbd "s-O")
513 ;; 'b/outline-prefix-map)
514 ;; (define-key b/outline-prefix-map (kbd "TAB")
515 ;; #'outline-toggle-children)
516 ;; (define-key b/outline-prefix-map (kbd "a")
517 ;; #'outline-hide-body)
518 ;; (define-key b/outline-prefix-map (kbd "H")
519 ;; #'outline-hide-body)
520 ;; (define-key b/outline-prefix-map (kbd "S")
521 ;; #'outline-show-all)
522 ;; (define-key b/outline-prefix-map (kbd "h")
523 ;; #'outline-hide-subtree)
524 ;; (define-key b/outline-prefix-map (kbd "s")
525 ;; #'outline-show-subtree))
526 ;; (add-hook 'prog-mode-hook #'outline-minor-mode)
528 (require 'bandali-dired
)
530 (with-eval-after-load 'help
531 (temp-buffer-resize-mode)
532 (csetq help-window-select t
))
534 (with-eval-after-load 'help-mode
535 ;; local key bindings
536 (define-key help-mode-map
(kbd "p") #'backward-button
)
537 (define-key help-mode-map
(kbd "n") #'forward-button
))
539 (with-eval-after-load 'tramp
540 (csetq tramp-auto-save-directory
(b/var
"tramp/auto-save/")
541 tramp-persistency-file-name
(b/var
"tramp/persistency.el"))
542 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
543 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
544 (add-to-list 'tramp-default-proxies-alist
545 (list (regexp-quote (system-name)) nil nil
)))
547 (with-eval-after-load 'doc-view
548 (define-key doc-view-mode-map
(kbd "M-RET") #'image-previous-line
))
550 (csetq shr-max-width
80)
552 ;; Email (with Gnus, message, and EBDB)
553 (require 'bandali-gnus
)
554 (with-eval-after-load 'sendmail
555 (csetq sendmail-program
(executable-find "msmtp")
556 ;; message-sendmail-extra-arguments '("-v" "-d")
557 mail-specify-envelope-from t
558 mail-envelope-from
'header
))
559 (require 'bandali-message
)
560 (require 'bandali-ebdb
)
563 (require 'bandali-erc
)
565 (add-to-list 'load-path
(b/lisp
"scpaste"))
566 (with-eval-after-load 'scpaste
567 (csetq scpaste-http-destination
"https://p.bndl.org"
568 scpaste-scp-destination
"p:~"))
569 (autoload 'scpaste
"scpaste" nil t
)
570 (autoload 'scpaste-region
"scpaste" nil t
)
571 (global-set-key (kbd "C-c a p p") #'scpaste
)
572 (global-set-key (kbd "C-c a p r") #'scpaste-region
)
577 ;; display Lisp objects at point in the echo area
578 (when (version< "25" emacs-version
)
579 (with-eval-after-load 'eldoc
580 (csetq eldoc-minor-mode-string
" eldoc")
581 (global-eldoc-mode)))
583 ;; highlight matching parens
587 ;; (require 'elec-pair)
588 ;; (electric-pair-mode)
591 ;; Save what I copy into clipboard from other applications into Emacs'
592 ;; kill-ring, which would allow me to still be able to easily access
593 ;; it in case I kill (cut or copy) something else inside Emacs before
594 ;; yanking (pasting) what I'd originally intended to.
595 save-interprogram-paste-before-kill t
)
596 (with-eval-after-load 'simple
597 (column-number-mode 1))
599 ;; save minibuffer history
601 (csetq savehist-file
(b/var
"savehist.el"))
603 (add-to-list 'savehist-additional-variables
'kill-ring
)
605 ;; automatically save place in files
606 (when (version< "25" emacs-version
)
607 (csetq save-place-file
(b/var
"save-place.el"))
610 (defun indicate-buffer-boundaries-left ()
611 (csetq indicate-buffer-boundaries
'left
))
612 (with-eval-after-load 'prog-mode
613 (global-prettify-symbols-mode))
614 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
)
616 (define-key text-mode-map
(kbd "C-<return>") #'b
/insert-asterism
)
617 (add-hook 'text-mode-hook
#'indicate-buffer-boundaries-left
)
618 (add-hook 'text-mode-hook
#'flyspell-mode
)
620 (add-to-list 'auto-mode-alist
'("\\.*rc$" . conf-mode
))
622 (add-to-list 'auto-mode-alist
'("\\.bashrc$" . sh-mode
))
624 (with-eval-after-load 'flyspell
625 (csetq flyspell-mode-line-string
" fly"))
628 ;; (run-with-idle-timer 0.6 nil #'require 'flycheck)
629 ;; (with-eval-after-load 'flycheck
631 ;; ;; Use the load-path from running Emacs when checking elisp files
632 ;; flycheck-emacs-lisp-load-path 'inherit
633 ;; ;; Only flycheck when I actually save the buffer
634 ;; flycheck-check-syntax-automatically '(mode-enabled save)
635 ;; flycheck-mode-line-prefix "flyc"))
636 ;; (define-key flycheck-mode-map (kbd "M-P") #'flycheck-previous-error)
637 ;; (define-key flycheck-mode-map (kbd "M-N") #'flycheck-next-error)
638 ;; (add-hook 'prog-mode-hook #'flycheck-mode)
641 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
642 ;; (run-with-idle-timer 0.6 nil #'require 'ispell)
643 ;; (with-eval-after-load 'ispell
644 ;; ;; ’ can be part of a word
645 ;; (csetq ispell-local-dictionary-alist
646 ;; `((nil "[[:alpha:]]" "[^[:alpha:]]"
647 ;; "['\x2019]" nil ("-B") nil utf-8))
648 ;; ispell-program-name (executable-find "hunspell"))
649 ;; ;; don't send ’ to the subprocess
650 ;; (defun endless/replace-apostrophe (args)
651 ;; (cons (replace-regexp-in-string
652 ;; "’" "'" (car args))
654 ;; (advice-add #'ispell-send-string :filter-args
655 ;; #'endless/replace-apostrophe)
656 ;; ;; convert ' back to ’ from the subprocess
657 ;; (defun endless/replace-quote (args)
658 ;; (if (not (derived-mode-p 'org-mode))
660 ;; (cons (replace-regexp-in-string
661 ;; "'" "’" (car args))
663 ;; (advice-add #'ispell-parse-output :filter-args
664 ;; #'endless/replace-quote))
667 (csetq abbrev-file-name
(b/etc
"abbrev.el"))
668 (add-hook 'text-mode-hook
#'abbrev-mode
)
671 ;;; Programming modes
673 (with-eval-after-load 'lisp-mode
674 (defun indent-spaces-mode ()
675 (setq indent-tabs-mode nil
))
676 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
679 (add-to-list 'load-path
(b/lisp
"alloy-mode"))
680 (autoload 'alloy-mode
"alloy-mode" nil t
)
681 (with-eval-after-load 'alloy-mode
682 (csetq alloy-basic-offset
2)
683 ;; (defun b/alloy-simple-indent (start end)
685 ;; ;; (if (region-active-p)
686 ;; ;; (indent-rigidly start end alloy-basic-offset)
688 ;; ;; (indent-rigidly (line-beginning-position)
689 ;; ;; (line-end-position)
690 ;; ;; alloy-basic-offset)))
691 ;; (indent-to (+ (current-column) alloy-basic-offset)))
692 ;; local key bindings
693 (define-key alloy-mode-map
(kbd "RET") #'electric-newline-and-maybe-indent
)
694 ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent)
695 (define-key alloy-mode-map
(kbd "TAB") #'indent-for-tab-command
))
696 (add-to-list 'auto-mode-alist
'("\\.\\(als\\|dsh\\)\\'" . alloy-mode
))
697 (add-hook 'alloy-mode-hook
(lambda nil
(setq-local indent-tabs-mode nil
)))
700 ;; (eval-when-compile (defvar lean-mode-map))
701 ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode)
702 ;; (with-eval-after-load 'lean-mode
703 ;; (require 'lean-input)
704 ;; (csetq default-input-method "Lean"
705 ;; lean-input-tweak-all '(lean-input-compose
706 ;; (lean-input-prepend "/")
707 ;; (lean-input-nonempty))
708 ;; lean-input-user-translations '(("/" "/")))
709 ;; (lean-input-setup)
710 ;; ;; local key bindings
711 ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete))
713 (with-eval-after-load 'sgml-mode
714 (csetq sgml-basic-offset
0))
716 (with-eval-after-load 'css-mode
717 (csetq css-indent-offset
2))
720 ;; (add-hook 'po-mode-hook (lambda nil (run-with-timer 0.1 nil 'View-exit)))
723 ;; (csetq font-latex-fontify-sectioning 'color)
725 (with-eval-after-load 'tex-mode
727 (lambda (p) (string-match "^---?" (car p
)))
728 tex--prettify-symbols-alist
))
729 (add-hook 'tex-mode-hook
#'auto-fill-mode
)
730 (add-hook 'tex-mode-hook
#'flyspell-mode
)
733 ;;; Emacs enhancements & auxiliary packages
735 (with-eval-after-load 'man
736 (csetq Man-width
80))
738 (defun b/*scratch
* ()
739 "Switch to `*scratch*' buffer, creating it if it does not exist."
742 (or (get-buffer "*scratch*")
743 (with-current-buffer (get-buffer-create "*scratch*")
744 (set-buffer-major-mode (current-buffer))
746 (global-set-key (kbd "C-c s") #'b
/*scratch
*)
749 ;; | make pretty boxed quotes like this
751 (add-to-list 'load-path
(b/lisp
"boxquote"))
752 (run-with-idle-timer 0.6 nil
#'require
'boxquote
)
753 (with-eval-after-load 'boxquote
754 (defvar b
/boxquote-prefix-map
)
755 (define-prefix-command 'b
/boxquote-prefix-map
)
756 (global-set-key (kbd "C-c q") 'b
/boxquote-prefix-map
)
757 (define-key b
/boxquote-prefix-map
(kbd "b") #'boxquote-buffer
)
758 (define-key b
/boxquote-prefix-map
(kbd "B") #'boxquote-insert-buffer
)
759 (define-key b
/boxquote-prefix-map
(kbd "d") #'boxquote-defun
)
760 (define-key b
/boxquote-prefix-map
(kbd "F") #'boxquote-insert-file
)
761 (define-key b
/boxquote-prefix-map
(kbd "hf") #'boxquote-describe-function
)
762 (define-key b
/boxquote-prefix-map
(kbd "hk") #'boxquote-describe-key
)
763 (define-key b
/boxquote-prefix-map
(kbd "hv") #'boxquote-describe-variable
)
764 (define-key b
/boxquote-prefix-map
(kbd "hw") #'boxquote-where-is
)
765 (define-key b
/boxquote-prefix-map
(kbd "k") #'boxquote-kill
)
766 (define-key b
/boxquote-prefix-map
(kbd "p") #'boxquote-paragraph
)
767 (define-key b
/boxquote-prefix-map
(kbd "q") #'boxquote-boxquote
)
768 (define-key b
/boxquote-prefix-map
(kbd "r") #'boxquote-region
)
769 (define-key b
/boxquote-prefix-map
(kbd "s") #'boxquote-shell-command
)
770 (define-key b
/boxquote-prefix-map
(kbd "t") #'boxquote-text
)
771 (define-key b
/boxquote-prefix-map
(kbd "T") #'boxquote-title
)
772 (define-key b
/boxquote-prefix-map
(kbd "u") #'boxquote-unbox
)
773 (define-key b
/boxquote-prefix-map
(kbd "U") #'boxquote-unbox-region
)
774 (define-key b
/boxquote-prefix-map
(kbd "y") #'boxquote-yank
)
775 (define-key b
/boxquote-prefix-map
(kbd "M-q") #'boxquote-fill-paragraph
)
776 (define-key b
/boxquote-prefix-map
(kbd "M-w") #'boxquote-kill-ring-save
))
778 (add-to-list 'load-path
(b/lisp
"hl-todo"))
779 (run-with-idle-timer 0.5 nil
#'require
'hl-todo
)
780 (with-eval-after-load 'hl-todo
781 ;; highlight TODOs in buffers
782 (global-hl-todo-mode))
784 (add-to-list 'load-path
(b/lisp
"page-break-lines"))
785 (run-with-idle-timer 0.5 nil
#'require
'page-break-lines
)
786 (with-eval-after-load 'page-break-lines
787 (csetq page-break-lines-max-width fill-column
)
788 (global-page-break-lines-mode))
791 (global-set-key (kbd "C-=") #'er
/expand-region
)
793 (run-with-idle-timer 0.6 nil
#'require
'yasnippet
)
794 (with-eval-after-load 'yasnippet
795 (declare-function yas-reload-all
796 "yasnippet" (&optional no-jit interactive
))
797 (declare-function yas-maybe-expand-abbrev-key-filter
800 (defconst yas-verbosity-cur yas-verbosity
)
801 (setq yas-verbosity
2)
802 (csetq yas-snippet-dirs
`(,(b/etc
"yasnippet/snippets")))
803 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
805 (setq yas-verbosity yas-verbosity-cur
)
807 (defun b/yas-maybe-expand-abbrev-key-filter
(cmd)
808 (when (and (yas-maybe-expand-abbrev-key-filter cmd
)
809 (not (bound-and-true-p git-commit-mode
)))
811 (defconst b
/yas-maybe-expand
812 '(menu-item "" yas-expand
813 :filter b
/yas-maybe-expand-abbrev-key-filter
))
814 (define-key yas-minor-mode-map
(kbd "SPC") b
/yas-maybe-expand
)
819 (global-set-key (kbd "C-c D d") #'debbugs-gnu
)
820 (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs
)
821 (global-set-key (kbd "C-c D e") ; bug-gnu-emacs
824 (setq debbugs-gnu-current-suppress t
)
825 (debbugs-gnu debbugs-gnu-default-severities
827 (global-set-key (kbd "C-c D g") ; bug-gnuzilla
830 (setq debbugs-gnu-current-suppress t
)
831 (debbugs-gnu debbugs-gnu-default-severities
833 (global-set-key (kbd "C-c D G b") ; bug-guix
836 (setq debbugs-gnu-current-suppress t
)
837 (debbugs-gnu debbugs-gnu-default-severities
839 (global-set-key (kbd "C-c D G p") ; guix-patches
842 (setq debbugs-gnu-current-suppress t
)
843 (debbugs-gnu debbugs-gnu-default-severities
848 url-configuration-directory
(b/var
"url/configuration/")
849 url-cache-directory
(b/var
"url/cache/"))
852 (csetq eww-download-directory
(file-name-as-directory
853 (getenv "XDG_DOWNLOAD_DIR")))
854 (global-set-key (kbd "C-c a e w") #'eww
)
858 ;; reftex-default-bibliography '("~/usr/org/references.bib")
859 ;; org-ref-default-bibliography '("~/usr/org/references.bib")
860 ;; org-ref-bibliography-notes "~/usr/org/notes.org"
861 ;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")
863 ;; fill-column-indicator ?
866 (csetq split-width-threshold
150)
867 (global-set-key (kbd "C-c w s l")
872 (global-set-key (kbd "C-c w s j")
877 (global-set-key (kbd "C-c w q") #'quit-window
)
879 (run-with-idle-timer 0.6 nil
#'require
'windmove
)
880 (global-set-key (kbd "C-c w h") #'windmove-left
)
881 (global-set-key (kbd "C-c w j") #'windmove-down
)
882 (global-set-key (kbd "C-c w k") #'windmove-up
)
883 (global-set-key (kbd "C-c w l") #'windmove-right
)
884 (global-set-key (kbd "C-c w H") #'windmove-swap-states-left
)
885 (global-set-key (kbd "C-c w J") #'windmove-swap-states-down
)
886 (global-set-key (kbd "C-c w K") #'windmove-swap-states-up
)
887 (global-set-key (kbd "C-c w L") #'windmove-swap-states-right
)
890 ;; (global-set-key (kbd "C-c a p") #'pass)
891 ;; (add-hook 'pass-mode-hook #'View-exit)
894 ;; uncomment to disable reftex-cite's default choice of previous word
895 ;; (with-eval-after-load 'reftex
896 ;; (require 'reftex-cite)
897 ;; (defun reftex-get-bibkey-default ()
898 ;; "If the cursor is in a citation macro, return the word before the macro."
899 ;; (let* ((macro (reftex-what-macro 1)))
901 ;; (when (and macro (string-match "cite" (car macro)))
902 ;; (goto-char (cdr macro)))
903 ;; (reftex-this-word)))))
904 (add-hook 'latex-mode-hook
#'reftex-mode
)
908 ;; dmenu-prompt-string "run: "
909 ;; dmenu-save-file (b/var "dmenu-items"))
914 (run-with-idle-timer 0.5 nil
#'require
'delight
)
915 (with-eval-after-load 'delight
916 (delight 'auto-fill-function
" f" "simple")
917 (delight 'abbrev-mode
"" "abbrev")
918 (delight 'page-break-lines-mode
"" "page-break-lines")
919 (delight 'ivy-mode
"" "ivy")
920 (delight 'counsel-mode
"" "counsel")
921 (delight 'mml-mode
" mml" "mml")
922 (delight 'yas-minor-mode
"" "yasnippet"))
925 ;;; Post initialization
927 (message "Loading %s...done (%.3fs)" user-init-file
928 (float-time (time-subtract (current-time)
929 b
/before-user-init-time
)))
931 ;;; init.el ends here