0

To cut time on untangling my org setup file, I now only compile on save. However it is somewhat annoying to have the compile buffer popup on every save.

  ;; Only untangle on a change/save
  (defun my/tangle-dotfiles ()
    "If the current file is this file, the code blocks are tangled"
    (interactive)
    (when (equal (buffer-file-name) (file-truename (expand-file-name "myinit.org" user-emacs-directory)))
      (org-babel-tangle-file (expand-file-name "myinit.org" user-emacs-directory)
                             (expand-file-name "myinit.el" user-emacs-directory)
                             )
      (byte-compile-file (expand-file-name "myinit.el" user-emacs-directory))
      )
    )
  (add-hook 'after-save-hook #'my/tangle-dotfiles)

Is there a way to have this statement:

(byte-compile-file (expand-file-name "myinit.el" user-emacs-directory))

Run in the background instead in a buffer that pops up every time I save?

1

Byte-compiling is a CPU-bound activity, unlike with subprocesses and network processes there is no way of doing it asynchronously in the same Emacs instance. What you can do though is launching an Emacs subprocess and making it byte-compile the file. async.el offers support for this, try async-byte-compile-file from async-bytecomp.el.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.