summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-08-04 16:37:18 +0200
committerAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-08-04 16:39:56 +0200
commit24b0e724617427c40fbe74bcb58e36ee490207a8 (patch)
treeeaf0ce62300fac188960e024caf249604abeab52
parent7a7259065d54708d7f92ab880755aca7971410c6 (diff)
downloademacs-24b0e724617427c40fbe74bcb58e36ee490207a8.tar.gz
emacs-24b0e724617427c40fbe74bcb58e36ee490207a8.tar.xz
emacs-24b0e724617427c40fbe74bcb58e36ee490207a8.zip
init: Separate tangle and load
This way I can load the config without having org-mode loaded. org-mode is only required once to tangle the elisp code blocks from the org-mode file. This also adds a startup timer.
-rw-r--r--init.el31
1 files changed, 26 insertions, 5 deletions
diff --git a/init.el b/init.el
index 902642d..427291c 100644
--- a/init.el
+++ b/init.el
@@ -1,5 +1,26 @@
-(let ((file-name-handler-alist nil))
- (package-initialize nil)
- (setq package-enable-at-startup nil
- org-babel-use-quick-and-dirty-noweb-expansion t)
- (org-babel-load-file "~/.emacs.d/init.d/main.org"))
+(setq alex/startup-time (current-time)
+ alex/config (concat user-emacs-directory "init.d/main.org"))
+
+(defun alex/untangle-file-name (file)
+ (let ((base (file-name-sans-extension file)))
+ (concat base ".el")))
+
+(defun alex/tangle-config (orgfile elfile)
+ (let ((org-babel-use-quick-and-dirty-noweb-expansion t))
+ (message "Generating %s from %s. This may need some time..." elfile orgfile)
+ (let ((inhibit-message t))
+ (require 'org)
+ (org-babel-tangle-file orgfile elfile 'emacs-lisp))
+ (message "Done.")))
+
+(let ((elfile (alex/untangle-file-name alex/config)))
+ (when (or (not (file-exists-p elfile))
+ (file-newer-than-file-p alex/config elfile))
+ (alex/tangle-config alex/config elfile))
+
+ (let ((file-name-handler-alist nil))
+ (package-initialize nil)
+ (setq package-enable-at-startup nil)
+ (load-file elfile)))
+
+(message "Startup finished in %.2fs" (float-time (time-subtract (current-time) alex/startup-time)))