diff options
author | Alan Pearce | 2015-07-18 12:04:38 +0200 |
---|---|---|
committer | Alan Pearce | 2015-07-18 12:04:38 +0200 |
commit | fd72b1680ad33c4976c588471b03144655b62911 (patch) | |
tree | da16cce15c69d3f6300406f14aa4a9273223bfeb | |
parent | cf097a882af4b7b3510c68c70858dd88a8a52cff (diff) | |
download | nixfiles-fd72b1680ad33c4976c588471b03144655b62911.tar.lz nixfiles-fd72b1680ad33c4976c588471b03144655b62911.tar.zst nixfiles-fd72b1680ad33c4976c588471b03144655b62911.zip |
Emacs: Tangle init file asynchronously
-rw-r--r-- | tag-emacs/emacs.d/init.org | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 18a6f97e..1f0dd1ee 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -1,7 +1,7 @@ #+TITLE: Emacs Configuration for Alan Pearce #+PROPERTY: results silent #+PROPERTY: eval no-export -#+PROPERTY: header-args :tangle yes :comments link +#+PROPERTY: header-args :comments link * Introduction This is a living document, detailing my Emacs configuration using org-mode * Basics @@ -2464,7 +2464,8 @@ the buffer for me. * Tangling Taken from [[https://github.com/larstvei/dot-emacs/blob/master/init.org][larstvei/dot-emacs]]. I changed it so that it would work with -my current dotfiles repository structure. +my current dotfiles repository structure and work asynchronously, +thanks to [[https://github.com/jwiegley/emacs-async][jwiegley/emacs-async]]. We can use =C-c C-v t= to run =org-babel-tangle=, which extracts the code blocks from the current file into a source-specific file (in this @@ -2475,15 +2476,25 @@ to the =after-save-hook= ensuring to always tangle and byte-compile the =org=-document after changes. #+BEGIN_SRC emacs-lisp + (req-package async) + (defun tangle-init () "If the current buffer is 'init.org' the code-blocks are tangled, and the tangled file is compiled." (when (string-suffix-p "init.org" (buffer-file-name)) - ;; Avoid running hooks when tangling. - (let ((prog-mode-hook nil)) - (org-babel-tangle) - (byte-compile-file (concat user-emacs-directory "init.el"))))) + (async-start + `(lambda () + ;; Avoid running hooks when tangling. + (let ((prog-mode-hook nil) + (dest (concat user-emacs-directory "init.el"))) + (find-file ,(buffer-file-name)) + (require 'ob-tangle) + (org-babel-tangle nil dest) + (byte-compile-file dest) + dest)) + (lambda (result) + (message "Init tangling completed: %s" result))))) #+END_SRC # Local Variables: |