2018-06-08 16:23:13 +02:00
|
|
|
;;; config/literate/init.el -*- lexical-binding: t; -*-
|
|
|
|
|
2018-06-05 16:09:03 +02:00
|
|
|
(defvar +literate-config-file
|
|
|
|
(expand-file-name "config.org" doom-private-dir)
|
|
|
|
"The file path of your literate config file.")
|
2018-06-05 15:38:58 +02:00
|
|
|
|
2018-06-05 16:09:03 +02:00
|
|
|
(defvar +literate-config-dest-file
|
|
|
|
(expand-file-name "config.el" doom-private-dir)
|
|
|
|
"The file path that `+literate-config-file' will be tangled to, then
|
|
|
|
byte-compiled from.")
|
2018-06-05 15:38:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2018-06-05 16:09:03 +02:00
|
|
|
(defun +literate-compile (&optional load)
|
|
|
|
"Tangles & compiles `+literate-config-file' if it has changed. If LOAD is
|
|
|
|
non-nil, load it too!"
|
|
|
|
(let ((org +literate-config-file)
|
2018-06-08 16:23:13 +02:00
|
|
|
(el +literate-config-dest-file))
|
|
|
|
(when (file-newer-than-file-p org el)
|
2018-06-05 16:14:38 +02:00
|
|
|
(message "Compiling your literate config...")
|
2018-06-08 16:23:13 +02:00
|
|
|
|
|
|
|
;; We tangle in a separate, blank process because loading it here would
|
|
|
|
;; load all of :lang org (very expensive!). We only need ob-tangle.
|
2018-06-05 16:09:03 +02:00
|
|
|
(or (zerop (call-process
|
|
|
|
"emacs" nil nil nil
|
|
|
|
"-q" "--batch" "-l" "ob-tangle" "--eval"
|
|
|
|
(format "(org-babel-tangle-file \"%s\" \"%s\" \"emacs-lisp\")"
|
2018-06-08 16:23:13 +02:00
|
|
|
org el)))
|
|
|
|
(warn "There was a problem tangling your literate config!"))
|
|
|
|
|
2018-06-05 16:14:38 +02:00
|
|
|
(message "Done!"))))
|
2018-06-05 15:38:58 +02:00
|
|
|
|
2018-06-05 16:09:03 +02:00
|
|
|
;; Let 'er rip!
|
|
|
|
(+literate-compile)
|
2018-06-05 15:38:58 +02:00
|
|
|
|
|
|
|
;; No need to load the resulting file. Doom will do this for us after all
|
|
|
|
;; modules have finished loading.
|