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
111 ;; (add-to-list 'load-path
112 ;; (expand-file-name "lib/borg" user-emacs-directory))
115 ;; (setq borg-rewrite-urls-alist
116 ;; '(("git@github.com:" . "https://github.com/")
117 ;; ("git@gitlab.com:" . "https://gitlab.com/"))))
119 ;; variables of interest:
120 ;; package-archive-priorities
122 ;; package-pinned-packages
124 ;; (let* ((b (find-file-noselect "refinery-theme.el"))
125 ;; (d (with-current-buffer b (package-buffer-info))))
126 ;; (package-generate-description-file d "refinery-theme-pkg.el"))
127 (run-with-idle-timer 0.01 nil
#'require
'package
)
128 (with-eval-after-load 'package
129 (when (= (length package-archives
) 1)
133 ("org" .
"https://orgmode.org/elpa/")
134 ("bndl" .
"https://p.bndl.org/elpa/"))))
135 (package-initialize))
137 (csetq package-archive-upload-base
"/ssh:caffeine:~/www/p/elpa")
142 ;; keep ~/.emacs.d clean
145 (convert-standard-filename "etc/") user-emacs-directory
)
146 "The directory where packages place their configuration files.")
149 (convert-standard-filename "var/") user-emacs-directory
)
150 "The directory where packages place their persistent data files.")
153 (convert-standard-filename "lisp/") user-emacs-directory
)
154 "The directory where packages place their persistent data files.")
156 "Expand filename FILE relative to `b/etc-dir'."
157 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
159 "Expand filename FILE relative to `b/var-dir'."
160 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
162 "Expand filename FILE relative to `b/lisp-dir'."
163 (expand-file-name (convert-standard-filename file
) b
/lisp-dir
))
166 auto-save-list-file-prefix
(b/var
"auto-save/sessions/")
167 nsm-settings-file
(b/var
"nsm-settings.el"))
169 ;; separate custom file (don't want it mixing with init.el)
170 (with-eval-after-load 'custom
171 (setq custom-file
(b/etc
"custom.el"))
172 (when (file-exists-p custom-file
)
174 ;; while at it, treat themes as safe
175 ;; (setf custom-safe-themes t)
176 ;; only one custom theme at a time
178 (defadvice load-theme
(before clear-previous-themes activate
)
179 "Clear existing theme settings instead of layering them"
180 (mapc #'disable-theme custom-enabled-themes
))))
182 ;; load the secrets file if it exists, otherwise show a warning
185 (load (b/etc
"secrets"))))
187 ;; start up emacs server. see
188 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
189 (run-with-idle-timer 0.5 nil
#'require
'server
)
190 (with-eval-after-load 'server
191 (declare-function server-edit
"server")
192 (global-set-key (kbd "C-c F D") #'server-edit
)
193 (declare-function server-running-p
"server")
194 (or (server-running-p) (server-mode)))
199 ;;;; C-level customizations
203 enable-recursive-minibuffers t
204 resize-mini-windows t
205 ;; more useful frame titles
206 ;; frame-title-format '("" invocation-name " - "
208 ;; (if (buffer-file-name)
209 ;; (abbreviate-file-name (buffer-file-name))
211 ;; i don't feel like jumping out of my chair every now and again; so
212 ;; don't BEEP! at me, emacs
213 ring-bell-function
'ignore
216 ;; scroll-conservatively 10000
218 scroll-conservatively
101
219 scroll-preserve-screen-position
1
220 ;; focus follows mouse
221 mouse-autoselect-window t
)
224 ;; always use space for indentation
227 ;; case-sensitive search (and `dabbrev-expand')
228 ;; case-fold-search nil
232 (set-fontset-font t
'arabic
"Vazir")
236 (dolist (ft (fontset-list))
240 (font-spec :name
"Source Code Pro" :size
14))
244 (font-spec :name
"DejaVu Sans Mono")
251 ;; :name "Symbola monospacified for DejaVu Sans Mono")
257 ;; (font-spec :name "DejaVu Sans Mono")
263 (font-spec :name
"DejaVu Sans Mono" :size
14)
267 ;;;; Elisp-level customizations
270 ;; don't need to see the startup echo area message
271 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
273 ;; i want *scratch* as my startup buffer
274 initial-buffer-choice t
275 ;; i don't need the default hint
276 initial-scratch-message nil
277 ;; use customizable text-mode as major mode for *scratch*
278 ;; (initial-major-mode 'text-mode)
279 ;; inhibit buffer list when more than 2 files are loaded
280 inhibit-startup-buffer-menu t
281 ;; don't need to see the startup screen or echo area message
282 inhibit-startup-screen t
283 inhibit-startup-echo-area-message user-login-name
)
287 ;; backups (C-h v make-backup-files RET)
289 backup-directory-alist
(list (cons "." (b/var
"backup/")))
291 delete-old-versions t
293 auto-save-file-name-transforms
`((".*" ,(b/var
"auto-save/") t
))
294 ;; insert newline at the end of files
295 require-final-newline t
296 ;; open read-only file buffers in view-mode
297 ;; (enables niceties like `q' for quit)
301 ;; disable disabled commands
302 (csetq disabled-command-function nil
)
304 ;; lazy-person-friendly yes/no prompts
305 (defalias 'yes-or-no-p
#'y-or-n-p
)
307 ;; autorevert: enable automatic reloading of changed buffers and files
308 (csetq auto-revert-verbose nil
309 global-auto-revert-non-file-buffers nil
)
310 (require 'autorevert
)
311 (global-auto-revert-mode 1)
313 ;; time and battery in mode-line
315 display-time-default-load-average nil
316 display-time-format
" %a %b %-e %-l:%M%P"
317 display-time-mail-icon
'(image :type xpm
318 :file
"gnus/gnus-pointer.xpm"
320 display-time-use-mail-icon t
)
324 (csetq battery-mode-line-format
" %p%% %t")
326 (display-battery-mode)
330 ;; (fringe-mode '(3 . 1))
334 ;; enable winner-mode (C-h f winner-mode RET)
337 (with-eval-after-load 'compile
338 ;; don't display *compilation* buffer on success. based on
339 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
340 ;; instead of the now obsolete `flet'.
341 (defun b/compilation-finish-function
(buffer outstr
)
342 (unless (string-match "finished" outstr
)
343 (switch-to-buffer-other-window buffer
))
346 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
350 (defadvice compilation-start
351 (around inhibit-display
352 (command &optional mode name-function highlight-regexp
))
353 (if (not (string-match "^\\(find\\|grep\\)" command
))
354 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
355 (save-window-excursion ad-do-it
))
357 (ad-activate 'compilation-start
))
361 ;; allow scrolling in Isearch
362 isearch-allow-scroll t
363 ;; search for non-ASCII characters: i’d like non-ASCII characters such
364 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
365 ;; counterpart. shoutout to
366 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
367 search-default-mode
#'char-fold-to-regexp
)
370 ;; uncomment to extend the above behaviour to query-replace
371 ;; (csetq replace-char-fold t)
374 (global-set-key (kbd "C-x v C-=") #'vc-ediff
)
376 (with-eval-after-load 'vc-git
377 (csetq vc-git-print-log-follow t
))
379 (csetq ediff-window-setup-function
'ediff-setup-windows-plain
380 ediff-split-window-function
'split-window-horizontally
)
381 (with-eval-after-load 'ediff
382 (add-hook 'ediff-after-quit-hook-internal
#'winner-undo
))
386 ;; gentler font resizing
387 text-scale-mode-step
1.05)
389 (run-with-idle-timer 0.4 nil
#'require
'mwheel
)
390 (csetq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
391 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
392 mouse-wheel-follow-mouse t
) ; scroll window under mouse
394 (run-with-idle-timer 0.4 nil
#'require
'pixel-scroll
)
395 (with-eval-after-load 'pixel-scroll
396 (pixel-scroll-mode 1))
400 epg-gpg-program
(executable-find "gpg")
401 ;; ask for GPG passphrase in minibuffer
402 ;; this will fail if gpg>=2.1 is not available
403 epg-pinentry-mode
'loopback
)
405 ;; (require 'pinentry)
406 ;; workaround for systemd-based distros:
407 ;; (setq pinentry--socket-dir server-socket-dir)
412 auth-sources
'("~/.authinfo.gpg")
413 authinfo-hidden
(regexp-opt '("password" "client-secret" "token")))
416 ;;; General key bindings
418 (global-set-key (kbd "C-a") #'b
/move-indentation-or-beginning-of-line
)
419 (global-set-key (kbd "C-c a i") #'ielm
)
420 (global-set-key (kbd "C-c d") #'b
/duplicate-line-or-region
)
421 (global-set-key (kbd "C-S-j") #'b
/join-line-top
)
422 (global-set-key (kbd "C-c x") #'execute-extended-command
)
424 ;; evaling and macro-expanding
425 (global-set-key (kbd "C-c e b") #'eval-buffer
)
426 (global-set-key (kbd "C-c e e") #'eval-last-sexp
)
427 (global-set-key (kbd "C-c e p") #'pp-macroexpand-last-sexp
)
428 (global-set-key (kbd "C-c e r") #'eval-region
)
431 (global-set-key (kbd "C-c e i") #'emacs-init-time
)
432 (global-set-key (kbd "C-c e u") #'emacs-uptime
)
433 (global-set-key (kbd "C-c e v") #'emacs-version
)
436 (global-set-key (kbd "C-c f .") #'find-file
)
437 (global-set-key (kbd "C-c f d") #'find-name-dired
)
438 (global-set-key (kbd "C-c f l") #'find-library
)
441 (global-set-key (kbd "C-c F m") #'make-frame-command
)
442 (global-set-key (kbd "C-c F d") #'delete-frame
)
445 (global-set-key (kbd "C-S-h C") #'describe-char
)
446 (global-set-key (kbd "C-S-h F") #'describe-face
)
448 ;; (global-set-key (kbd "C-x k") #'b/kill-current-buffer)
449 ;; (global-set-key (kbd "C-x K") #'kill-buffer)
450 ;; (global-set-key (kbd "C-x s") #'save-buffer)
451 ;; (global-set-key (kbd "C-x S") #'save-some-buffers)
453 (define-key emacs-lisp-mode-map
(kbd "<C-return>") #'b
/add-elisp-section
)
455 (when (display-graphic-p)
456 (global-unset-key (kbd "C-z")))
459 ;;; Essential packages
461 ;; (require 'bandali-exwm)
463 (require 'bandali-org
)
465 (require 'bandali-theme
)
467 ;; (require 'bandali-magit)
469 ;; recently opened files
470 (csetq recentf-max-saved-items
2000
471 recentf-save-file
(b/var
"recentf-save.el"))
472 (run-with-idle-timer 0.2 nil
#'require
'recentf
)
473 (with-eval-after-load 'recentf
474 ;; (add-to-list 'recentf-keep #'file-remote-p)
477 ;; needed for history for counsel
478 (csetq amx-save-file
(b/var
"amx-save.el"))
479 (add-to-list 'load-path
(b/lisp
"s"))
480 (add-to-list 'load-path
(b/lisp
"amx"))
481 (run-with-idle-timer 0.3 nil
#'require
'amx
)
482 (with-eval-after-load 'amx
485 (require 'bandali-ivy
)
487 (require 'bandali-eshell
)
489 (require 'bandali-ibuffer
)
492 ;; (with-eval-after-load 'outline
493 ;; (when (featurep 'which-key)
494 ;; (which-key-add-key-based-replacements
497 ;; (define-key outline-minor-mode-map (kbd "<s-tab>")
498 ;; #'outline-toggle-children)
499 ;; (define-key outline-minor-mode-map (kbd "M-p")
500 ;; #'outline-previous-visible-heading)
501 ;; (define-key outline-minor-mode-map (kbd "M-n")
502 ;; #'outline-next-visible-heading)
503 ;; (defvar b/outline-prefix-map)
504 ;; (define-prefix-command 'b/outline-prefix-map)
505 ;; (define-key outline-minor-mode-map (kbd "s-O")
506 ;; 'b/outline-prefix-map)
507 ;; (define-key b/outline-prefix-map (kbd "TAB")
508 ;; #'outline-toggle-children)
509 ;; (define-key b/outline-prefix-map (kbd "a")
510 ;; #'outline-hide-body)
511 ;; (define-key b/outline-prefix-map (kbd "H")
512 ;; #'outline-hide-body)
513 ;; (define-key b/outline-prefix-map (kbd "S")
514 ;; #'outline-show-all)
515 ;; (define-key b/outline-prefix-map (kbd "h")
516 ;; #'outline-hide-subtree)
517 ;; (define-key b/outline-prefix-map (kbd "s")
518 ;; #'outline-show-subtree))
519 ;; (add-hook 'prog-mode-hook #'outline-minor-mode)
521 (require 'bandali-dired
)
523 (with-eval-after-load 'help
524 (temp-buffer-resize-mode)
525 (csetq help-window-select t
))
527 (with-eval-after-load 'help-mode
528 ;; local key bindings
529 (define-key help-mode-map
(kbd "p") #'backward-button
)
530 (define-key help-mode-map
(kbd "n") #'forward-button
))
532 (with-eval-after-load 'tramp
533 (csetq tramp-auto-save-directory
(b/var
"tramp/auto-save/")
534 tramp-persistency-file-name
(b/var
"tramp/persistency.el"))
535 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
536 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
537 (add-to-list 'tramp-default-proxies-alist
538 (list (regexp-quote (system-name)) nil nil
)))
540 (with-eval-after-load 'doc-view
541 (define-key doc-view-mode-map
(kbd "M-RET") #'image-previous-line
))
543 (csetq shr-max-width
80)
545 ;; Email (with Gnus, message, and EBDB)
546 (require 'bandali-gnus
)
547 (with-eval-after-load 'sendmail
548 (csetq sendmail-program
(executable-find "msmtp")
549 ;; message-sendmail-extra-arguments '("-v" "-d")
550 mail-specify-envelope-from t
551 mail-envelope-from
'header
))
552 (require 'bandali-message
)
553 (require 'bandali-ebdb
)
556 (require 'bandali-erc
)
558 (add-to-list 'load-path
(b/lisp
"scpaste"))
559 (with-eval-after-load 'scpaste
560 (csetq scpaste-http-destination
"https://p.bndl.org"
561 scpaste-scp-destination
"p:~"))
562 (autoload 'scpaste
"scpaste" nil t
)
563 (autoload 'scpaste-region
"scpaste" nil t
)
564 (global-set-key (kbd "C-c a p p") #'scpaste
)
565 (global-set-key (kbd "C-c a p r") #'scpaste-region
)
570 ;; display Lisp objects at point in the echo area
571 (when (version< "25" emacs-version
)
572 (with-eval-after-load 'eldoc
573 (csetq eldoc-minor-mode-string
" eldoc")
574 (global-eldoc-mode)))
576 ;; highlight matching parens
580 ;; (require 'elec-pair)
581 ;; (electric-pair-mode)
584 ;; Save what I copy into clipboard from other applications into Emacs'
585 ;; kill-ring, which would allow me to still be able to easily access
586 ;; it in case I kill (cut or copy) something else inside Emacs before
587 ;; yanking (pasting) what I'd originally intended to.
588 save-interprogram-paste-before-kill t
)
589 (with-eval-after-load 'simple
590 (column-number-mode 1))
592 ;; save minibuffer history
594 (csetq savehist-file
(b/var
"savehist.el"))
596 (add-to-list 'savehist-additional-variables
'kill-ring
)
598 ;; automatically save place in files
599 (when (version< "25" emacs-version
)
600 (csetq save-place-file
(b/var
"save-place.el"))
603 (defun indicate-buffer-boundaries-left ()
604 (csetq indicate-buffer-boundaries
'left
))
605 (with-eval-after-load 'prog-mode
606 (global-prettify-symbols-mode))
607 (add-hook 'prog-mode-hook
#'indicate-buffer-boundaries-left
)
609 (define-key text-mode-map
(kbd "C-<return>") #'b
/insert-asterism
)
610 (add-hook 'text-mode-hook
#'indicate-buffer-boundaries-left
)
611 (add-hook 'text-mode-hook
#'flyspell-mode
)
613 (add-to-list 'auto-mode-alist
'("\\.*rc$" . conf-mode
))
615 (add-to-list 'auto-mode-alist
'("\\.bashrc$" . sh-mode
))
617 (with-eval-after-load 'flyspell
618 (csetq flyspell-mode-line-string
" fly"))
621 ;; (run-with-idle-timer 0.6 nil #'require 'flycheck)
622 ;; (with-eval-after-load 'flycheck
624 ;; ;; Use the load-path from running Emacs when checking elisp files
625 ;; flycheck-emacs-lisp-load-path 'inherit
626 ;; ;; Only flycheck when I actually save the buffer
627 ;; flycheck-check-syntax-automatically '(mode-enabled save)
628 ;; flycheck-mode-line-prefix "flyc"))
629 ;; (define-key flycheck-mode-map (kbd "M-P") #'flycheck-previous-error)
630 ;; (define-key flycheck-mode-map (kbd "M-N") #'flycheck-next-error)
631 ;; (add-hook 'prog-mode-hook #'flycheck-mode)
634 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
635 ;; (run-with-idle-timer 0.6 nil #'require 'ispell)
636 ;; (with-eval-after-load 'ispell
637 ;; ;; ’ can be part of a word
638 ;; (csetq ispell-local-dictionary-alist
639 ;; `((nil "[[:alpha:]]" "[^[:alpha:]]"
640 ;; "['\x2019]" nil ("-B") nil utf-8))
641 ;; ispell-program-name (executable-find "hunspell"))
642 ;; ;; don't send ’ to the subprocess
643 ;; (defun endless/replace-apostrophe (args)
644 ;; (cons (replace-regexp-in-string
645 ;; "’" "'" (car args))
647 ;; (advice-add #'ispell-send-string :filter-args
648 ;; #'endless/replace-apostrophe)
649 ;; ;; convert ' back to ’ from the subprocess
650 ;; (defun endless/replace-quote (args)
651 ;; (if (not (derived-mode-p 'org-mode))
653 ;; (cons (replace-regexp-in-string
654 ;; "'" "’" (car args))
656 ;; (advice-add #'ispell-parse-output :filter-args
657 ;; #'endless/replace-quote))
660 (csetq abbrev-file-name
(b/etc
"abbrev.el"))
661 (add-hook 'text-mode-hook
#'abbrev-mode
)
664 ;;; Programming modes
666 (with-eval-after-load 'lisp-mode
667 (defun indent-spaces-mode ()
668 (setq indent-tabs-mode nil
))
669 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
672 (add-to-list 'load-path
(b/lisp
"alloy-mode"))
673 (autoload 'alloy-mode
"alloy-mode" nil t
)
674 (with-eval-after-load 'alloy-mode
675 (csetq alloy-basic-offset
2)
676 ;; (defun b/alloy-simple-indent (start end)
678 ;; ;; (if (region-active-p)
679 ;; ;; (indent-rigidly start end alloy-basic-offset)
681 ;; ;; (indent-rigidly (line-beginning-position)
682 ;; ;; (line-end-position)
683 ;; ;; alloy-basic-offset)))
684 ;; (indent-to (+ (current-column) alloy-basic-offset)))
685 ;; local key bindings
686 (define-key alloy-mode-map
(kbd "RET") #'electric-newline-and-maybe-indent
)
687 ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent)
688 (define-key alloy-mode-map
(kbd "TAB") #'indent-for-tab-command
))
689 (add-to-list 'auto-mode-alist
'("\\.\\(als\\|dsh\\)\\'" . alloy-mode
))
690 (add-hook 'alloy-mode-hook
(lambda nil
(setq-local indent-tabs-mode nil
)))
693 ;; (eval-when-compile (defvar lean-mode-map))
694 ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode)
695 ;; (with-eval-after-load 'lean-mode
696 ;; (require 'lean-input)
697 ;; (csetq default-input-method "Lean"
698 ;; lean-input-tweak-all '(lean-input-compose
699 ;; (lean-input-prepend "/")
700 ;; (lean-input-nonempty))
701 ;; lean-input-user-translations '(("/" "/")))
702 ;; (lean-input-setup)
703 ;; ;; local key bindings
704 ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete))
706 (with-eval-after-load 'sgml-mode
707 (csetq sgml-basic-offset
0))
709 (with-eval-after-load 'css-mode
710 (csetq css-indent-offset
2))
713 ;; (add-hook 'po-mode-hook (lambda nil (run-with-timer 0.1 nil 'View-exit)))
716 ;; (csetq font-latex-fontify-sectioning 'color)
718 (with-eval-after-load 'tex-mode
720 (lambda (p) (string-match "^---?" (car p
)))
721 tex--prettify-symbols-alist
))
722 (add-hook 'tex-mode-hook
#'auto-fill-mode
)
723 (add-hook 'tex-mode-hook
#'flyspell-mode
)
726 ;;; Emacs enhancements & auxiliary packages
728 (with-eval-after-load 'man
729 (csetq Man-width
80))
731 (defun b/*scratch
* ()
732 "Switch to `*scratch*' buffer, creating it if it does not exist."
735 (or (get-buffer "*scratch*")
736 (with-current-buffer (get-buffer-create "*scratch*")
737 (set-buffer-major-mode (current-buffer))
739 (global-set-key (kbd "C-c s") #'b
/*scratch
*)
742 ;; | make pretty boxed quotes like this
744 (add-to-list 'load-path
(b/lisp
"boxquote"))
745 (run-with-idle-timer 0.6 nil
#'require
'boxquote
)
746 (with-eval-after-load 'boxquote
747 (defvar b
/boxquote-prefix-map
)
748 (define-prefix-command 'b
/boxquote-prefix-map
)
749 (global-set-key (kbd "C-c q") 'b
/boxquote-prefix-map
)
750 (define-key b
/boxquote-prefix-map
(kbd "b") #'boxquote-buffer
)
751 (define-key b
/boxquote-prefix-map
(kbd "B") #'boxquote-insert-buffer
)
752 (define-key b
/boxquote-prefix-map
(kbd "d") #'boxquote-defun
)
753 (define-key b
/boxquote-prefix-map
(kbd "F") #'boxquote-insert-file
)
754 (define-key b
/boxquote-prefix-map
(kbd "hf") #'boxquote-describe-function
)
755 (define-key b
/boxquote-prefix-map
(kbd "hk") #'boxquote-describe-key
)
756 (define-key b
/boxquote-prefix-map
(kbd "hv") #'boxquote-describe-variable
)
757 (define-key b
/boxquote-prefix-map
(kbd "hw") #'boxquote-where-is
)
758 (define-key b
/boxquote-prefix-map
(kbd "k") #'boxquote-kill
)
759 (define-key b
/boxquote-prefix-map
(kbd "p") #'boxquote-paragraph
)
760 (define-key b
/boxquote-prefix-map
(kbd "q") #'boxquote-boxquote
)
761 (define-key b
/boxquote-prefix-map
(kbd "r") #'boxquote-region
)
762 (define-key b
/boxquote-prefix-map
(kbd "s") #'boxquote-shell-command
)
763 (define-key b
/boxquote-prefix-map
(kbd "t") #'boxquote-text
)
764 (define-key b
/boxquote-prefix-map
(kbd "T") #'boxquote-title
)
765 (define-key b
/boxquote-prefix-map
(kbd "u") #'boxquote-unbox
)
766 (define-key b
/boxquote-prefix-map
(kbd "U") #'boxquote-unbox-region
)
767 (define-key b
/boxquote-prefix-map
(kbd "y") #'boxquote-yank
)
768 (define-key b
/boxquote-prefix-map
(kbd "M-q") #'boxquote-fill-paragraph
)
769 (define-key b
/boxquote-prefix-map
(kbd "M-w") #'boxquote-kill-ring-save
))
771 (add-to-list 'load-path
(b/lisp
"hl-todo"))
772 (run-with-idle-timer 0.5 nil
#'require
'hl-todo
)
773 (with-eval-after-load 'hl-todo
774 ;; highlight TODOs in buffers
775 (global-hl-todo-mode))
777 (add-to-list 'load-path
(b/lisp
"page-break-lines"))
778 (run-with-idle-timer 0.5 nil
#'require
'page-break-lines
)
779 (with-eval-after-load 'page-break-lines
780 (csetq page-break-lines-max-width fill-column
)
781 (global-page-break-lines-mode))
784 (global-set-key (kbd "C-=") #'er
/expand-region
)
786 (run-with-idle-timer 0.6 nil
#'require
'yasnippet
)
787 (with-eval-after-load 'yasnippet
788 (declare-function yas-reload-all
789 "yasnippet" (&optional no-jit interactive
))
790 (declare-function yas-maybe-expand-abbrev-key-filter
793 (defconst yas-verbosity-cur yas-verbosity
)
794 (setq yas-verbosity
2)
795 (csetq yas-snippet-dirs
`(,(b/etc
"yasnippet/snippets")))
796 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
798 (setq yas-verbosity yas-verbosity-cur
)
800 (defun b/yas-maybe-expand-abbrev-key-filter
(cmd)
801 (when (and (yas-maybe-expand-abbrev-key-filter cmd
)
802 (not (bound-and-true-p git-commit-mode
)))
804 (defconst b
/yas-maybe-expand
805 '(menu-item "" yas-expand
806 :filter b
/yas-maybe-expand-abbrev-key-filter
))
807 (define-key yas-minor-mode-map
(kbd "SPC") b
/yas-maybe-expand
)
812 (global-set-key (kbd "C-c D d") #'debbugs-gnu
)
813 (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs
)
814 (global-set-key (kbd "C-c D e") ; bug-gnu-emacs
817 (setq debbugs-gnu-current-suppress t
)
818 (debbugs-gnu debbugs-gnu-default-severities
820 (global-set-key (kbd "C-c D g") ; bug-gnuzilla
823 (setq debbugs-gnu-current-suppress t
)
824 (debbugs-gnu debbugs-gnu-default-severities
826 (global-set-key (kbd "C-c D G b") ; bug-guix
829 (setq debbugs-gnu-current-suppress t
)
830 (debbugs-gnu debbugs-gnu-default-severities
832 (global-set-key (kbd "C-c D G p") ; guix-patches
835 (setq debbugs-gnu-current-suppress t
)
836 (debbugs-gnu debbugs-gnu-default-severities
841 url-configuration-directory
(b/var
"url/configuration/")
842 url-cache-directory
(b/var
"url/cache/"))
845 (csetq eww-download-directory
(file-name-as-directory
846 (getenv "XDG_DOWNLOAD_DIR")))
847 (global-set-key (kbd "C-c a e w") #'eww
)
851 ;; reftex-default-bibliography '("~/usr/org/references.bib")
852 ;; org-ref-default-bibliography '("~/usr/org/references.bib")
853 ;; org-ref-bibliography-notes "~/usr/org/notes.org"
854 ;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")
856 ;; fill-column-indicator ?
859 (csetq split-width-threshold
150)
860 (global-set-key (kbd "C-c w s l")
865 (global-set-key (kbd "C-c w s j")
870 (global-set-key (kbd "C-c w q") #'quit-window
)
872 (run-with-idle-timer 0.6 nil
#'require
'windmove
)
873 (global-set-key (kbd "C-c w h") #'windmove-left
)
874 (global-set-key (kbd "C-c w j") #'windmove-down
)
875 (global-set-key (kbd "C-c w k") #'windmove-up
)
876 (global-set-key (kbd "C-c w l") #'windmove-right
)
877 (global-set-key (kbd "C-c w H") #'windmove-swap-states-left
)
878 (global-set-key (kbd "C-c w J") #'windmove-swap-states-down
)
879 (global-set-key (kbd "C-c w K") #'windmove-swap-states-up
)
880 (global-set-key (kbd "C-c w L") #'windmove-swap-states-right
)
883 ;; (global-set-key (kbd "C-c a p") #'pass)
884 ;; (add-hook 'pass-mode-hook #'View-exit)
887 ;; uncomment to disable reftex-cite's default choice of previous word
888 ;; (with-eval-after-load 'reftex
889 ;; (require 'reftex-cite)
890 ;; (defun reftex-get-bibkey-default ()
891 ;; "If the cursor is in a citation macro, return the word before the macro."
892 ;; (let* ((macro (reftex-what-macro 1)))
894 ;; (when (and macro (string-match "cite" (car macro)))
895 ;; (goto-char (cdr macro)))
896 ;; (reftex-this-word)))))
897 (add-hook 'latex-mode-hook
#'reftex-mode
)
901 ;; dmenu-prompt-string "run: "
902 ;; dmenu-save-file (b/var "dmenu-items"))
907 (run-with-idle-timer 0.5 nil
#'require
'delight
)
908 (with-eval-after-load 'delight
909 (delight 'auto-fill-function
" f" "simple")
910 (delight 'abbrev-mode
"" "abbrev")
911 (delight 'page-break-lines-mode
"" "page-break-lines")
912 (delight 'ivy-mode
"" "ivy")
913 (delight 'counsel-mode
"" "counsel")
914 (delight 'mml-mode
" mml" "mml")
915 (delight 'yas-minor-mode
"" "yasnippet"))
918 ;;; Post initialization
920 (message "Loading %s...done (%.3fs)" user-init-file
921 (float-time (time-subtract (current-time)
922 b
/before-user-init-time
)))
924 ;;; init.el ends here