[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cc533f23386: Show duration of compilation when it stops (bug#6525
From: |
Mattias Engdegård |
Subject: |
master cc533f23386: Show duration of compilation when it stops (bug#65251) |
Date: |
Fri, 18 Aug 2023 07:58:10 -0400 (EDT) |
branch: master
commit cc533f23386984bc3bb2c98d227d7e56e4b7b7a7
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Show duration of compilation when it stops (bug#65251)
Patch by Helmut Eller, lightly edited.
* lisp/progmodes/compile.el (compilation--start-time): New variable.
(compilation-start): Set it.
(compilation-handle-exit): Display duration.
---
lisp/progmodes/compile.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 6d151db8a83..f85cc0909dd 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1862,6 +1862,9 @@ process from additional information inserted by Emacs."
(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)
@@ -1993,6 +1996,7 @@ Returns the compilation buffer created."
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.
@@ -2480,7 +2484,14 @@ commands of Compilation major mode are available. See
(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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master cc533f23386: Show duration of compilation when it stops (bug#65251),
Mattias Engdegård <=