Hi all,

I have finally become bored enough of going to Eshell and saying "time
pdflatex <whetever>" instead of just pressing C-c C-c that I decided to
spend a few minutes writing this quite trivial patch.  I would be
thankful for reviewing it and telling me what I should change in case
I messed something up (or accepting it if I didn't;-)).

TIA,

--
Marcin Borkowski
>From 550692d0ddc72b7fe29ecfbfa952b3a6849f44a8 Mon Sep 17 00:00:00 2001
From: Marcin Borkowski <[email protected]>
Date: Sun, 19 Feb 2017 08:41:04 +0100
Subject: [PATCH] Add info about compilation time to the "success" message

---
 tex-buf.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tex-buf.el b/tex-buf.el
index 64977774..eadf659c 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -471,6 +471,8 @@ Do you want to select one of these engines?"
   :group 'TeX-command
   :type 'integer)
 
+(defvar TeX-start-time nil "Starting time of compilation.")
+
 (defun TeX-command (name file &optional override-confirm)
   "Run command NAME on the file returned by calling FILE.
 
@@ -530,6 +532,7 @@ remember to add /Library/TeX/texbin/ to your PATH"
 
     ;; Now start the process
     (setq file (funcall file))
+    (setq TeX-start-time (current-time))
     (TeX-process-set-variable file 'TeX-command-next TeX-command-Show)
     (funcall hook name command file)))
 
@@ -1414,6 +1417,12 @@ errors or warnings to show."
 	(t
 	 (concat TeX-current-page " pages"))))
 
+(defun TeX-compilation-time ()
+  "Return string indicating the compilation time."
+  (cond ((null TeX-start-time)
+	 "")
+	(t (format " in %.1f seconds" (time-to-seconds (time-subtract (current-time) TeX-start-time))))))
+
 (defun TeX-TeX-sentinel-check (process name)
   "Cleanup TeX output buffer after running TeX.
 Return nil ifs no errors were found."
@@ -1594,7 +1603,9 @@ Rerun to get mark in right position\\." nil t)
 				    (when bad-boxes "bad boxes")
 				    ")"))))
 	   (message "%s" (concat name ": successfully formatted "
-				 (TeX-current-pages) add-info)))
+				 (TeX-current-pages)
+				 (TeX-compilation-time)
+				 add-info)))
 	 (let (dvi2pdf)
 	   (if (with-current-buffer TeX-command-buffer
 		 (and TeX-PDF-mode (setq dvi2pdf (TeX-PDF-from-DVI))))
-- 
2.11.1

_______________________________________________
auctex-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to