Function: compilation-handle-exit
compilation-handle-exit is a byte-compiled function defined in
compile.el.gz.
Signature
(compilation-handle-exit PROCESS-STATUS EXIT-STATUS MSG)
Documentation
Write MSG in the current buffer and hack its mode-line-process.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/compile.el.gz
(defun compilation-handle-exit (process-status exit-status msg)
"Write MSG in the current buffer and hack its `mode-line-process'."
(let ((inhibit-read-only t)
(status (if compilation-exit-message-function
(funcall compilation-exit-message-function
process-status exit-status msg)
(cons msg exit-status)))
(omax (point-max))
(opoint (point))
(cur-buffer (current-buffer)))
;; Record where we put the message, so we can ignore it later on.
(goto-char omax)
(compilation-insert-annotation ?\n mode-name " " (car status))
(if (and (numberp compilation-window-height)
(zerop compilation-window-height))
(message "%s" (cdr status)))
(if (bolp)
(forward-char -1))
(compilation-insert-annotation
" at "
(substring (current-time-string) 0 19)
", duration "
(let ((elapsed (- (float-time) compilation--start-time)))
(cond ((< elapsed 10) (format "%.2f s" elapsed))
((< elapsed 60) (format "%.1f s" elapsed))
(t (format-seconds "%h:%02m:%02s" elapsed)))))
(goto-char (point-max))
;; Prevent that message from being recognized as a compilation error.
(add-text-properties omax (point)
(append '(compilation-handle-exit t) nil))
(setq mode-line-process
(list
(let ((out-string (format ":%s [%s]" process-status (cdr status)))
(msg (format "%s %s" mode-name
(replace-regexp-in-string "\n?$" ""
(car status)))))
(message "%s" msg)
(propertize out-string
'help-echo msg
'face (if (> exit-status 0)
'compilation-mode-line-fail
'compilation-mode-line-exit)))
compilation-mode-line-errors))
;; Force mode line redisplay soon.
(force-mode-line-update)
(if (and opoint (< opoint omax))
(goto-char opoint))
(run-hook-with-args 'compilation-finish-functions cur-buffer msg)))