aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2007-06-04 23:49:26 +0000
committerChong Yidong2007-06-04 23:49:26 +0000
commit7e285b363fa39b4ec1bd649429a178384542d428 (patch)
tree970df62612322f3fbd39fdc129f22af9a90893d4
parent89cd203073dc3196199ebd914d607795d469d44f (diff)
downloademacs-7e285b363fa39b4ec1bd649429a178384542d428.tar.gz
emacs-7e285b363fa39b4ec1bd649429a178384542d428.zip
Update version number.
(timeclock-modeline-display): Mention timeclock-use-display-time in explanatory message. (timeclock-log): Suppress warnings when finding the log. Don't check for a nil project twice. Run hooks after killing the buffer (if applicable). (timeclock-geometric-mean): Rename to `timeclock-mean' (it never was geometric). All uses changed. (timeclock-generate-report): Support prefix argument.
-rw-r--r--lisp/calendar/timeclock.el65
1 files changed, 46 insertions, 19 deletions
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 4e6e4120404..edadd2ceaea 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -5,7 +5,7 @@
5 5
6;; Author: John Wiegley <johnw@gnu.org> 6;; Author: John Wiegley <johnw@gnu.org>
7;; Created: 25 Mar 1999 7;; Created: 25 Mar 1999
8;; Version: 2.6 8;; Version: 2.6.1
9;; Keywords: calendar data 9;; Keywords: calendar data
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
@@ -304,8 +304,8 @@ display (non-nil means on)."
304 ;; Update immediately so there is a visible change 304 ;; Update immediately so there is a visible change
305 ;; on calling this function. 305 ;; on calling this function.
306 (if display-time-mode (timeclock-update-modeline) 306 (if display-time-mode (timeclock-update-modeline)
307 (message "Activate `display-time-mode' to see \ 307 (message "Activate `display-time-mode' or turn off \
308timeclock information")) 308`timeclock-use-display-time' to see timeclock information"))
309 (add-hook 'display-time-hook 'timeclock-update-modeline)) 309 (add-hook 'display-time-hook 'timeclock-update-modeline))
310 (setq timeclock-update-timer 310 (setq timeclock-update-timer
311 (run-at-time nil 60 'timeclock-update-modeline)))) 311 (run-at-time nil 60 'timeclock-update-modeline))))
@@ -589,6 +589,38 @@ relative only to the time worked today, and not to past time."
589 (message "%s" string) 589 (message "%s" string)
590 string))) 590 string)))
591 591
592(defun timeclock-make-hours-explicit (old-default)
593 "Specify all workday lengths in `timeclock-file'.
594OLD-DEFAULT hours are set for every day that has no number indicated."
595 (interactive "P")
596 (if old-default (setq old-default (prefix-numeric-value old-default))
597 (error "timelog-make-hours-explicit requires an explicit argument"))
598 (let ((extant-timelog (find-buffer-visiting timeclock-file))
599 current-date)
600 (with-current-buffer (find-file-noselect timeclock-file t)
601 (unwind-protect
602 (save-excursion
603 (save-restriction
604 (widen)
605 (goto-char (point-min))
606 (while (progn (skip-chars-forward "\n") (not (eobp)))
607 ;; This is just a variant of `timeclock-moment-regexp'.
608 (unless (looking-at
609 (concat "^\\([bhioO]\\) \\([0-9]+/[0-9]+/[0-9]+\\) "
610 "\\([0-9]+:[0-9]+:[0-9]+\\)"))
611 (error "Can't parse `%s'" timeclock-file))
612 (let ((this-date (match-string 2)))
613 (unless (or (and current-date
614 (string= this-date current-date))
615 (string= (match-string 1) "h"))
616 (insert (format "h %s %s %s\n" (match-string 2)
617 (match-string 3) old-default)))
618 (if (string-match "^[ih]" (match-string 1)) ; ignore logouts
619 (setq current-date this-date)))
620 (forward-line))
621 (save-buffer)))
622 (unless extant-timelog (kill-buffer (current-buffer)))))))
623
592;;; Internal Functions: 624;;; Internal Functions:
593 625
594(defvar timeclock-project-list nil) 626(defvar timeclock-project-list nil)
@@ -653,7 +685,7 @@ that variable's documentation."
653If PROJECT is a string, it represents the project which the event is 685If PROJECT is a string, it represents the project which the event is
654being logged for. Normally only \"in\" events specify a project." 686being logged for. Normally only \"in\" events specify a project."
655 (let ((extant-timelog (find-buffer-visiting timeclock-file))) 687 (let ((extant-timelog (find-buffer-visiting timeclock-file)))
656 (with-current-buffer (find-file-noselect timeclock-file) 688 (with-current-buffer (find-file-noselect timeclock-file t)
657 (save-excursion 689 (save-excursion
658 (save-restriction 690 (save-restriction
659 (widen) 691 (widen)
@@ -663,8 +695,7 @@ being logged for. Normally only \"in\" events specify a project."
663 (let ((now (current-time))) 695 (let ((now (current-time)))
664 (insert code " " 696 (insert code " "
665 (format-time-string "%Y/%m/%d %H:%M:%S" now) 697 (format-time-string "%Y/%m/%d %H:%M:%S" now)
666 (or (and project 698 (or (and (stringp project)
667 (stringp project)
668 (> (length project) 0) 699 (> (length project) 0)
669 (concat " " project)) 700 (concat " " project))
670 "") 701 "")
@@ -679,8 +710,8 @@ being logged for. Normally only \"in\" events specify a project."
679 timeclock-last-period))) 710 timeclock-last-period)))
680 (setq timeclock-last-event (list code now project))))) 711 (setq timeclock-last-event (list code now project)))))
681 (save-buffer) 712 (save-buffer)
682 (run-hooks 'timeclock-event-hook) 713 (unless extant-timelog (kill-buffer (current-buffer)))))
683 (unless extant-timelog (kill-buffer (current-buffer)))))) 714 (run-hooks 'timeclock-event-hook))
684 715
685(defvar timeclock-moment-regexp 716(defvar timeclock-moment-regexp
686 (concat "\\([bhioO]\\)\\s-+" 717 (concat "\\([bhioO]\\)\\s-+"
@@ -1152,8 +1183,8 @@ If optional argument TIME is non-nil, use that instead of the current time."
1152 (setcar (nthcdr 2 decoded) 0) 1183 (setcar (nthcdr 2 decoded) 0)
1153 (apply 'encode-time decoded))) 1184 (apply 'encode-time decoded)))
1154 1185
1155(defun timeclock-geometric-mean (l) 1186(defun timeclock-mean (l)
1156 "Compute the geometric mean of the values in the list L." 1187 "Compute the arithmetic mean of the values in the list L."
1157 (let ((total 0) 1188 (let ((total 0)
1158 (count 0)) 1189 (count 0))
1159 (while l 1190 (while l
@@ -1168,7 +1199,7 @@ If optional argument TIME is non-nil, use that instead of the current time."
1168 "Generate a summary report based on the current timelog file. 1199 "Generate a summary report based on the current timelog file.
1169By default, the report is in plain text, but if the optional argument 1200By default, the report is in plain text, but if the optional argument
1170HTML-P is non-nil, HTML markup is added." 1201HTML-P is non-nil, HTML markup is added."
1171 (interactive) 1202 (interactive "P")
1172 (let ((log (timeclock-log-data)) 1203 (let ((log (timeclock-log-data))
1173 (today (timeclock-day-base))) 1204 (today (timeclock-day-base)))
1174 (if html-p (insert "<p>")) 1205 (if html-p (insert "<p>"))
@@ -1300,14 +1331,10 @@ HTML-P is non-nil, HTML markup is added."
1300 ;; average statistics 1331 ;; average statistics
1301 (let ((i 0) (l 5)) 1332 (let ((i 0) (l 5))
1302 (while (< i l) 1333 (while (< i l)
1303 (aset time-in i (timeclock-geometric-mean 1334 (aset time-in i (timeclock-mean (cdr (aref time-in i))))
1304 (cdr (aref time-in i)))) 1335 (aset time-out i (timeclock-mean (cdr (aref time-out i))))
1305 (aset time-out i (timeclock-geometric-mean 1336 (aset breaks i (timeclock-mean (cdr (aref breaks i))))
1306 (cdr (aref time-out i)))) 1337 (aset workday i (timeclock-mean (cdr (aref workday i))))
1307 (aset breaks i (timeclock-geometric-mean
1308 (cdr (aref breaks i))))
1309 (aset workday i (timeclock-geometric-mean
1310 (cdr (aref workday i))))
1311 (setq i (1+ i)))) 1338 (setq i (1+ i))))
1312 ;; Output the HTML table 1339 ;; Output the HTML table
1313 (insert "<tr>\n") 1340 (insert "<tr>\n")