blob: a9c53795a6d8906e7b78d55f713f9785b9b38f7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
;; Set up benchmark-init of initialization early inside init.el to correctly benchmark load time
(when (package-installed-p 'benchmark-init)
(require 'benchmark-init)
(add-hook 'after-init-hook 'benchmark-init/deactivate))
(setq checksum-path (expand-file-name ".config-checksum" user-emacs-directory))
(setq config-path (expand-file-name "config.org" user-emacs-directory))
(setq config-untangled-path (expand-file-name "config.el" user-emacs-directory))
(when (eq system-type 'gnu/linux)
(setq md5-cmd "md5sum --zero "))
(when (eq system-type 'darwin)
(setq md5-cmd "md5 -q "))
;; Since config is residing inside one file, I can calculate its checksum and tangle config.org only
;; when it was changed. This way loading is significantly faster.
(setq new-checksum (car (split-string (shell-command-to-string (concat md5-cmd config-path)))))
(setq saved-checksum "")
(when (file-exists-p checksum-path)
(setq saved-checksum (with-temp-buffer
(insert-file-contents checksum-path)
(buffer-string))))
(if (string-equal new-checksum saved-checksum)
(load-file config-untangled-path)
(progn
(write-region new-checksum nil checksum-path)
(setq org-modules '(org-id ol-info org-protocol))
(org-babel-load-file config-path)))
|