aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config
diff options
context:
space:
mode:
Diffstat (limited to 'Emacs/.config')
-rw-r--r--Emacs/.config/emacs/elisp/literate.el33
1 files changed, 14 insertions, 19 deletions
diff --git a/Emacs/.config/emacs/elisp/literate.el b/Emacs/.config/emacs/elisp/literate.el
index 0a53bdd..67ee88e 100644
--- a/Emacs/.config/emacs/elisp/literate.el
+++ b/Emacs/.config/emacs/elisp/literate.el
@@ -48,10 +48,6 @@
(lambda (name) (string= "el" (file-name-extension name)))
(cddr (directory-files (concat user-emacs-directory "elisp/")))))))
-(defconst +literate/elisp-byte-compiled
- `(,@(mapcar #'(lambda (x) (replace-regexp-in-string ".el" ".elc" x)) +literate/output-files)
- ,@(mapcar #'(lambda (x) (replace-regexp-in-string ".el" ".elc" x)) +literate/elisp-files)))
-
;; Setup predicates and loading
(defun +literate/--reduce-bool (bools init)
@@ -62,7 +58,7 @@
(defun +literate/output-files-exist ()
"Checks if output files exist, for compilation purposes."
(if (< 1 (length +literate/output-files))
- (+literate/--reduce-bool (mapc #'file-exists-p +literate/output-files) t)
+ (+literate/--reduce-bool (mapcar #'file-exists-p +literate/output-files) t)
(file-exists-p (car +literate/output-files))))
(defun +literate/load-config ()
@@ -72,30 +68,29 @@
(autoload #'org-babel-tangle-file "ob-tangle")
+(defun +literate/tangle-if-old (org-file)
+ (let ((output-file (replace-regexp-in-string ".org" ".el" org-file)))
+ (if (or (not (file-exists-p output-file)) (file-newer-than-file-p org-file output-file))
+ (org-babel-tangle-file org-file))))
+
+(defun +literate/byte-compile-if-old (el-file)
+ (let ((output-file (replace-regexp-in-string ".el" ".elc" el-file)))
+ (if (file-newer-than-file-p el-file output-file)
+ (byte-compile-file el-file))))
+
(defun +literate/compile-config ()
"Compile all files in +literate/org-files via org-babel-tangle."
(interactive)
(message "Compiling files...")
- (mapcar #'org-babel-tangle-file +literate/org-files)
+ (mapc #'+literate/tangle-if-old +literate/org-files)
(message "Files compiled")
(message "Byte-compiling literate files...")
- (mapcar #'(lambda (file) (byte-compile-file file)) +literate/output-files)
+ (mapc #'+literate/byte-compile-if-old +literate/output-files)
(message "Literate files byte-compiled")
(message "Byte compiling init.el, early-init.el, elisp/*")
- (mapcar #'(lambda (file) (byte-compile-file file)) +literate/elisp-files)
+ (mapc #'+literate/byte-compile-if-old +literate/elisp-files)
(message "Finished byte-compiling"))
-(defun +literate/--async-compile ()
- "WIP Attempting to make an asynchronous compilation function."
- (interactive)
- (start-process-shell-command
- "async-compile"
- "*literate/async-compile*"
- (format
- "emacs --batch --eval \"(progn (load %s\") (+literate/compile-config))\""
- (concat user-emacs-directory "elisp/literate.el"))))
-
-
(provide 'literate)
;;; literate.el ends here