diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2020-08-09 17:32:09 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2020-08-09 17:32:09 +0100 |
commit | b309ef154d8c743917b517986d595a955f59fa54 (patch) | |
tree | 7499f1d1eba17c7f76d1118efede79ed27252071 /Emacs | |
parent | 8a0bf92555451211bac0ea0ec4c379717bb838d9 (diff) | |
download | dotfiles-b309ef154d8c743917b517986d595a955f59fa54.tar.gz dotfiles-b309ef154d8c743917b517986d595a955f59fa54.tar.bz2 dotfiles-b309ef154d8c743917b517986d595a955f59fa54.zip |
+better literate config
This is a smarter Emacs literate config. The way it works is simple:
- If no config output files exist, compile them. Otherwise just load
the config
- Add a hook when exiting emacs such that the config is compiled and
ready for next call.
This makes it so that load time is fast and compile occurs at a more
opportune time than at init.
Diffstat (limited to 'Emacs')
-rw-r--r-- | Emacs/.config/emacs/init.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Emacs/.config/emacs/init.el b/Emacs/.config/emacs/init.el index 5015f68..7ab3170 100644 --- a/Emacs/.config/emacs/init.el +++ b/Emacs/.config/emacs/init.el @@ -1,7 +1,24 @@ ;; Load literate (require 'ob-tangle) (setq user-emacs-directory "~/.config/emacs/") -(mapc #'(lambda (x) (org-babel-load-file (concat user-emacs-directory x))) (list "config.org")) +(defconst +literate/files (list "config.org")) +(defconst +literate/output-files (mapcar #'(lambda (x) (replace-regexp-in-string ".org" ".el" x)) +literate/files)) +(message "%s" +literate/output-files) + +(defun +literate/load-config () + (mapc #'(lambda (x) (load-file (concat user-emacs-directory x))) +literate/output-files)) + +(defun +literate/compile-config () + (mapc #'(lambda (x) (org-babel-tangle-file (concat user-emacs-directory x))) +literate/files)) + +(defun +literate/files-exist () + (cl-reduce #'(lambda (x y) (or x y)) (mapc #'(lambda (x) (file-exists-p (concat user-emacs-directory x))) +literate/output-files))) + +(add-hook 'kill-emacs-hook #'+literate/compile-config) +(unless (+literate/files-exist) + (+literate/compile-config)) + +(+literate/load-config) ;; Programming (custom-set-variables |