1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2022 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 bandali, free software activist,
21 ;; computing scientist, and GNU maintainer and volunteer.
23 ;; Over the years, I've taken inspiration from configurations of many
24 ;; great people. Some that I can remember off the top of my head are:
26 ;; - https://github.com/dieggsy/dotfiles
27 ;; - https://github.com/dakra/dmacs
28 ;; - http://pages.sachachua.com/.emacs.d/Sacha.html
29 ;; - https://github.com/dakrone/eos
30 ;; - http://doc.rix.si/cce/cce.html
31 ;; - https://github.com/jwiegley/dot-emacs
32 ;; - https://github.com/wasamasa/dotemacs
33 ;; - https://github.com/hlissner/doom-emacs
38 (setq user-full-name
"Amin Bandali"
39 user-mail-address
"bandali@gnu.org")
42 ;;; Package management
44 ;; variables of interest:
45 ;; package-archive-priorities
47 ;; package-pinned-packages
49 ;; (let* ((b (find-file-noselect "refinery-theme.el"))
50 ;; (d (with-current-buffer b (package-buffer-info))))
51 ;; (package-generate-description-file d "refinery-theme-pkg.el"))
52 (run-with-idle-timer 0.01 nil
#'require
'package
)
53 (with-eval-after-load 'package
55 ;; ;; package-archives
56 ;; ;; `(,@package-archives
57 ;; ;; ("bndl" . "https://p.bndl.org/elpa/"))
63 ;; (rt-liberation "2.4")))
66 (setq package-archive-upload-base
"/ssh:caffeine:~/www/p/elpa")
71 ;; Keep ~/.emacs.d clean.
74 (convert-standard-filename "etc/") user-emacs-directory
)
75 "The directory where packages place their configuration files.")
78 (convert-standard-filename "var/") user-emacs-directory
)
79 "The directory where packages place their persistent data files.")
82 (convert-standard-filename "lisp/") user-emacs-directory
)
83 "The directory where packages place their persistent data files.")
85 "Expand filename FILE relative to `b/etc-dir'."
86 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
88 "Expand filename FILE relative to `b/var-dir'."
89 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
91 "Expand filename FILE relative to `b/lisp-dir'."
92 (expand-file-name (convert-standard-filename file
) b
/lisp-dir
))
94 ;; Separate custom file (don't want it mixing with init.el).
95 (with-eval-after-load 'custom
96 (setq custom-file
(b/etc
"custom.el"))
97 (when (file-exists-p custom-file
)
99 ;; Only one custom theme at a time.
100 ;; (defadvice load-theme (before clear-previous-themes activate)
101 ;; "Clear existing theme settings instead of layering them"
102 ;; (mapc #'disable-theme custom-enabled-themes))
105 ;; Load the secrets file if it exists, otherwise show a warning.
106 ;; (with-demoted-errors
107 ;; (load (b/etc "secrets")))
109 ;; Start up emacs server:
110 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html
111 (run-with-idle-timer 0.5 nil
#'require
'server
)
112 (with-eval-after-load 'server
113 (declare-function server-edit
"server")
114 (global-set-key (kbd "C-c F D") #'server-edit
)
115 (declare-function server-running-p
"server")
116 (or (server-running-p) (server-mode)))
121 ;;;; C-level customizations
125 completion-ignore-case t
126 read-buffer-completion-ignore-case t
127 enable-recursive-minibuffers t
128 resize-mini-windows t
129 message-log-max
20000
131 ;; mouse-autoselect-window t
132 scroll-conservatively
15
133 scroll-preserve-screen-position
1
134 ;; I don't feel like jumping out of my chair every now and again;
135 ;; so...don't *BEEP* at me, Emacs. =)
136 ring-bell-function
'ignore
)
139 ;; Case-sensitive search (and `dabbrev-expand').
140 ;; case-fold-search nil
141 indent-tabs-mode nil
; always use space for indentation
143 indicate-buffer-boundaries
'left
)
145 ;; Lazy-person-friendly yes/no prompts.
146 (defalias 'yes-or-no-p
#'y-or-n-p
)
148 (when (display-graphic-p)
149 ;; (set-frame-font "Source Code Pro-10.5:weight=medium" nil t)
150 ;; (set-frame-font "FreeSans" nil t)
151 (set-fontset-font t
'arabic
"Vazir"))
153 ;;;; Elisp-level customizations
155 (with-eval-after-load 'minibuffer
156 (setq read-file-name-completion-ignore-case t
))
159 (setq auto-save-list-file-prefix
(b/var
"auto-save/sessions/"))
161 (with-eval-after-load 'files
163 ;; backups (C-h v make-backup-files RET)
165 backup-directory-alist
(list (cons "." (b/var
"backup/")))
167 delete-old-versions t
169 auto-save-file-name-transforms
`((".*" ,(b/var
"auto-save/") t
))
170 ;; insert newline at the end of files
171 ;; require-final-newline t
172 ;; open read-only file buffers in view-mode
173 ;; (enables niceties like `q' for quit)
177 (setq disabled-command-function nil
)
180 ;; (keyboard-translate ?\( ?\[)
181 ;; (keyboard-translate ?\) ?\])
182 ;; (keyboard-translate ?\[ ?\()
183 ;; (keyboard-translate ?\] ?\))
185 (run-with-idle-timer 0.1 nil
#'require
'autorevert
)
186 (with-eval-after-load 'autorevert
188 ;; auto-revert-verbose nil
189 global-auto-revert-non-file-buffers nil
)
190 (global-auto-revert-mode 1))
192 (run-with-idle-timer 0.1 nil
#'require
'time
)
193 (with-eval-after-load 'time
195 display-time-default-load-average nil
196 display-time-format
" %a %b %-e %-l:%M%P"
197 display-time-mail-icon
'(image :type xpm
198 :file
"gnus/gnus-pointer.xpm"
200 display-time-use-mail-icon t
201 zoneinfo-style-world-list
202 `(,@zoneinfo-style-world-list
204 ("Asia/Tehran" "Tehran")
205 ("Australia/Melbourne" "Melbourne")))
208 (run-with-idle-timer 0.1 nil
#'require
'battery
)
209 (with-eval-after-load 'battery
210 (setq battery-mode-line-format
" %p%% %t")
211 (display-battery-mode))
213 ;; (with-eval-after-load 'fringe
215 ;; (fringe-mode '(3 . 1)))
217 (run-with-idle-timer 0.5 nil
#'require
'winner
)
218 (with-eval-after-load 'winner
221 (run-with-idle-timer 0.5 nil
#'require
'windmove
)
222 (with-eval-after-load 'windmove
223 (setq windmove-wrap-around t
)
224 (global-set-key (kbd "M-H") #'windmove-left
)
225 (global-set-key (kbd "M-L") #'windmove-right
)
226 (global-set-key (kbd "M-K") #'windmove-up
)
227 (global-set-key (kbd "M-J") #'windmove-down
))
229 (with-eval-after-load 'compile
230 ;; don't display *compilation* buffer on success. based on
231 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
232 ;; instead of the now obsolete `flet'.
233 (defun b/compilation-finish-function
(buffer outstr
)
234 (unless (string-match "finished" outstr
)
235 (switch-to-buffer-other-window buffer
))
238 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
242 (defadvice compilation-start
243 (around inhibit-display
244 (command &optional mode name-function highlight-regexp
))
245 (if (not (string-match "^\\(find\\|grep\\)" command
))
246 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
247 (save-window-excursion ad-do-it
))
249 (ad-activate 'compilation-start
))
251 (with-eval-after-load 'isearch
253 ;; Allow scrolling in Isearch.
254 isearch-allow-scroll t
256 ;; Search for non-ASCII characters: i’d like non-ASCII characters
257 ;; such as ‘’“”«»‹›áⓐ𝒶 to be selected when I search for their ASCII
258 ;; counterpart. Shoutout to
259 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
260 search-default-mode
#'char-fold-to-regexp
))
262 ;; (with-eval-after-load 'replace
263 ;; ;; Uncomment to extend the above behaviour to query-replace.
264 ;; (setq replace-char-fold t))
267 (global-set-key (kbd "C-x v C-=") #'vc-ediff
)
269 (with-eval-after-load 'vc-git
270 (setq vc-git-print-log-follow t
271 vc-git-show-stash
0))
273 (with-eval-after-load 'ediff
274 (setq ediff-window-setup-function
'ediff-setup-windows-plain
275 ediff-split-window-function
'split-window-horizontally
)
276 (add-hook 'ediff-after-quit-hook-internal
#'winner-undo
))
278 (with-eval-after-load 'face-remap
280 ;; Gentler font resizing.
281 text-scale-mode-step
1.05))
283 (run-with-idle-timer 0.4 nil
#'require
'mwheel
)
284 (with-eval-after-load 'mwheel
286 mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
287 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
288 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
290 (run-with-idle-timer 0.4 nil
#'require
'pixel-scroll
)
291 (with-eval-after-load 'pixel-scroll
292 (pixel-scroll-mode 1))
294 (with-eval-after-load 'epg-config
296 epg-gpg-program
(executable-find "gpg")
297 ;; Ask for GPG passphrase in minibuffer.
298 ;; Will fail if gpg >= 2.1 is not available.
299 epg-pinentry-mode
'loopback
))
301 (with-eval-after-load 'auth-source
303 auth-sources
'("~/.authinfo.gpg")
305 (regexp-opt '("password" "client-secret" "token"))))
307 (with-eval-after-load 'info
310 `(,@Info-directory-list
312 (convert-standard-filename "info/") source-directory
)
313 "/usr/share/info/")))
315 (when (display-graphic-p)
316 (with-eval-after-load 'faces
317 (let ((grey "#e7e7e7"))
318 (set-face-attribute 'fixed-pitch nil
319 :font
"Source Code Pro"
321 (set-face-attribute 'mode-line nil
323 :inherit
'fixed-pitch
))))
325 (when (version< emacs-version
"28")
326 ;; Manually make some `mode-line' spaces smaller. Emacs 28 (and
327 ;; above) does a terrific job at this out of the box when
328 ;; `mode-line-compact' is set to t (see above)."
339 mode-line-buffer-identification
340 (propertized-buffer-identification "%10b")))
345 (defun b/add-elisp-section
()
349 (insert "\n\f\n;;; "))
351 (defun b/insert-asterism
()
352 "Insert a centred asterism."
354 (let ((asterism "* * *"))
359 (floor (/ (- fill-column
(length asterism
)) 2))
364 (defun b/start-process
(program &rest args
)
365 "Same as `start-process', but doesn't bother about name and buffer."
366 (let ((process-name (concat program
"_process"))
367 (buffer-name (generate-new-buffer-name
368 (concat program
"_output"))))
369 (apply #'start-process
370 process-name buffer-name program args
)))
372 (defun b/no-mouse-autoselect-window
()
373 "Conveniently disable `focus-follows-mouse'.
374 For disabling the behaviour for certain buffers and/or modes."
375 (make-local-variable 'mouse-autoselect-window
)
376 (setq mouse-autoselect-window nil
))
378 ;; (defun b/move-indentation-or-beginning-of-line (arg)
379 ;; "Move to the indentation or to the beginning of line."
380 ;; (interactive "^p")
382 ;; ;; (back-to-indentation)
383 ;; ;; (move-beginning-of-line arg))
385 ;; (progn (back-to-indentation)
387 ;; (move-beginning-of-line arg)))
389 (defun b/join-line-top
()
390 "Like `join-line', but join next line to the current line."
394 (defun b/*scratch
* ()
395 "Switch to `*scratch*' buffer, creating it if it does not
398 (let ((fun (if (functionp #'get-scratch-buffer-create
)
399 #'get-scratch-buffer-create
; (version<= "29" emacs-version)
400 #'startup--get-buffer-create-scratch
))) ; (version< emacs-version "29")
401 (switch-to-buffer (funcall fun
))))
403 (defun b/duplicate-line-or-region
(&optional n
)
404 "Duplicate the current line, or region (if active).
405 Make N (default: 1) copies of the current line or region."
407 (let ((u-r-p (use-region-p)) ; if region is active
412 (buffer-substring (region-beginning) (region-end))
413 (prog1 (thing-at-point 'line
)
417 (forward-line 1))))))
418 (dotimes (_ (abs n1
))
421 (defun b/invert-default-face
()
422 "Invert the `default' face (swap its background and foreground).
423 Effectively a very simple light/dark theme toggle switch."
425 (invert-face 'default
(selected-frame))
426 (invert-face 'mode-line
(selected-frame)))
428 (defun b/export-frame
()
430 ;; TODO: ask for fn and/or take as arg
431 (let* ((fn (make-temp-file "emacs" nil
".pdf"))
432 (data (x-export-frames nil
'pdf
)))
439 ;;; General key bindings
441 ;; (global-set-key (kbd "C-a") #'b/move-indentation-or-beginning-of-line)
442 (global-set-key (kbd "C-c i") #'ielm
)
443 (global-set-key (kbd "C-c d") #'b
/duplicate-line-or-region
)
444 (global-set-key (kbd "C-c j") #'b
/join-line-top
)
445 (global-set-key (kbd "C-S-j") #'b
/join-line-top
)
446 (global-set-key (kbd "C-c s c") #'b
/*scratch
*)
447 (global-set-key (kbd "C-c x") #'execute-extended-command
)
448 (global-set-key (kbd "C-c v") #'b
/invert-default-face
)
450 ;; evaling and macro-expanding
451 (global-set-key (kbd "C-c e b") #'eval-buffer
)
452 (global-set-key (kbd "C-c e e") #'eval-last-sexp
)
453 (global-set-key (kbd "C-c e m") #'pp-macroexpand-last-sexp
)
454 (global-set-key (kbd "C-c e r") #'eval-region
)
457 (global-set-key (kbd "C-c e i") #'emacs-init-time
)
458 (global-set-key (kbd "C-c e u") #'emacs-uptime
)
459 (global-set-key (kbd "C-c e v") #'emacs-version
)
462 (global-set-key (kbd "C-c f .") #'find-file
)
463 (global-set-key (kbd "C-c f d") #'find-name-dired
)
464 (global-set-key (kbd "C-c f l") #'find-library
)
465 (global-set-key (kbd "C-c f p") #'find-file-at-point
)
468 (global-set-key (kbd "C-c F m") #'make-frame-command
)
469 (global-set-key (kbd "C-c F d") #'delete-frame
)
472 (global-set-key (kbd "C-S-h F") #'describe-face
)
474 (define-key emacs-lisp-mode-map
(kbd "C-<return>") #'b
/add-elisp-section
)
476 (when (display-graphic-p)
477 (global-unset-key (kbd "C-z")))
480 ;;; Essential packages
485 (convert-standard-filename "lisp") user-emacs-directory
))
487 ;; (require 'bandali-exwm)
489 (require 'bandali-org
)
491 ;; (require 'bandali-theme)
493 ;; recently opened files
494 (run-with-idle-timer 0.2 nil
#'require
'recentf
)
495 (with-eval-after-load 'recentf
497 recentf-max-saved-items
2000
498 recentf-save-file
(b/var
"recentf-save.el"))
499 ;; (add-to-list 'recentf-keep #'file-remote-p)
502 (defun b/recentf-open
()
503 "Use `completing-read' to \\[find-file] a recent file."
506 (completing-read "Find recent file: " recentf-list
)))
507 (global-set-key (kbd "C-c f r") #'b
/recentf-open
))
509 ;; (define-key minibuffer-local-completion-map
510 ;; "\t" #'minibuffer-force-complete)
512 ;; (with-eval-after-load 'icomplete
514 ;; (setq icomplete-on-del-error-function #'abort-recursive-edit)
516 ;; (defun b/icomplete-fido-backward-updir ()
517 ;; "Delete char before or go up directory, like `ido-mode'."
519 ;; (if (and (eq (char-before) ?/)
520 ;; (eq (icomplete--category) 'file))
522 ;; (goto-char (1- (point)))
523 ;; (when (search-backward "/" (point-min) t)
524 ;; (delete-region (1+ (point)) (point-max))))
525 ;; (condition-case nil
526 ;; (call-interactively #'delete-backward-char)
528 ;; (when icomplete-on-del-error-function
529 ;; (funcall icomplete-on-del-error-function))))))
531 ;; (define-key icomplete-fido-mode-map
532 ;; (kbd "DEL") #'b/icomplete-fido-backward-updir))
535 ;; (defun b/icomplete--fido-mode-setup ()
536 ;; "Customizations to `fido-mode''s minibuffer."
537 ;; (when (and icomplete-mode (icomplete-simple-completing-p))
539 ;; ;; icomplete-compute-delay 0.1
540 ;; ;; icomplete-hide-common-prefix t
541 ;; icomplete-separator " · "
542 ;; completion-styles '(basic substring partial-completion flex))))
543 ;; (add-hook 'minibuffer-setup-hook #'b/icomplete--fido-mode-setup 1)
545 (require 'bandali-eshell
)
547 (require 'bandali-ibuffer
)
549 (require 'bandali-dired
)
551 (with-eval-after-load 'help
552 (temp-buffer-resize-mode)
553 (setq help-window-select t
))
555 (with-eval-after-load 'help-mode
556 (define-key help-mode-map
(kbd "p") #'backward-button
)
557 (define-key help-mode-map
(kbd "n") #'forward-button
))
559 (with-eval-after-load 'tramp
560 (setq tramp-auto-save-directory
(b/var
"tramp/auto-save/")
561 tramp-persistency-file-name
(b/var
"tramp/persistency.el"))
562 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
563 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
564 (add-to-list 'tramp-default-proxies-alist
565 (list (regexp-quote (system-name)) nil nil
)))
567 (with-eval-after-load 'doc-view
568 (define-key doc-view-mode-map
(kbd "M-RET") #'image-previous-line
))
570 (setq shr-max-width
80)
572 ;; Email (with Gnus, message, and smtpmail)
573 (require 'bandali-gnus
)
574 (require 'bandali-message
)
575 ;; (with-eval-after-load 'smtpmail
576 ;; (setq smtpmail-queue-mail t
577 ;; smtpmail-queue-dir (concat b/maildir "queue/")))
580 (require 'bandali-erc
)
582 ;; 'paste' service (aka scp + web server)
583 (add-to-list 'load-path
(b/lisp
"scpaste"))
584 (with-eval-after-load 'scpaste
585 (setq scpaste-http-destination
"https://p.bndl.org"
586 scpaste-scp-destination
"p:~"))
587 (autoload 'scpaste
"scpaste" nil t
)
588 (autoload 'scpaste-region
"scpaste" nil t
)
589 (global-set-key (kbd "C-c p p") #'scpaste
)
590 (global-set-key (kbd "C-c p r") #'scpaste-region
)
595 (when (featurep 'eldoc
)
596 ;; Display Lisp objects at point in the echo area.
597 (with-eval-after-load 'eldoc
598 (setq eldoc-minor-mode-string
" eldoc")
599 (global-eldoc-mode)))
601 ;; highlight matching parens
602 (run-with-idle-timer 0.2 nil
#'require
'paren
)
603 (with-eval-after-load 'paren
606 (run-with-idle-timer 0.2 nil
#'require
'elec-pair
)
607 (with-eval-after-load 'elec-pair
608 (electric-pair-mode))
610 (with-eval-after-load 'simple
612 ;; Save what I copy into clipboard from other applications into Emacs'
613 ;; kill-ring, which would allow me to still be able to easily access
614 ;; it in case I kill (cut or copy) something else inside Emacs before
615 ;; yanking (pasting) what I'd originally intended to.
616 save-interprogram-paste-before-kill t
)
617 (column-number-mode 1)
618 (line-number-mode 1))
620 (run-with-idle-timer 0.2 nil
#'require
'savehist
)
621 (with-eval-after-load 'savehist
622 ;; Save minibuffer history.
623 (setq savehist-file
(b/var
"savehist.el"))
625 (add-to-list 'savehist-additional-variables
'kill-ring
))
627 ;; Automatically save place in files.
628 (run-with-idle-timer 0.2 nil
#'require
'saveplace nil
'noerror
)
629 (with-eval-after-load 'saveplace
630 (setq save-place-file
(b/var
"save-place.el"))
633 (with-eval-after-load 'prog-mode
634 (global-prettify-symbols-mode))
636 (add-to-list 'auto-mode-alist
'("\\.*rc$" . conf-mode
))
637 (add-to-list 'auto-mode-alist
'("\\.bashrc$" . sh-mode
))
639 (with-eval-after-load 'flyspell
640 (setq flyspell-mode-line-string
" fly"))
642 (with-eval-after-load 'text-mode
643 (add-hook 'text-mode-hook
#'flyspell-mode
)
644 (define-key text-mode-map
(kbd "C-<return>") #'b
/insert-asterism
))
646 ;; ;; http://endlessparentheses.com/ispell-and-apostrophes.html
647 ;; (run-with-idle-timer 0.6 nil #'require 'ispell)
648 ;; (with-eval-after-load 'ispell
649 ;; ;; ’ can be part of a word.
650 ;; (setq ispell-local-dictionary-alist
651 ;; `((nil "[[:alpha:]]" "[^[:alpha:]]"
652 ;; "['\x2019]" nil ("-B") nil utf-8))
653 ;; ispell-program-name (executable-find "hunspell"))
654 ;; ;; Don't send ’ to the subprocess.
655 ;; (defun endless/replace-apostrophe (args)
656 ;; (cons (replace-regexp-in-string
657 ;; "’" "'" (car args))
659 ;; (advice-add #'ispell-send-string :filter-args
660 ;; #'endless/replace-apostrophe)
661 ;; ;; Convert ' back to ’ from the subprocess.
662 ;; (defun endless/replace-quote (args)
663 ;; (if (not (derived-mode-p 'org-mode))
665 ;; (cons (replace-regexp-in-string
666 ;; "'" "’" (car args))
668 ;; (advice-add #'ispell-parse-output :filter-args
669 ;; #'endless/replace-quote))
671 (with-eval-after-load 'abbrev
672 (setq abbrev-file-name
(b/etc
"abbrev.el")))
673 (add-hook 'text-mode-hook
#'abbrev-mode
)
676 ;;; Programming modes
678 (with-eval-after-load 'lisp-mode
679 (defun indent-spaces-mode ()
680 (setq indent-tabs-mode nil
))
681 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
683 (add-to-list 'load-path
(b/lisp
"alloy-mode"))
684 (autoload 'alloy-mode
"alloy-mode" nil t
)
685 (with-eval-after-load 'alloy-mode
686 (setq alloy-basic-offset
2)
687 ;; (defun b/alloy-simple-indent (start end)
689 ;; ;; (if (region-active-p)
690 ;; ;; (indent-rigidly start end alloy-basic-offset)
692 ;; ;; (indent-rigidly (line-beginning-position)
693 ;; ;; (line-end-position)
694 ;; ;; alloy-basic-offset)))
695 ;; (indent-to (+ (current-column) alloy-basic-offset)))
696 (define-key alloy-mode-map
(kbd "RET") #'electric-newline-and-maybe-indent
)
697 ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent)
698 (define-key alloy-mode-map
(kbd "TAB") #'indent-for-tab-command
))
699 (add-to-list 'auto-mode-alist
'("\\.\\(als\\|dsh\\)\\'" . alloy-mode
))
700 (add-hook 'alloy-mode-hook
(lambda nil
(setq-local indent-tabs-mode nil
)))
702 ;; (eval-when-compile (defvar lean-mode-map))
703 ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode)
704 ;; (with-eval-after-load 'lean-mode
705 ;; (require 'lean-input)
706 ;; (setq default-input-method "Lean"
707 ;; lean-input-tweak-all '(lean-input-compose
708 ;; (lean-input-prepend "/")
709 ;; (lean-input-nonempty))
710 ;; lean-input-user-translations '(("/" "/")))
711 ;; (lean-input-setup)
712 ;; ;; local key bindings
713 ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete))
715 (with-eval-after-load 'sgml-mode
716 (setq sgml-basic-offset
0))
718 (with-eval-after-load 'css-mode
719 (setq css-indent-offset
2))
721 ;; (with-eval-after-load 'auctex
722 ;; (setq font-latex-fontify-sectioning 'color))
724 (with-eval-after-load 'tex-mode
726 (lambda (p) (string-match "^---?" (car p
)))
727 tex--prettify-symbols-alist
))
728 (add-hook 'tex-mode-hook
#'auto-fill-mode
)
729 (add-hook 'tex-mode-hook
#'flyspell-mode
)
731 (run-with-idle-timer 0.5 nil
#'require
'cmake-mode
)
732 (with-eval-after-load 'cmake-mode
733 ;; (setq cmake-tab-width 4)
734 (add-to-list 'load-path
(b/lisp
"cmake-font-lock"))
735 (run-with-idle-timer 0.5 nil
#'require
'cmake-font-lock
))
738 ;;; Emacs enhancements & auxiliary packages
740 (with-eval-after-load 'nsm
741 (setq nsm-settings-file
(b/var
"nsm-settings.el")))
743 (with-eval-after-load 'man
747 ;; | make pretty boxed quotes like this
749 (run-with-idle-timer 0.6 nil
#'require
'boxquote
)
750 (with-eval-after-load 'boxquote
751 (defvar b
/boxquote-prefix-map
)
752 (define-prefix-command 'b
/boxquote-prefix-map
)
753 (global-set-key (kbd "C-c q") 'b
/boxquote-prefix-map
)
754 (define-key b
/boxquote-prefix-map
(kbd "b") #'boxquote-buffer
)
755 (define-key b
/boxquote-prefix-map
(kbd "B") #'boxquote-insert-buffer
)
756 (define-key b
/boxquote-prefix-map
(kbd "d") #'boxquote-defun
)
757 (define-key b
/boxquote-prefix-map
(kbd "F") #'boxquote-insert-file
)
758 (define-key b
/boxquote-prefix-map
(kbd "hf") #'boxquote-describe-function
)
759 (define-key b
/boxquote-prefix-map
(kbd "hk") #'boxquote-describe-key
)
760 (define-key b
/boxquote-prefix-map
(kbd "hv") #'boxquote-describe-variable
)
761 (define-key b
/boxquote-prefix-map
(kbd "hw") #'boxquote-where-is
)
762 (define-key b
/boxquote-prefix-map
(kbd "k") #'boxquote-kill
)
763 (define-key b
/boxquote-prefix-map
(kbd "p") #'boxquote-paragraph
)
764 (define-key b
/boxquote-prefix-map
(kbd "q") #'boxquote-boxquote
)
765 (define-key b
/boxquote-prefix-map
(kbd "r") #'boxquote-region
)
766 (define-key b
/boxquote-prefix-map
(kbd "s") #'boxquote-shell-command
)
767 (define-key b
/boxquote-prefix-map
(kbd "t") #'boxquote-text
)
768 (define-key b
/boxquote-prefix-map
(kbd "T") #'boxquote-title
)
769 (define-key b
/boxquote-prefix-map
(kbd "u") #'boxquote-unbox
)
770 (define-key b
/boxquote-prefix-map
(kbd "U") #'boxquote-unbox-region
)
771 (define-key b
/boxquote-prefix-map
(kbd "y") #'boxquote-yank
)
772 (define-key b
/boxquote-prefix-map
(kbd "M-q") #'boxquote-fill-paragraph
)
773 (define-key b
/boxquote-prefix-map
(kbd "M-w") #'boxquote-kill-ring-save
))
775 (add-to-list 'load-path
(b/lisp
"hl-todo"))
776 (run-with-idle-timer 0.5 nil
#'require
'hl-todo
)
777 (with-eval-after-load 'hl-todo
778 ;; Highlight TODO in buffers.
779 (global-hl-todo-mode))
782 (global-set-key (kbd "C-c D d") #'debbugs-gnu
)
783 (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs
)
784 (global-set-key (kbd "C-c D e") ; bug-gnu-emacs
787 (setq debbugs-gnu-current-suppress t
)
788 (debbugs-gnu debbugs-gnu-default-severities
790 (global-set-key (kbd "C-c D g") ; bug-gnuzilla
793 (setq debbugs-gnu-current-suppress t
)
794 (debbugs-gnu debbugs-gnu-default-severities
797 (with-eval-after-load 'url
798 (setq url-configuration-directory
(b/var
"url/configuration/")))
800 (with-eval-after-load 'url-cache
801 (setq url-cache-directory
(b/var
"url/cache/")))
803 (with-eval-after-load 'eww
805 eww-download-directory
806 (file-name-as-directory (getenv "XDG_DOWNLOAD_DIR"))))
807 (global-set-key (kbd "C-c e w") #'eww
)
809 ;; (with-eval-after-load 'org-ref
811 ;; reftex-default-bibliography '("~/usr/org/references.bib")
812 ;; org-ref-default-bibliography '("~/usr/org/references.bib")
813 ;; org-ref-bibliography-notes "~/usr/org/notes.org"
814 ;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
817 0.2 nil
#'require
'display-fill-column-indicator nil
'noerror
)
818 (with-eval-after-load 'display-fill-column-indicator
819 (global-display-fill-column-indicator-mode 1))
821 (with-eval-after-load 'window
822 (setq split-width-threshold
150)
823 (global-set-key (kbd "C-c w s l")
828 (global-set-key (kbd "C-c w s j")
833 (global-set-key (kbd "C-c w q") #'quit-window
))
835 ;; Uncomment to disable reftex-cite's default choice of previous word.
836 ;; (with-eval-after-load 'reftex
837 ;; (require 'reftex-cite)
838 ;; (defun reftex-get-bibkey-default ()
839 ;; "If the cursor is in a citation macro, return the word before
841 ;; (let* ((macro (reftex-what-macro 1)))
843 ;; (when (and macro (string-match "cite" (car macro)))
844 ;; (goto-char (cdr macro)))
845 ;; (reftex-this-word)))))
846 (add-hook 'latex-mode-hook
#'reftex-mode
)
848 (add-to-list 'load-path
(b/lisp
"dmenu"))
849 (with-eval-after-load 'dmenu
850 (setq dmenu-prompt-string
"run: "
851 dmenu-save-file
(b/var
"dmenu-items")))
852 (autoload 'dmenu
"dmenu" nil t
)
854 (run-with-idle-timer 0.5 nil
#'require
'delight
)
855 (with-eval-after-load 'delight
856 (delight 'auto-fill-function
" f" "simple")
857 (delight 'abbrev-mode
"" "abbrev")
858 (delight 'mml-mode
" mml" "mml"))
860 (require 'bandali-po
)
862 (with-eval-after-load 'emms
863 (setq emms-directory
(b/var
"emms")))
865 (add-to-list 'load-path
(b/lisp
"ffs"))
866 (run-with-idle-timer 0.5 nil
#'require
'ffs
)
867 (with-eval-after-load 'ffs
868 (global-set-key (kbd "C-c f s") #'ffs
))
870 ;;; init.el ends here