diff options
Diffstat (limited to 'tag-emacs')
-rw-r--r-- | tag-emacs/emacs.d/init.org | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index fb6eec6..ccf726a 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -2369,44 +2369,40 @@ the =org=-document after changes. :commands (async-start) :defer 2) + (defun tangle-if-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)) + (tangle-init))) + (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 (expand-file-name "init.el" user-emacs-directory))) - (require 'ob-tangle) - (org-babel-tangle-file (buffer-file-name) dest) - (if (byte-compile-file dest) - (byte-compile-dest-file dest) - (with-current-buffer byte-compile-log-buffer - (buffer-string)))))) + (message "Tangling init") + ;; Avoid running hooks when tangling. + (let ((prog-mode-hook nil) + (src (expand-file-name "init.org" user-emacs-directory)) + (dest (expand-file-name "init.el" user-emacs-directory))) + (require 'ob-tangle) + (org-babel-tangle-file src dest) + (if (byte-compile-file dest) + (byte-compile-dest-file 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." + "Tangle init.org asynchronously." (interactive) - (when (string-suffix-p "init.org" (buffer-file-name)) - (message "Tangling init") - (async-start - `(lambda () - ;; Avoid running hooks when tangling. - (let ((prog-mode-hook nil) - (dest (expand-file-name "init.el" user-emacs-directory))) - (require 'ob-tangle) - (org-babel-tangle-file ,(buffer-file-name) dest) - (if (byte-compile-file dest) - (byte-compile-dest-file dest) - (with-current-buffer byte-compile-log-buffer - (buffer-string))))) - (lambda (result) - (message "Init tangling completed: %s" result))))) + (message "Tangling init") + (async-start + (symbol-function #'tangle-init-sync) + (lambda (result) + (message "Init tangling completed: %s" result)))) #+END_SRC # Local Variables: -# eval: (when (fboundp #'tangle-init) (add-hook 'after-save-hook #'tangle-init)) +# eval: (when (fboundp #'tangle-if-init) (add-hook 'after-save-hook #'tangle-if-init)) # End: * End |