Skip to content

Instantly share code, notes, and snippets.

@jsscclr
Created September 27, 2015 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsscclr/2b3f468bf25dc6960072 to your computer and use it in GitHub Desktop.
Save jsscclr/2b3f468bf25dc6960072 to your computer and use it in GitHub Desktop.
(defun tangle-init ()
"If the current buffer is 'init.org' the code-blocks are
tangled, and the tangled file is compiled."
(when (equal (buffer-file-name)
(expand-file-name (concat user-emacs-directory "init.org")))
;; Avoid running hooks when tangling.
(let ((prog-mode-hook nil))
(org-babel-tangle)
(byte-compile-file (concat user-emacs-directory "init.el")))))
(add-hook 'after-save-hook 'tangle-init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment