As I understand, Emacs doesn't really support multi-threading. Because of this I've chosen to run some operation (it can take a while) with compile function. This is asynchronous and all in all it seemed like a good solution at first.

Now I need to wait until compilation ends and perform other actions (again they should not freeze Emacs, so they will be probably new compile calls) once it's finished.

So, it would be good if there were after-compilation-hook or something like that, because compilation-exit-message-function doesn't work, as it's called when compilation is not formally finished.

Is there some way I can perform actions after compilation process (I'm referring to process created by compile)? Please note that I cannot concatenate all commands into one big command and feed it to compile at once because the commands are not known in advance.

1 Answer 1


Try using compilation-finish-functions:

(defun my-compilation-finish-function (buffer desc)
  (message "Buffer %s: %s" buffer desc))
(add-hook 'compilation-finish-functions 'my-compilation-finish-function)
  • This definitely should do the trick. Thanks a lot! Commented Jul 23, 2015 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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