Subject: bug#52018: 28.0.60; Improve documentation for compilation-finish-functions

From: Thibault Polge <[email-masked]>
Date: Sun, 21 Nov 2021 21:20:28 +0100

> The function is called with the compilation buffer, right?  And the
> compilation process runs in that buffer, right?  So the function can
> call get-buffer-process, and then access the exit status via
> process-exit-status.

I actually tried that, but the docstring for get-buffer-process says the
process must be live.  The following attempt fails:

(add-hook 'compilation-finish-functions
          (defun my-compilation-finish-function (buffer _)
            (let ((process (get-buffer-process buffer)))
              (message "Is there a buffer? %s" (bufferp buffer))
              (message "Is there a process? %s" (not (null process)))
              (message "Its status is: %s" (process-exit-status process)))))

Fails with:

Is there a buffer? t
Is there a process? nil
error in process sentinel: message: Wrong type argument: processp, nil
error in process sentinel: Wrong type argument: processp, nil