diff options
-rw-r--r-- | init.org | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -29,25 +29,25 @@ prose for a new paragraph requires a lot less effort as the text itself acts as a connection between unrelated bits of code. * How to use this? +:PROPERTIES: +:noweb-ref: compile-init +:END: -The sole purpose of the =~/.emacs.d/init.el= file is now to load up -and interpret this =org-mode= file. (We don’t execute this code -here.) - -#+BEGIN_SRC elisp :tangle no -(require 'org) +We take all code blocks in this file and assemble an =init.el= from it +if the source file =init.org= is younger. At startup time we check if +the =init.el= has to be regenerated. -;; Load the actual configuration file -(org-babel-load-file - (expand-file-name (concat user-emacs-directory "init.org"))) +#+BEGIN_SRC elisp +(let ((orgfile (expand-file-name (concat user-emacs-directory "init.org"))) + (target (expand-file-name (concat user-emacs-directory "init.el")))) + (when (not (file-newer-than-file-p target orgfile)) + (progn + (require 'org) + (org-babel-tangle-file orgfile) + (byte-compile-file target) + (load target)))) #+END_SRC -Alternatively, we can take all code blocks in this file and assemble -an =init.el= from it. This is what the =org-babel-tangle= procedure -does for us. I actually prefer doing it this way, because startup -times are faster this way as org-mode doesn’t have to be loaded first. -We can even byte-compile the init file. - * Initialise packages :PROPERTIES: :noweb-ref: packages @@ -752,6 +752,7 @@ Having defined named code blocks in the sections above we can finally put them all together to build the init file #+BEGIN_SRC elisp :noweb yes :tangle "~/.emacs.d/init.el" +<<compile-init>> <<initial>> <<packages>> <<default-fonts>> |