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-fontset-font t
'arabic
"Vazir"))
150 ;; ;; (set-frame-font "Drafting Mono-14:weight=light" nil t)
151 ;; (set-frame-font "Drafting Mono:pixelsize=16" nil t)
152 ;; (set-face-attribute 'bold nil :weight 'semi-bold)
154 ;;;; Elisp-level customizations
156 (with-eval-after-load 'minibuffer
157 (setq read-file-name-completion-ignore-case t
))
160 (setq auto-save-list-file-prefix
(b/var
"auto-save/sessions/"))
162 (with-eval-after-load 'files
164 ;; backups (C-h v make-backup-files RET)
166 backup-directory-alist
(list (cons "." (b/var
"backup/")))
168 delete-old-versions t
170 auto-save-file-name-transforms
`((".*" ,(b/var
"auto-save/") t
))
171 ;; insert newline at the end of files
172 ;; require-final-newline t
173 ;; open read-only file buffers in view-mode
174 ;; (enables niceties like `q' for quit)
178 (setq disabled-command-function nil
)
181 ;; (keyboard-translate ?\( ?\[)
182 ;; (keyboard-translate ?\) ?\])
183 ;; (keyboard-translate ?\[ ?\()
184 ;; (keyboard-translate ?\] ?\))
186 (run-with-idle-timer 0.1 nil
#'require
'autorevert
)
187 (with-eval-after-load 'autorevert
189 ;; auto-revert-verbose nil
190 global-auto-revert-non-file-buffers nil
)
191 (global-auto-revert-mode 1))
193 (run-with-idle-timer 0.1 nil
#'require
'time
)
194 (with-eval-after-load 'time
196 display-time-default-load-average nil
197 display-time-format
" %a %b %-e %-l:%M%P"
198 display-time-mail-icon
'(image :type xpm
199 :file
"gnus/gnus-pointer.xpm"
201 display-time-use-mail-icon t
202 zoneinfo-style-world-list
203 `(,@zoneinfo-style-world-list
205 ("Asia/Tehran" "Tehran")
206 ("Australia/Melbourne" "Melbourne")))
209 (run-with-idle-timer 0.1 nil
#'require
'battery
)
210 (with-eval-after-load 'battery
211 (setq battery-mode-line-format
" %p%% %t")
212 (display-battery-mode))
214 ;; (with-eval-after-load 'fringe
216 ;; (fringe-mode '(3 . 1)))
218 (run-with-idle-timer 0.5 nil
#'require
'winner
)
219 (with-eval-after-load 'winner
222 (run-with-idle-timer 0.5 nil
#'require
'windmove
)
223 (with-eval-after-load 'windmove
224 (setq windmove-wrap-around t
)
225 (global-set-key (kbd "M-H") #'windmove-left
)
226 (global-set-key (kbd "M-L") #'windmove-right
)
227 (global-set-key (kbd "M-K") #'windmove-up
)
228 (global-set-key (kbd "M-J") #'windmove-down
))
230 (with-eval-after-load 'compile
231 ;; don't display *compilation* buffer on success. based on
232 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
233 ;; instead of the now obsolete `flet'.
234 (defun b/compilation-finish-function
(buffer outstr
)
235 (unless (string-match "finished" outstr
)
236 (switch-to-buffer-other-window buffer
))
239 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
243 (defadvice compilation-start
244 (around inhibit-display
245 (command &optional mode name-function highlight-regexp
))
246 (if (not (string-match "^\\(find\\|grep\\)" command
))
247 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
248 (save-window-excursion ad-do-it
))
250 (ad-activate 'compilation-start
))
252 (with-eval-after-load 'isearch
254 ;; Allow scrolling in Isearch.
255 isearch-allow-scroll t
257 ;; Search for non-ASCII characters: i’d like non-ASCII characters
258 ;; such as ‘’“”«»‹›áⓐ𝒶 to be selected when I search for their ASCII
259 ;; counterpart. Shoutout to
260 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
261 search-default-mode
#'char-fold-to-regexp
))
263 ;; (with-eval-after-load 'replace
264 ;; ;; Uncomment to extend the above behaviour to query-replace.
265 ;; (setq replace-char-fold t))
268 (global-set-key (kbd "C-x v C-=") #'vc-ediff
)
270 (with-eval-after-load 'vc-git
271 (setq vc-git-print-log-follow t
272 vc-git-show-stash
0))
274 (with-eval-after-load 'ediff
275 (setq ediff-window-setup-function
'ediff-setup-windows-plain
276 ediff-split-window-function
'split-window-horizontally
)
277 (add-hook 'ediff-after-quit-hook-internal
#'winner-undo
))
279 (with-eval-after-load 'face-remap
281 ;; Gentler font resizing.
282 text-scale-mode-step
1.05))
284 (run-with-idle-timer 0.4 nil
#'require
'mwheel
)
285 (with-eval-after-load 'mwheel
287 mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
288 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
289 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
291 (run-with-idle-timer 0.4 nil
#'require
'pixel-scroll
)
292 (with-eval-after-load 'pixel-scroll
293 (pixel-scroll-mode 1))
295 (with-eval-after-load 'epg-config
297 epg-gpg-program
(executable-find "gpg")
298 ;; Ask for GPG passphrase in minibuffer.
299 ;; Will fail if gpg >= 2.1 is not available.
300 epg-pinentry-mode
'loopback
))
302 (with-eval-after-load 'auth-source
304 auth-sources
'("~/.authinfo.gpg")
306 (regexp-opt '("password" "client-secret" "token"))))
308 (with-eval-after-load 'info
311 `(,@Info-directory-list
313 (convert-standard-filename "info/") source-directory
)
314 "/usr/share/info/")))
316 (when (display-graphic-p)
317 (with-eval-after-load 'faces
318 (let ((grey "#e7e7e7"))
319 (set-face-attribute 'fixed-pitch nil
:family
"Source Code Pro")
320 (set-face-attribute 'mode-line nil
322 :inherit
'fixed-pitch
))))
324 (when (version< emacs-version
"28")
325 ;; Manually make some `mode-line' spaces smaller. Emacs 28 (and
326 ;; above) does a terrific job at this out of the box when
327 ;; `mode-line-compact' is set to t (see above)."
338 mode-line-buffer-identification
339 (propertized-buffer-identification "%10b")))
344 (defun b/add-elisp-section
()
348 (insert "\n\f\n;;; "))
350 (defun b/insert-asterism
()
351 "Insert a centred asterism."
353 (let ((asterism "* * *"))
358 (floor (/ (- fill-column
(length asterism
)) 2))
363 (defun b/start-process
(program &rest args
)
364 "Same as `start-process', but doesn't bother about name and buffer."
365 (let ((process-name (concat program
"_process"))
366 (buffer-name (generate-new-buffer-name
367 (concat program
"_output"))))
368 (apply #'start-process
369 process-name buffer-name program args
)))
371 (defun b/no-mouse-autoselect-window
()
372 "Conveniently disable `focus-follows-mouse'.
373 For disabling the behaviour for certain buffers and/or modes."
374 (make-local-variable 'mouse-autoselect-window
)
375 (setq mouse-autoselect-window nil
))
377 (defun b/move-indentation-or-beginning-of-line
(arg)
378 "Move to the indentation or to the beginning of line."
381 ;; (back-to-indentation)
382 ;; (move-beginning-of-line arg))
384 (progn (back-to-indentation)
386 (move-beginning-of-line arg
)))
388 (defun b/join-line-top
()
389 "Like `join-line', but join next line to the current line."
393 (defun b/*scratch
* ()
394 "Switch to `*scratch*' buffer, creating it if it does not
397 (let ((fun (if (functionp #'get-scratch-buffer-create
)
398 #'get-scratch-buffer-create
; (version<= "29" emacs-version)
399 #'startup--get-buffer-create-scratch
))) ; (version< emacs-version "29")
400 (switch-to-buffer (funcall fun
))))
402 (defun b/duplicate-line-or-region
(&optional n
)
403 "Duplicate the current line, or region (if active).
404 Make N (default: 1) copies of the current line or region."
406 (let ((u-r-p (use-region-p)) ; if region is active
411 (buffer-substring (region-beginning) (region-end))
412 (prog1 (thing-at-point 'line
)
416 (forward-line 1))))))
417 (dotimes (_ (abs n1
))
420 (defun b/invert-default-face
()
421 "Invert the `default' face (swap its background and foreground).
422 Effectively a very simple light/dark theme toggle switch."
424 (invert-face 'default
(selected-frame))
425 (invert-face 'mode-line
(selected-frame)))
427 (defun b/export-frame
()
429 ;; TODO: ask for fn and/or take as arg
430 (let* ((fn (make-temp-file "emacs" nil
".pdf"))
431 (data (x-export-frames nil
'pdf
)))
438 ;;; General key bindings
440 (global-set-key (kbd "C-a") #'b
/move-indentation-or-beginning-of-line
)
441 (global-set-key (kbd "C-c i") #'ielm
)
442 (global-set-key (kbd "C-c d") #'b
/duplicate-line-or-region
)
443 (global-set-key (kbd "C-c j") #'b
/join-line-top
)
444 (global-set-key (kbd "C-S-j") #'b
/join-line-top
)
445 (global-set-key (kbd "C-c s c") #'b
/*scratch
*)
446 (global-set-key (kbd "C-c x") #'execute-extended-command
)
447 (global-set-key (kbd "C-c v") #'b
/invert-default-face
)
449 ;; evaling and macro-expanding
450 (global-set-key (kbd "C-c e b") #'eval-buffer
)
451 (global-set-key (kbd "C-c e e") #'eval-last-sexp
)
452 (global-set-key (kbd "C-c e m") #'pp-macroexpand-last-sexp
)
453 (global-set-key (kbd "C-c e r") #'eval-region
)
456 (global-set-key (kbd "C-c e i") #'emacs-init-time
)
457 (global-set-key (kbd "C-c e u") #'emacs-uptime
)
458 (global-set-key (kbd "C-c e v") #'emacs-version
)
461 (global-set-key (kbd "C-c f .") #'find-file
)
462 (global-set-key (kbd "C-c f d") #'find-name-dired
)
463 (global-set-key (kbd "C-c f l") #'find-library
)
464 (global-set-key (kbd "C-c f p") #'find-file-at-point
)
467 (global-set-key (kbd "C-c F m") #'make-frame-command
)
468 (global-set-key (kbd "C-c F d") #'delete-frame
)
471 (global-set-key (kbd "C-S-h F") #'describe-face
)
473 (define-key emacs-lisp-mode-map
(kbd "C-<return>") #'b
/add-elisp-section
)
475 (when (display-graphic-p)
476 (global-unset-key (kbd "C-z")))
479 ;;; Essential packages
484 (convert-standard-filename "lisp") user-emacs-directory
))
486 ;; (require 'bandali-exwm)
488 (require 'bandali-org
)
490 ;; (require 'bandali-theme)
492 ;; recently opened files
493 (run-with-idle-timer 0.2 nil
#'require
'recentf
)
494 (with-eval-after-load 'recentf
496 recentf-max-saved-items
2000
497 recentf-save-file
(b/var
"recentf-save.el"))
498 ;; (add-to-list 'recentf-keep #'file-remote-p)
501 (defun b/recentf-open
()
502 "Use `completing-read' to \\[find-file] a recent file."
505 (completing-read "Find recent file: " recentf-list
)))
506 (global-set-key (kbd "C-c f r") #'b
/recentf-open
))
508 ;; (define-key minibuffer-local-completion-map
509 ;; "\t" #'minibuffer-force-complete)
511 ;; (with-eval-after-load 'icomplete
513 ;; (setq icomplete-on-del-error-function #'abort-recursive-edit)
515 ;; (defun b/icomplete-fido-backward-updir ()
516 ;; "Delete char before or go up directory, like `ido-mode'."
518 ;; (if (and (eq (char-before) ?/)
519 ;; (eq (icomplete--category) 'file))
521 ;; (goto-char (1- (point)))
522 ;; (when (search-backward "/" (point-min) t)
523 ;; (delete-region (1+ (point)) (point-max))))
524 ;; (condition-case nil
525 ;; (call-interactively #'delete-backward-char)
527 ;; (when icomplete-on-del-error-function
528 ;; (funcall icomplete-on-del-error-function))))))
530 ;; (define-key icomplete-fido-mode-map
531 ;; (kbd "DEL") #'b/icomplete-fido-backward-updir))
534 ;; (defun b/icomplete--fido-mode-setup ()
535 ;; "Customizations to `fido-mode''s minibuffer."
536 ;; (when (and icomplete-mode (icomplete-simple-completing-p))
538 ;; ;; icomplete-compute-delay 0.1
539 ;; ;; icomplete-hide-common-prefix t
540 ;; icomplete-separator " · "
541 ;; completion-styles '(basic substring partial-completion flex))))
542 ;; (add-hook 'minibuffer-setup-hook #'b/icomplete--fido-mode-setup 1)
544 (require 'bandali-eshell
)
546 (require 'bandali-ibuffer
)
548 (require 'bandali-dired
)
550 (with-eval-after-load 'help
551 (temp-buffer-resize-mode)
552 (setq help-window-select t
))
554 (with-eval-after-load 'help-mode
555 (define-key help-mode-map
(kbd "p") #'backward-button
)
556 (define-key help-mode-map
(kbd "n") #'forward-button
))
558 (with-eval-after-load 'tramp
559 (setq tramp-auto-save-directory
(b/var
"tramp/auto-save/")
560 tramp-persistency-file-name
(b/var
"tramp/persistency.el"))
561 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
562 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
563 (add-to-list 'tramp-default-proxies-alist
564 (list (regexp-quote (system-name)) nil nil
)))
566 (with-eval-after-load 'doc-view
567 (define-key doc-view-mode-map
(kbd "M-RET") #'image-previous-line
))
569 (setq shr-max-width
80)
571 ;; Email (with Gnus, message, and smtpmail)
572 (require 'bandali-gnus
)
573 (require 'bandali-message
)
574 ;; (with-eval-after-load 'smtpmail
575 ;; (setq smtpmail-queue-mail t
576 ;; smtpmail-queue-dir (concat b/maildir "queue/")))
579 (require 'bandali-erc
)
581 ;; 'paste' service (aka scp + web server)
582 (add-to-list 'load-path
(b/lisp
"scpaste"))
583 (with-eval-after-load 'scpaste
584 (setq scpaste-http-destination
"https://p.bndl.org"
585 scpaste-scp-destination
"p:~"))
586 (autoload 'scpaste
"scpaste" nil t
)
587 (autoload 'scpaste-region
"scpaste" nil t
)
588 (global-set-key (kbd "C-c p p") #'scpaste
)
589 (global-set-key (kbd "C-c p r") #'scpaste-region
)
594 (when (featurep 'eldoc
)
595 ;; Display Lisp objects at point in the echo area.
596 (with-eval-after-load 'eldoc
597 (setq eldoc-minor-mode-string
" eldoc")
598 (global-eldoc-mode)))
600 ;; highlight matching parens
601 (run-with-idle-timer 0.2 nil
#'require
'paren
)
602 (with-eval-after-load 'paren
605 ;; (run-with-idle-timer 0.2 nil #'require 'elec-pair)
606 ;; (with-eval-after-load 'elec-pair
607 ;; (electric-pair-mode))
609 (with-eval-after-load 'simple
611 ;; Save what I copy into clipboard from other applications into Emacs'
612 ;; kill-ring, which would allow me to still be able to easily access
613 ;; it in case I kill (cut or copy) something else inside Emacs before
614 ;; yanking (pasting) what I'd originally intended to.
615 save-interprogram-paste-before-kill t
)
616 (column-number-mode 1)
617 (line-number-mode 1))
619 (run-with-idle-timer 0.2 nil
#'require
'savehist
)
620 (with-eval-after-load 'savehist
621 ;; Save minibuffer history.
622 (setq savehist-file
(b/var
"savehist.el"))
624 (add-to-list 'savehist-additional-variables
'kill-ring
))
626 ;; Automatically save place in files.
627 (run-with-idle-timer 0.2 nil
#'require
'saveplace nil
'noerror
)
628 (with-eval-after-load 'saveplace
629 (setq save-place-file
(b/var
"save-place.el"))
632 (with-eval-after-load 'prog-mode
633 (global-prettify-symbols-mode))
635 (add-to-list 'auto-mode-alist
'("\\.*rc$" . conf-mode
))
636 (add-to-list 'auto-mode-alist
'("\\.bashrc$" . sh-mode
))
638 (with-eval-after-load 'flyspell
639 (setq flyspell-mode-line-string
" fly"))
641 (with-eval-after-load 'text-mode
642 (add-hook 'text-mode-hook
#'flyspell-mode
)
643 (define-key text-mode-map
(kbd "C-<return>") #'b
/insert-asterism
))
645 ;; ;; http://endlessparentheses.com/ispell-and-apostrophes.html
646 ;; (run-with-idle-timer 0.6 nil #'require 'ispell)
647 ;; (with-eval-after-load 'ispell
648 ;; ;; ’ can be part of a word.
649 ;; (setq ispell-local-dictionary-alist
650 ;; `((nil "[[:alpha:]]" "[^[:alpha:]]"
651 ;; "['\x2019]" nil ("-B") nil utf-8))
652 ;; ispell-program-name (executable-find "hunspell"))
653 ;; ;; Don't send ’ to the subprocess.
654 ;; (defun endless/replace-apostrophe (args)
655 ;; (cons (replace-regexp-in-string
656 ;; "’" "'" (car args))
658 ;; (advice-add #'ispell-send-string :filter-args
659 ;; #'endless/replace-apostrophe)
660 ;; ;; Convert ' back to ’ from the subprocess.
661 ;; (defun endless/replace-quote (args)
662 ;; (if (not (derived-mode-p 'org-mode))
664 ;; (cons (replace-regexp-in-string
665 ;; "'" "’" (car args))
667 ;; (advice-add #'ispell-parse-output :filter-args
668 ;; #'endless/replace-quote))
670 (with-eval-after-load 'abbrev
671 (setq abbrev-file-name
(b/etc
"abbrev.el")))
672 (add-hook 'text-mode-hook
#'abbrev-mode
)
675 ;;; Programming modes
677 (with-eval-after-load 'lisp-mode
678 (defun indent-spaces-mode ()
679 (setq indent-tabs-mode nil
))
680 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
682 (add-to-list 'load-path
(b/lisp
"alloy-mode"))
683 (autoload 'alloy-mode
"alloy-mode" nil t
)
684 (with-eval-after-load 'alloy-mode
685 (setq alloy-basic-offset
2)
686 ;; (defun b/alloy-simple-indent (start end)
688 ;; ;; (if (region-active-p)
689 ;; ;; (indent-rigidly start end alloy-basic-offset)
691 ;; ;; (indent-rigidly (line-beginning-position)
692 ;; ;; (line-end-position)
693 ;; ;; alloy-basic-offset)))
694 ;; (indent-to (+ (current-column) alloy-basic-offset)))
695 (define-key alloy-mode-map
(kbd "RET") #'electric-newline-and-maybe-indent
)
696 ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent)
697 (define-key alloy-mode-map
(kbd "TAB") #'indent-for-tab-command
))
698 (add-to-list 'auto-mode-alist
'("\\.\\(als\\|dsh\\)\\'" . alloy-mode
))
699 (add-hook 'alloy-mode-hook
(lambda nil
(setq-local indent-tabs-mode nil
)))
701 ;; (eval-when-compile (defvar lean-mode-map))
702 ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode)
703 ;; (with-eval-after-load 'lean-mode
704 ;; (require 'lean-input)
705 ;; (setq default-input-method "Lean"
706 ;; lean-input-tweak-all '(lean-input-compose
707 ;; (lean-input-prepend "/")
708 ;; (lean-input-nonempty))
709 ;; lean-input-user-translations '(("/" "/")))
710 ;; (lean-input-setup)
711 ;; ;; local key bindings
712 ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete))
714 (with-eval-after-load 'sgml-mode
715 (setq sgml-basic-offset
0))
717 (with-eval-after-load 'css-mode
718 (setq css-indent-offset
2))
720 ;; (with-eval-after-load 'auctex
721 ;; (setq font-latex-fontify-sectioning 'color))
723 (with-eval-after-load 'tex-mode
725 (lambda (p) (string-match "^---?" (car p
)))
726 tex--prettify-symbols-alist
))
727 (add-hook 'tex-mode-hook
#'auto-fill-mode
)
728 (add-hook 'tex-mode-hook
#'flyspell-mode
)
730 (run-with-idle-timer 0.5 nil
#'require
'cmake-mode
)
731 (with-eval-after-load 'cmake-mode
732 ;; (setq cmake-tab-width 4)
733 (add-to-list 'load-path
(b/lisp
"cmake-font-lock"))
734 (run-with-idle-timer 0.5 nil
#'require
'cmake-font-lock
))
737 ;;; Emacs enhancements & auxiliary packages
739 (with-eval-after-load 'nsm
740 (setq nsm-settings-file
(b/var
"nsm-settings.el")))
742 (with-eval-after-load 'man
746 ;; | make pretty boxed quotes like this
748 (run-with-idle-timer 0.6 nil
#'require
'boxquote
)
749 (with-eval-after-load 'boxquote
750 (defvar b
/boxquote-prefix-map
)
751 (define-prefix-command 'b
/boxquote-prefix-map
)
752 (global-set-key (kbd "C-c q") 'b
/boxquote-prefix-map
)
753 (define-key b
/boxquote-prefix-map
(kbd "b") #'boxquote-buffer
)
754 (define-key b
/boxquote-prefix-map
(kbd "B") #'boxquote-insert-buffer
)
755 (define-key b
/boxquote-prefix-map
(kbd "d") #'boxquote-defun
)
756 (define-key b
/boxquote-prefix-map
(kbd "F") #'boxquote-insert-file
)
757 (define-key b
/boxquote-prefix-map
(kbd "hf") #'boxquote-describe-function
)
758 (define-key b
/boxquote-prefix-map
(kbd "hk") #'boxquote-describe-key
)
759 (define-key b
/boxquote-prefix-map
(kbd "hv") #'boxquote-describe-variable
)
760 (define-key b
/boxquote-prefix-map
(kbd "hw") #'boxquote-where-is
)
761 (define-key b
/boxquote-prefix-map
(kbd "k") #'boxquote-kill
)
762 (define-key b
/boxquote-prefix-map
(kbd "p") #'boxquote-paragraph
)
763 (define-key b
/boxquote-prefix-map
(kbd "q") #'boxquote-boxquote
)
764 (define-key b
/boxquote-prefix-map
(kbd "r") #'boxquote-region
)
765 (define-key b
/boxquote-prefix-map
(kbd "s") #'boxquote-shell-command
)
766 (define-key b
/boxquote-prefix-map
(kbd "t") #'boxquote-text
)
767 (define-key b
/boxquote-prefix-map
(kbd "T") #'boxquote-title
)
768 (define-key b
/boxquote-prefix-map
(kbd "u") #'boxquote-unbox
)
769 (define-key b
/boxquote-prefix-map
(kbd "U") #'boxquote-unbox-region
)
770 (define-key b
/boxquote-prefix-map
(kbd "y") #'boxquote-yank
)
771 (define-key b
/boxquote-prefix-map
(kbd "M-q") #'boxquote-fill-paragraph
)
772 (define-key b
/boxquote-prefix-map
(kbd "M-w") #'boxquote-kill-ring-save
))
774 (add-to-list 'load-path
(b/lisp
"hl-todo"))
775 (run-with-idle-timer 0.5 nil
#'require
'hl-todo
)
776 (with-eval-after-load 'hl-todo
777 ;; Highlight TODO in buffers.
778 (global-hl-todo-mode))
781 (global-set-key (kbd "C-c D d") #'debbugs-gnu
)
782 (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs
)
783 (global-set-key (kbd "C-c D e") ; bug-gnu-emacs
786 (setq debbugs-gnu-current-suppress t
)
787 (debbugs-gnu debbugs-gnu-default-severities
789 (global-set-key (kbd "C-c D g") ; bug-gnuzilla
792 (setq debbugs-gnu-current-suppress t
)
793 (debbugs-gnu debbugs-gnu-default-severities
796 (with-eval-after-load 'url
797 (setq url-configuration-directory
(b/var
"url/configuration/")))
799 (with-eval-after-load 'url-cache
800 (setq url-cache-directory
(b/var
"url/cache/")))
802 (with-eval-after-load 'eww
804 eww-download-directory
805 (file-name-as-directory (getenv "XDG_DOWNLOAD_DIR"))))
806 (global-set-key (kbd "C-c e w") #'eww
)
808 ;; (with-eval-after-load 'org-ref
810 ;; reftex-default-bibliography '("~/usr/org/references.bib")
811 ;; org-ref-default-bibliography '("~/usr/org/references.bib")
812 ;; org-ref-bibliography-notes "~/usr/org/notes.org"
813 ;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
816 0.2 nil
#'require
'display-fill-column-indicator nil
'noerror
)
817 (with-eval-after-load 'display-fill-column-indicator
818 (global-display-fill-column-indicator-mode 1))
820 (with-eval-after-load 'window
821 (setq split-width-threshold
150)
822 (global-set-key (kbd "C-c w s l")
827 (global-set-key (kbd "C-c w s j")
832 (global-set-key (kbd "C-c w q") #'quit-window
))
834 ;; Uncomment to disable reftex-cite's default choice of previous word.
835 ;; (with-eval-after-load 'reftex
836 ;; (require 'reftex-cite)
837 ;; (defun reftex-get-bibkey-default ()
838 ;; "If the cursor is in a citation macro, return the word before
840 ;; (let* ((macro (reftex-what-macro 1)))
842 ;; (when (and macro (string-match "cite" (car macro)))
843 ;; (goto-char (cdr macro)))
844 ;; (reftex-this-word)))))
845 (add-hook 'latex-mode-hook
#'reftex-mode
)
847 (add-to-list 'load-path
(b/lisp
"dmenu"))
848 (with-eval-after-load 'dmenu
849 (setq dmenu-prompt-string
"run: "
850 dmenu-save-file
(b/var
"dmenu-items")))
851 (autoload 'dmenu
"dmenu" nil t
)
853 (run-with-idle-timer 0.5 nil
#'require
'delight
)
854 (with-eval-after-load 'delight
855 (delight 'auto-fill-function
" f" "simple")
856 (delight 'abbrev-mode
"" "abbrev")
857 (delight 'mml-mode
" mml" "mml"))
859 (require 'bandali-po
)
861 (with-eval-after-load 'emms
862 (setq emms-directory
(b/var
"emms")))
864 (add-to-list 'load-path
(b/lisp
"ffs"))
865 (run-with-idle-timer 0.5 nil
#'require
'ffs
)
866 (with-eval-after-load 'ffs
867 (global-set-key (kbd "C-c f s") #'ffs
))
869 ;;; init.el ends here