I use this function for tangling my init.el file
(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")))
(let ((prog-mode-hook nil)) ;; Avoid running hooks when tangling.
(org-babel-tangle-file buffer-file-name (concat user-emacs-directory "init.el") "emacs-lisp")
(byte-compile-file (concat user-emacs-directory "init.el")))))
(add-hook 'after-save-hook 'tangle-init)
That code works well but it take a lot of time. So I would like to execute this function with async librairie (https://github.com/jwiegley/emacs-async)
I tried something like this but doesn't work:
(require 'async)
(defun tangle-init-async ()
"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")))
(async-start
(lambda ()
(let ((prog-mode-hook nil)) ;; Avoid running hooks when tangling.
(org-babel-tangle-file buffer-file-name (concat user-emacs-directory "init.el") "emacs-lisp")
(byte-compile-file (concat user-emacs-directory "init.el")))))))
(add-hook 'after-save-hook 'tangle-init-async)
Any help appreciated.