(apply #'insert args)
(put-text-property start (point) 'compilation-annotation t)))
+(defvar-local compilation--start-time nil
+ "The time when the compilation started as returned by `float-time'.")
+
;;;###autoload
(defun compilation-start (command &optional mode name-function highlight-regexp
continue)
mode-name
(substring (current-time-string) 0 19))
command "\n")
+ (setq compilation--start-time (float-time))
(setq thisdir default-directory))
(set-buffer-modified-p nil))
;; Pop up the compilation buffer.
(message "%s" (cdr status)))
(if (bolp)
(forward-char -1))
- (compilation-insert-annotation " at " (substring (current-time-string) 0 19))
+ (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)