From 739636d0a98f76ba5746a7d6a54cbb9be492e7e6 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 10 Aug 2020 12:27:49 +0100 Subject: ~clean up init.el literate code --- Emacs/.config/emacs/init.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Emacs/.config/emacs') diff --git a/Emacs/.config/emacs/init.el b/Emacs/.config/emacs/init.el index ee9e139..868e3ef 100644 --- a/Emacs/.config/emacs/init.el +++ b/Emacs/.config/emacs/init.el @@ -2,23 +2,28 @@ (setq user-emacs-directory "~/.config/emacs/") (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 () + (interactive) (require 'ob-tangle) - (mapc #'(lambda (x) (org-babel-tangle-file (concat user-emacs-directory x))) +literate/files)) + (mapc #'org-babel-tangle-file +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))) + "Checks if output files exist, for compilation purposes. Don't use if only one file." + (require 'cl-lib) + (cl-reduce #'(lambda (x y) (and x y)) (mapc #'file-exists-p +literate/output-files) + :initial-value t)) (add-hook 'kill-emacs-hook #'+literate/compile-config) -(unless (+literate/files-exist) + +(unless (file-exists-p "config.el") ; only one file (+literate/compile-config)) (+literate/load-config) + (when (daemonp) (require 'org) (require 'notmuch) -- cgit v1.2.3-13-gbd6f