compilation-exit-message-function is a variable defined in `compile.el'.
Its value is

  • This variable may be risky if used as a file-local variable.

If non-nil, called when a compilation process dies to return a status message.
This should be a function of three arguments: process status, exit status,
and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
write into the compilation buffer, and to put in its mode line.