summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2016-01-09 17:46:23 +0100
committerAlan Pearce2016-01-09 17:46:23 +0100
commit10f81ec220477c7b8c7ea637639f78e90c7a4c3e (patch)
tree176deb58ee5cac31785ba9d61e9876c7025090be
parente3c5528891c42d23849d299fd5255f352d821b93 (diff)
downloaddotfiles-10f81ec220477c7b8c7ea637639f78e90c7a4c3e.tar.lz
dotfiles-10f81ec220477c7b8c7ea637639f78e90c7a4c3e.tar.zst
dotfiles-10f81ec220477c7b8c7ea637639f78e90c7a4c3e.zip
Emacs: Add sync version of tangle-init
-rw-r--r--tag-emacs/emacs.d/init.org14
1 files changed, 14 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 410a18b..2c86143 100644
--- a/tag-emacs/emacs.d/init.org
+++ b/tag-emacs/emacs.d/init.org
@@ -2462,6 +2462,20 @@ the =org=-document after changes.
     :commands (async-start)
     :defer 2)
 
+  (defun tangle-init-sync ()
+    (interactive)
+    (when (string-suffix-p "init.org" (buffer-file-name))
+      (message "Tangling init")
+      ;; Avoid running hooks when tangling.
+      (let ((prog-mode-hook nil)
+            (dest (concat user-emacs-directory "init.el")))
+        (require 'ob-tangle)
+        (org-babel-tangle-file (buffer-file-name) dest)
+        (if (byte-compile-file dest)
+            dest
+          (with-current-buffer byte-compile-log-buffer
+            (buffer-string))))))
+
   (defun tangle-init ()
     "If the current buffer is 'init.org' the code-blocks are
       tangled, and the tangled file is compiled."