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")
64 ;; (yasnippet "0.14.0")))
67 (setq package-archive-upload-base
"/ssh:caffeine:~/www/p/elpa")
72 ;; Keep ~/.emacs.d clean.
75 (convert-standard-filename "etc/") user-emacs-directory
)
76 "The directory where packages place their configuration files.")
79 (convert-standard-filename "var/") user-emacs-directory
)
80 "The directory where packages place their persistent data files.")
83 (convert-standard-filename "lisp/") user-emacs-directory
)
84 "The directory where packages place their persistent data files.")
86 "Expand filename FILE relative to `b/etc-dir'."
87 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
89 "Expand filename FILE relative to `b/var-dir'."
90 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
92 "Expand filename FILE relative to `b/lisp-dir'."
93 (expand-file-name (convert-standard-filename file
) b
/lisp-dir
))
95 ;; Separate custom file (don't want it mixing with init.el).
96 (with-eval-after-load 'custom
97 (setq custom-file
(b/etc
"custom.el"))
98 (when (file-exists-p custom-file
)
100 ;; Only one custom theme at a time.
101 ;; (defadvice load-theme (before clear-previous-themes activate)
102 ;; "Clear existing theme settings instead of layering them"
103 ;; (mapc #'disable-theme custom-enabled-themes))
106 ;; Load the secrets file if it exists, otherwise show a warning.
107 ;; (with-demoted-errors
108 ;; (load (b/etc "secrets")))
110 ;; Start up emacs server:
111 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html
112 (run-with-idle-timer 0.5 nil
#'require
'server
)
113 (with-eval-after-load 'server
114 (declare-function server-edit
"server")
115 (global-set-key (kbd "C-c F D") #'server-edit
)
116 (declare-function server-running-p
"server")
117 (or (server-running-p) (server-mode)))
122 ;;;; C-level customizations
126 completion-ignore-case t
127 read-buffer-completion-ignore-case t
128 enable-recursive-minibuffers t
129 resize-mini-windows t
130 message-log-max
20000
132 ;; mouse-autoselect-window t
133 scroll-conservatively
15
134 scroll-preserve-screen-position
1
135 ;; I don't feel like jumping out of my chair every now and again;
136 ;; so...don't *BEEP* at me, Emacs. =)
137 ring-bell-function
'ignore
)
140 ;; Case-sensitive search (and `dabbrev-expand').
141 ;; case-fold-search nil
142 indent-tabs-mode nil
; always use space for indentation
144 indicate-buffer-boundaries
'left
)
146 ;; Lazy-person-friendly yes/no prompts.
147 (defalias 'yes-or-no-p
#'y-or-n-p
)
149 (when (display-graphic-p)
150 (set-fontset-font t
'arabic
"Vazir"))
151 ;; ;; (set-frame-font "Drafting Mono-14:weight=light" nil t)
152 ;; (set-frame-font "Drafting Mono:pixelsize=16" nil t)
153 ;; (set-face-attribute 'bold nil :weight 'semi-bold)
155 ;;;; Elisp-level customizations
157 (with-eval-after-load 'minibuffer
158 (setq read-file-name-completion-ignore-case t
))
161 ;; don't need to see the startup echo area message
162 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
164 auto-save-list-file-prefix
(b/var
"auto-save/sessions/")
165 ;; i want *scratch* as my startup buffer
166 initial-buffer-choice t
167 ;; i don't need the default hint
168 initial-scratch-message nil
169 ;; use customizable text-mode as major mode for *scratch*
170 ;; (initial-major-mode 'text-mode)
171 ;; inhibit buffer list when more than 2 files are loaded
172 inhibit-startup-buffer-menu t
173 ;; don't need to see the startup screen or echo area message
174 inhibit-startup-screen t
175 inhibit-startup-echo-area-message user-login-name
)
177 (with-eval-after-load 'files
179 ;; backups (C-h v make-backup-files RET)
181 backup-directory-alist
(list (cons "." (b/var
"backup/")))
183 delete-old-versions t
185 auto-save-file-name-transforms
`((".*" ,(b/var
"auto-save/") t
))
186 ;; insert newline at the end of files
187 ;; require-final-newline t
188 ;; open read-only file buffers in view-mode
189 ;; (enables niceties like `q' for quit)
193 (setq disabled-command-function nil
)
196 ;; (keyboard-translate ?\( ?\[)
197 ;; (keyboard-translate ?\) ?\])
198 ;; (keyboard-translate ?\[ ?\()
199 ;; (keyboard-translate ?\] ?\))
201 (run-with-idle-timer 0.1 nil
#'require
'autorevert
)
202 (with-eval-after-load 'autorevert
204 ;; auto-revert-verbose nil
205 global-auto-revert-non-file-buffers nil
)
206 (global-auto-revert-mode 1))
208 (run-with-idle-timer 0.1 nil
#'require
'time
)
209 (with-eval-after-load 'time
211 display-time-default-load-average nil
212 display-time-format
" %a %b %-e %-l:%M%P"
213 display-time-mail-icon
'(image :type xpm
214 :file
"gnus/gnus-pointer.xpm"
216 display-time-use-mail-icon t
217 zoneinfo-style-world-list
218 `(,@zoneinfo-style-world-list
220 ("Asia/Tehran" "Tehran")
221 ("Australia/Melbourne" "Melbourne")))
224 (run-with-idle-timer 0.1 nil
#'require
'battery
)
225 (with-eval-after-load 'battery
226 (setq battery-mode-line-format
" %p%% %t")
227 (display-battery-mode))
229 ;; (with-eval-after-load 'fringe
231 ;; (fringe-mode '(3 . 1)))
233 (run-with-idle-timer 0.5 nil
#'require
'winner
)
234 (with-eval-after-load 'winner
237 (run-with-idle-timer 0.5 nil
#'require
'windmove
)
238 (with-eval-after-load 'windmove
239 (setq windmove-wrap-around t
)
240 (global-set-key (kbd "M-H") #'windmove-left
)
241 (global-set-key (kbd "M-L") #'windmove-right
)
242 (global-set-key (kbd "M-K") #'windmove-up
)
243 (global-set-key (kbd "M-J") #'windmove-down
))
245 (with-eval-after-load 'compile
246 ;; don't display *compilation* buffer on success. based on
247 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
248 ;; instead of the now obsolete `flet'.
249 (defun b/compilation-finish-function
(buffer outstr
)
250 (unless (string-match "finished" outstr
)
251 (switch-to-buffer-other-window buffer
))
254 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
258 (defadvice compilation-start
259 (around inhibit-display
260 (command &optional mode name-function highlight-regexp
))
261 (if (not (string-match "^\\(find\\|grep\\)" command
))
262 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
263 (save-window-excursion ad-do-it
))
265 (ad-activate 'compilation-start
))
267 (with-eval-after-load 'isearch
269 ;; Allow scrolling in Isearch.
270 isearch-allow-scroll t
272 ;; Search for non-ASCII characters: i’d like non-ASCII characters
273 ;; such as ‘’“”«»‹›áⓐ𝒶 to be selected when I search for their ASCII
274 ;; counterpart. Shoutout to
275 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
276 search-default-mode
#'char-fold-to-regexp
))
278 ;; (with-eval-after-load 'replace
279 ;; ;; Uncomment to extend the above behaviour to query-replace.
280 ;; (setq replace-char-fold t))
283 (global-set-key (kbd "C-x v C-=") #'vc-ediff
)
285 (with-eval-after-load 'vc-git
286 (setq vc-git-print-log-follow t
287 vc-git-show-stash
0))
289 (with-eval-after-load 'ediff
290 (setq ediff-window-setup-function
'ediff-setup-windows-plain
291 ediff-split-window-function
'split-window-horizontally
)
292 (add-hook 'ediff-after-quit-hook-internal
#'winner-undo
))
294 (with-eval-after-load 'face-remap
296 ;; Gentler font resizing.
297 text-scale-mode-step
1.05))
299 (run-with-idle-timer 0.4 nil
#'require
'mwheel
)
300 (with-eval-after-load 'mwheel
302 mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
303 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
304 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
306 (run-with-idle-timer 0.4 nil
#'require
'pixel-scroll
)
307 (with-eval-after-load 'pixel-scroll
308 (pixel-scroll-mode 1))
310 (with-eval-after-load 'epg-config
312 epg-gpg-program
(executable-find "gpg")
313 ;; Ask for GPG passphrase in minibuffer.
314 ;; Will fail if gpg >= 2.1 is not available.
315 epg-pinentry-mode
'loopback
))
317 (with-eval-after-load 'auth-source
319 auth-sources
'("~/.authinfo.gpg")
321 (regexp-opt '("password" "client-secret" "token"))))
323 (with-eval-after-load 'info
326 `(,@Info-directory-list
328 (convert-standard-filename "info/") source-directory
)
329 "/usr/share/info/")))
331 (when (display-graphic-p)
332 (with-eval-after-load 'faces
333 (let ((grey "#e7e7e7"))
334 (set-face-attribute 'fixed-pitch nil
:family
"Source Code Pro")
335 (set-face-attribute 'mode-line nil
337 :inherit
'fixed-pitch
))))
339 (when (version< emacs-version
"28")
340 ;; Manually make some `mode-line' spaces smaller. Emacs 28 (and
341 ;; above) does a terrific job at this out of the box when
342 ;; `mode-line-compact' is set to t (see above)."
353 mode-line-buffer-identification
354 (propertized-buffer-identification "%10b")))
359 (defun b/add-elisp-section
()
363 (insert "\n\f\n;;; "))
365 (defun b/insert-asterism
()
366 "Insert a centred asterism."
368 (let ((asterism "* * *"))
373 (floor (/ (- fill-column
(length asterism
)) 2))
378 (defun b/start-process
(program &rest args
)
379 "Same as `start-process', but doesn't bother about name and buffer."
380 (let ((process-name (concat program
"_process"))
381 (buffer-name (generate-new-buffer-name
382 (concat program
"_output"))))
383 (apply #'start-process
384 process-name buffer-name program args
)))
386 (defun b/no-mouse-autoselect-window
()
387 "Conveniently disable `focus-follows-mouse'.
388 For disabling the behaviour for certain buffers and/or modes."
389 (make-local-variable 'mouse-autoselect-window
)
390 (setq mouse-autoselect-window nil
))
392 (defun b/move-indentation-or-beginning-of-line
(arg)
393 "Move to the indentation or to the beginning of line."
396 ;; (back-to-indentation)
397 ;; (move-beginning-of-line arg))
399 (progn (back-to-indentation)
401 (move-beginning-of-line arg
)))
403 (defun b/join-line-top
()
404 "Like `join-line', but join next line to the current line."
408 (defun b/*scratch
* ()
409 "Switch to `*scratch*' buffer, creating it if it does not
412 (let ((fun (if (functionp #'get-scratch-buffer-create
)
413 #'get-scratch-buffer-create
; (version<= "29" emacs-version)
414 #'startup--get-buffer-create-scratch
))) ; (version< emacs-version "29")
415 (switch-to-buffer (funcall fun
))))
417 (defun b/duplicate-line-or-region
(&optional n
)
418 "Duplicate the current line, or region (if active).
419 Make N (default: 1) copies of the current line or region."
421 (let ((u-r-p (use-region-p)) ; if region is active
426 (buffer-substring (region-beginning) (region-end))
427 (prog1 (thing-at-point 'line
)
431 (forward-line 1))))))
432 (dotimes (_ (abs n1
))
435 (defun b/invert-default-face
()
436 "Invert the `default' face (swap its background and foreground).
437 Effectively a very simple light/dark theme toggle switch."
439 (invert-face 'default
(selected-frame))
440 (invert-face 'mode-line
(selected-frame)))
442 (defun b/export-frame
()
444 ;; TODO: ask for fn and/or take as arg
445 (let* ((fn (make-temp-file "emacs" nil
".pdf"))
446 (data (x-export-frames nil
'pdf
)))
453 ;;; General key bindings
455 (global-set-key (kbd "C-a") #'b
/move-indentation-or-beginning-of-line
)
456 (global-set-key (kbd "C-c a i") #'ielm
)
457 (global-set-key (kbd "C-c d") #'b
/duplicate-line-or-region
)
458 (global-set-key (kbd "C-c j") #'b
/join-line-top
)
459 (global-set-key (kbd "C-S-j") #'b
/join-line-top
)
460 (global-set-key (kbd "C-c s") #'b
/*scratch
*)
461 (global-set-key (kbd "C-c x") #'execute-extended-command
)
462 (global-set-key (kbd "C-c v") #'b
/invert-default-face
)
464 ;; evaling and macro-expanding
465 (global-set-key (kbd "C-c e b") #'eval-buffer
)
466 (global-set-key (kbd "C-c e e") #'eval-last-sexp
)
467 (global-set-key (kbd "C-c e m") #'pp-macroexpand-last-sexp
)
468 (global-set-key (kbd "C-c e r") #'eval-region
)
471 (global-set-key (kbd "C-c e i") #'emacs-init-time
)
472 (global-set-key (kbd "C-c e u") #'emacs-uptime
)
473 (global-set-key (kbd "C-c e v") #'emacs-version
)
476 (global-set-key (kbd "C-c f .") #'find-file
)
477 (global-set-key (kbd "C-c f d") #'find-name-dired
)
478 (global-set-key (kbd "C-c f l") #'find-library
)
479 (global-set-key (kbd "C-c f p") #'find-file-at-point
)
482 (global-set-key (kbd "C-c F m") #'make-frame-command
)
483 (global-set-key (kbd "C-c F d") #'delete-frame
)
486 (global-set-key (kbd "C-S-h F") #'describe-face
)
488 (define-key emacs-lisp-mode-map
(kbd "C-<return>") #'b
/add-elisp-section
)
490 (when (display-graphic-p)
491 (global-unset-key (kbd "C-z")))
494 ;;; Essential packages
499 (convert-standard-filename "lisp") user-emacs-directory
))
501 ;; (require 'bandali-exwm)
503 (require 'bandali-org
)
505 ;; (require 'bandali-theme)
507 ;; recently opened files
508 (run-with-idle-timer 0.2 nil
#'require
'recentf
)
509 (with-eval-after-load 'recentf
511 recentf-max-saved-items
2000
512 recentf-save-file
(b/var
"recentf-save.el"))
513 ;; (add-to-list 'recentf-keep #'file-remote-p)
516 (defun b/recentf-open
()
517 "Use `completing-read' to \\[find-file] a recent file."
520 (completing-read "Find recent file: " recentf-list
)))
521 (global-set-key (kbd "C-c f r") #'b
/recentf-open
))
523 ;; (define-key minibuffer-local-completion-map
524 ;; "\t" #'minibuffer-force-complete)
526 ;; (with-eval-after-load 'icomplete
528 ;; (setq icomplete-on-del-error-function #'abort-recursive-edit)
530 ;; (defun b/icomplete-fido-backward-updir ()
531 ;; "Delete char before or go up directory, like `ido-mode'."
533 ;; (if (and (eq (char-before) ?/)
534 ;; (eq (icomplete--category) 'file))
536 ;; (goto-char (1- (point)))
537 ;; (when (search-backward "/" (point-min) t)
538 ;; (delete-region (1+ (point)) (point-max))))
539 ;; (condition-case nil
540 ;; (call-interactively #'delete-backward-char)
542 ;; (when icomplete-on-del-error-function
543 ;; (funcall icomplete-on-del-error-function))))))
545 ;; (define-key icomplete-fido-mode-map
546 ;; (kbd "DEL") #'b/icomplete-fido-backward-updir))
549 ;; (defun b/icomplete--fido-mode-setup ()
550 ;; "Customizations to `fido-mode''s minibuffer."
551 ;; (when (and icomplete-mode (icomplete-simple-completing-p))
553 ;; ;; icomplete-compute-delay 0.1
554 ;; ;; icomplete-hide-common-prefix t
555 ;; icomplete-separator " · "
556 ;; completion-styles '(basic substring partial-completion flex))))
557 ;; (add-hook 'minibuffer-setup-hook #'b/icomplete--fido-mode-setup 1)
559 (require 'bandali-eshell
)
561 (require 'bandali-ibuffer
)
563 (require 'bandali-dired
)
565 (with-eval-after-load 'help
566 (temp-buffer-resize-mode)
567 (setq help-window-select t
))
569 (with-eval-after-load 'help-mode
570 (define-key help-mode-map
(kbd "p") #'backward-button
)
571 (define-key help-mode-map
(kbd "n") #'forward-button
))
573 (with-eval-after-load 'tramp
574 (setq tramp-auto-save-directory
(b/var
"tramp/auto-save/")
575 tramp-persistency-file-name
(b/var
"tramp/persistency.el"))
576 (add-to-list 'tramp-default-proxies-alist
'(nil "\\`root\\'" "/ssh:%h:"))
577 (add-to-list 'tramp-default-proxies-alist
'("localhost" nil nil
))
578 (add-to-list 'tramp-default-proxies-alist
579 (list (regexp-quote (system-name)) nil nil
)))
581 (with-eval-after-load 'doc-view
582 (define-key doc-view-mode-map
(kbd "M-RET") #'image-previous-line
))
584 (setq shr-max-width
80)
586 ;; Email (with Gnus, message, and smtpmail)
587 (require 'bandali-gnus
)
588 (require 'bandali-message
)
589 ;; (with-eval-after-load 'smtpmail
590 ;; (setq smtpmail-queue-mail t
591 ;; smtpmail-queue-dir (concat b/maildir "queue/")))
594 (require 'bandali-erc
)
596 ;; 'paste' service (aka scp + web server)
597 (add-to-list 'load-path
(b/lisp
"scpaste"))
598 (with-eval-after-load 'scpaste
599 (setq scpaste-http-destination
"https://p.bndl.org"
600 scpaste-scp-destination
"p:~"))
601 (autoload 'scpaste
"scpaste" nil t
)
602 (autoload 'scpaste-region
"scpaste" nil t
)
603 (global-set-key (kbd "C-c a p p") #'scpaste
)
604 (global-set-key (kbd "C-c a p r") #'scpaste-region
)
609 (when (featurep 'eldoc
)
610 ;; Display Lisp objects at point in the echo area.
611 (with-eval-after-load 'eldoc
612 (setq eldoc-minor-mode-string
" eldoc")
613 (global-eldoc-mode)))
615 ;; highlight matching parens
616 (run-with-idle-timer 0.2 nil
#'require
'paren
)
617 (with-eval-after-load 'paren
620 ;; (run-with-idle-timer 0.2 nil #'require 'elec-pair)
621 ;; (with-eval-after-load 'elec-pair
622 ;; (electric-pair-mode))
624 (with-eval-after-load 'simple
626 ;; Save what I copy into clipboard from other applications into Emacs'
627 ;; kill-ring, which would allow me to still be able to easily access
628 ;; it in case I kill (cut or copy) something else inside Emacs before
629 ;; yanking (pasting) what I'd originally intended to.
630 save-interprogram-paste-before-kill t
)
631 (column-number-mode 1)
632 (line-number-mode 1))
634 (run-with-idle-timer 0.2 nil
#'require
'savehist
)
635 (with-eval-after-load 'savehist
636 ;; Save minibuffer history.
637 (setq savehist-file
(b/var
"savehist.el"))
639 (add-to-list 'savehist-additional-variables
'kill-ring
))
641 ;; Automatically save place in files.
642 (run-with-idle-timer 0.2 nil
#'require
'saveplace nil
'noerror
)
643 (with-eval-after-load 'saveplace
644 (setq save-place-file
(b/var
"save-place.el"))
647 (with-eval-after-load 'prog-mode
648 (global-prettify-symbols-mode))
650 (add-to-list 'auto-mode-alist
'("\\.*rc$" . conf-mode
))
651 (add-to-list 'auto-mode-alist
'("\\.bashrc$" . sh-mode
))
653 (with-eval-after-load 'flyspell
654 (setq flyspell-mode-line-string
" fly"))
656 (with-eval-after-load 'text-mode
657 (add-hook 'text-mode-hook
#'flyspell-mode
)
658 (define-key text-mode-map
(kbd "C-<return>") #'b
/insert-asterism
))
660 ;; ;; http://endlessparentheses.com/ispell-and-apostrophes.html
661 ;; (run-with-idle-timer 0.6 nil #'require 'ispell)
662 ;; (with-eval-after-load 'ispell
663 ;; ;; ’ can be part of a word.
664 ;; (setq ispell-local-dictionary-alist
665 ;; `((nil "[[:alpha:]]" "[^[:alpha:]]"
666 ;; "['\x2019]" nil ("-B") nil utf-8))
667 ;; ispell-program-name (executable-find "hunspell"))
668 ;; ;; Don't send ’ to the subprocess.
669 ;; (defun endless/replace-apostrophe (args)
670 ;; (cons (replace-regexp-in-string
671 ;; "’" "'" (car args))
673 ;; (advice-add #'ispell-send-string :filter-args
674 ;; #'endless/replace-apostrophe)
675 ;; ;; Convert ' back to ’ from the subprocess.
676 ;; (defun endless/replace-quote (args)
677 ;; (if (not (derived-mode-p 'org-mode))
679 ;; (cons (replace-regexp-in-string
680 ;; "'" "’" (car args))
682 ;; (advice-add #'ispell-parse-output :filter-args
683 ;; #'endless/replace-quote))
685 (with-eval-after-load 'abbrev
686 (setq abbrev-file-name
(b/etc
"abbrev.el")))
687 (add-hook 'text-mode-hook
#'abbrev-mode
)
690 ;;; Programming modes
692 (with-eval-after-load 'lisp-mode
693 (defun indent-spaces-mode ()
694 (setq indent-tabs-mode nil
))
695 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
697 (add-to-list 'load-path
(b/lisp
"alloy-mode"))
698 (autoload 'alloy-mode
"alloy-mode" nil t
)
699 (with-eval-after-load 'alloy-mode
700 (setq alloy-basic-offset
2)
701 ;; (defun b/alloy-simple-indent (start end)
703 ;; ;; (if (region-active-p)
704 ;; ;; (indent-rigidly start end alloy-basic-offset)
706 ;; ;; (indent-rigidly (line-beginning-position)
707 ;; ;; (line-end-position)
708 ;; ;; alloy-basic-offset)))
709 ;; (indent-to (+ (current-column) alloy-basic-offset)))
710 (define-key alloy-mode-map
(kbd "RET") #'electric-newline-and-maybe-indent
)
711 ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent)
712 (define-key alloy-mode-map
(kbd "TAB") #'indent-for-tab-command
))
713 (add-to-list 'auto-mode-alist
'("\\.\\(als\\|dsh\\)\\'" . alloy-mode
))
714 (add-hook 'alloy-mode-hook
(lambda nil
(setq-local indent-tabs-mode nil
)))
716 ;; (eval-when-compile (defvar lean-mode-map))
717 ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode)
718 ;; (with-eval-after-load 'lean-mode
719 ;; (require 'lean-input)
720 ;; (setq default-input-method "Lean"
721 ;; lean-input-tweak-all '(lean-input-compose
722 ;; (lean-input-prepend "/")
723 ;; (lean-input-nonempty))
724 ;; lean-input-user-translations '(("/" "/")))
725 ;; (lean-input-setup)
726 ;; ;; local key bindings
727 ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete))
729 (with-eval-after-load 'sgml-mode
730 (setq sgml-basic-offset
0))
732 (with-eval-after-load 'css-mode
733 (setq css-indent-offset
2))
735 ;; (with-eval-after-load 'auctex
736 ;; (setq font-latex-fontify-sectioning 'color))
738 (with-eval-after-load 'tex-mode
740 (lambda (p) (string-match "^---?" (car p
)))
741 tex--prettify-symbols-alist
))
742 (add-hook 'tex-mode-hook
#'auto-fill-mode
)
743 (add-hook 'tex-mode-hook
#'flyspell-mode
)
745 (run-with-idle-timer 0.5 nil
#'require
'cmake-mode
)
746 (with-eval-after-load 'cmake-mode
747 ;; (setq cmake-tab-width 4)
748 (add-to-list 'load-path
(b/lisp
"cmake-font-lock"))
749 (run-with-idle-timer 0.5 nil
#'require
'cmake-font-lock
))
752 ;;; Emacs enhancements & auxiliary packages
754 (with-eval-after-load 'nsm
755 (setq nsm-settings-file
(b/var
"nsm-settings.el")))
757 (with-eval-after-load 'man
761 ;; | make pretty boxed quotes like this
763 (add-to-list 'load-path
(b/lisp
"boxquote"))
764 (run-with-idle-timer 0.6 nil
#'require
'boxquote
)
765 (with-eval-after-load 'boxquote
766 (defvar b
/boxquote-prefix-map
)
767 (define-prefix-command 'b
/boxquote-prefix-map
)
768 (global-set-key (kbd "C-c q") 'b
/boxquote-prefix-map
)
769 (define-key b
/boxquote-prefix-map
(kbd "b") #'boxquote-buffer
)
770 (define-key b
/boxquote-prefix-map
(kbd "B") #'boxquote-insert-buffer
)
771 (define-key b
/boxquote-prefix-map
(kbd "d") #'boxquote-defun
)
772 (define-key b
/boxquote-prefix-map
(kbd "F") #'boxquote-insert-file
)
773 (define-key b
/boxquote-prefix-map
(kbd "hf") #'boxquote-describe-function
)
774 (define-key b
/boxquote-prefix-map
(kbd "hk") #'boxquote-describe-key
)
775 (define-key b
/boxquote-prefix-map
(kbd "hv") #'boxquote-describe-variable
)
776 (define-key b
/boxquote-prefix-map
(kbd "hw") #'boxquote-where-is
)
777 (define-key b
/boxquote-prefix-map
(kbd "k") #'boxquote-kill
)
778 (define-key b
/boxquote-prefix-map
(kbd "p") #'boxquote-paragraph
)
779 (define-key b
/boxquote-prefix-map
(kbd "q") #'boxquote-boxquote
)
780 (define-key b
/boxquote-prefix-map
(kbd "r") #'boxquote-region
)
781 (define-key b
/boxquote-prefix-map
(kbd "s") #'boxquote-shell-command
)
782 (define-key b
/boxquote-prefix-map
(kbd "t") #'boxquote-text
)
783 (define-key b
/boxquote-prefix-map
(kbd "T") #'boxquote-title
)
784 (define-key b
/boxquote-prefix-map
(kbd "u") #'boxquote-unbox
)
785 (define-key b
/boxquote-prefix-map
(kbd "U") #'boxquote-unbox-region
)
786 (define-key b
/boxquote-prefix-map
(kbd "y") #'boxquote-yank
)
787 (define-key b
/boxquote-prefix-map
(kbd "M-q") #'boxquote-fill-paragraph
)
788 (define-key b
/boxquote-prefix-map
(kbd "M-w") #'boxquote-kill-ring-save
))
790 (add-to-list 'load-path
(b/lisp
"hl-todo"))
791 (run-with-idle-timer 0.5 nil
#'require
'hl-todo
)
792 (with-eval-after-load 'hl-todo
793 ;; Highlight TODO in buffers.
794 (global-hl-todo-mode))
796 (run-with-idle-timer 0.6 nil
#'require
'yasnippet
)
797 (with-eval-after-load 'yasnippet
798 (declare-function yas-reload-all
799 "yasnippet" (&optional no-jit interactive
))
800 (declare-function yas-maybe-expand-abbrev-key-filter
803 (defconst yas-verbosity-cur yas-verbosity
)
804 (setq yas-verbosity
2
805 yas-snippet-dirs
`(,(b/etc
"yasnippet/snippets")))
806 ;; (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
808 (setq yas-verbosity yas-verbosity-cur
)
810 (defun b/yas-maybe-expand-abbrev-key-filter
(cmd)
811 (when (and (yas-maybe-expand-abbrev-key-filter cmd
)
812 (not (bound-and-true-p git-commit-mode
)))
814 (defconst b
/yas-maybe-expand
815 '(menu-item "" yas-expand
816 :filter b
/yas-maybe-expand-abbrev-key-filter
))
817 (define-key yas-minor-mode-map
(kbd "SPC") b
/yas-maybe-expand
)
822 (global-set-key (kbd "C-c D d") #'debbugs-gnu
)
823 (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs
)
824 (global-set-key (kbd "C-c D e") ; bug-gnu-emacs
827 (setq debbugs-gnu-current-suppress t
)
828 (debbugs-gnu debbugs-gnu-default-severities
830 (global-set-key (kbd "C-c D g") ; bug-gnuzilla
833 (setq debbugs-gnu-current-suppress t
)
834 (debbugs-gnu debbugs-gnu-default-severities
837 (with-eval-after-load 'url
838 (setq url-configuration-directory
(b/var
"url/configuration/")))
840 (with-eval-after-load 'url-cache
841 (setq url-cache-directory
(b/var
"url/cache/")))
843 (with-eval-after-load 'eww
845 eww-download-directory
846 (file-name-as-directory (getenv "XDG_DOWNLOAD_DIR"))))
847 (global-set-key (kbd "C-c a e w") #'eww
)
849 ;; (with-eval-after-load 'org-ref
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/"))
857 0.2 nil
#'require
'display-fill-column-indicator nil
'noerror
)
858 (with-eval-after-load 'display-fill-column-indicator
859 (global-display-fill-column-indicator-mode 1))
861 (with-eval-after-load 'window
862 (setq split-width-threshold
150)
863 (global-set-key (kbd "C-c w s l")
868 (global-set-key (kbd "C-c w s j")
873 (global-set-key (kbd "C-c w q") #'quit-window
))
875 ;; Uncomment to disable reftex-cite's default choice of previous word.
876 ;; (with-eval-after-load 'reftex
877 ;; (require 'reftex-cite)
878 ;; (defun reftex-get-bibkey-default ()
879 ;; "If the cursor is in a citation macro, return the word before
881 ;; (let* ((macro (reftex-what-macro 1)))
883 ;; (when (and macro (string-match "cite" (car macro)))
884 ;; (goto-char (cdr macro)))
885 ;; (reftex-this-word)))))
886 (add-hook 'latex-mode-hook
#'reftex-mode
)
888 (add-to-list 'load-path
(b/lisp
"dmenu"))
889 (with-eval-after-load 'dmenu
890 (setq dmenu-prompt-string
"run: "
891 dmenu-save-file
(b/var
"dmenu-items")))
892 (autoload 'dmenu
"dmenu" nil t
)
894 (run-with-idle-timer 0.5 nil
#'require
'delight
)
895 (with-eval-after-load 'delight
896 (delight 'auto-fill-function
" f" "simple")
897 (delight 'abbrev-mode
"" "abbrev")
898 (delight 'mml-mode
" mml" "mml")
899 (delight 'yas-minor-mode
"" "yasnippet"))
901 (require 'bandali-po
)
903 (with-eval-after-load 'emms
904 (setq emms-directory
(b/var
"emms")))
906 (add-to-list 'load-path
(b/lisp
"ffs"))
907 (run-with-idle-timer 0.5 nil
#'require
'ffs
)
908 (with-eval-after-load 'ffs
909 (global-set-key (kbd "C-c f s") #'ffs
))
911 ;;; init.el ends here