diff options
| author | Richard M. Stallman | 2007-05-01 15:25:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2007-05-01 15:25:21 +0000 |
| commit | b94bc09b74906694d2346a2704d2fdf06e6fc24f (patch) | |
| tree | e2c81bcb5ab2337ec4d2bfeca84de85cd8d7c6c4 | |
| parent | 04990d03893eae9145571eb71f1974af7dd499f6 (diff) | |
| download | emacs-b94bc09b74906694d2346a2704d2fdf06e6fc24f.tar.gz emacs-b94bc09b74906694d2346a2704d2fdf06e6fc24f.zip | |
Update version number.
(timeclock-modeline-display): Mention timeclock-use-display-time
in explanatory message.
(timeclock-in): Fix non-interactive workday specifications.
(timeclock-log): Don't kill the log buffer if it already existed.
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/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/calendar/timeclock.el | 114 |
2 files changed, 87 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30ebd225ed2..4d2538452e5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2007-05-01 Davis Herring <herring@lanl.gov> | ||
| 2 | |||
| 3 | * calendar/timeclock.el: Update version number. | ||
| 4 | (timeclock-modeline-display): Mention timeclock-use-display-time | ||
| 5 | in explanatory message. | ||
| 6 | (timeclock-in): Fix non-interactive workday specifications. | ||
| 7 | (timeclock-log): Don't kill the log buffer if it already existed. | ||
| 8 | Suppress warnings when finding the log. Don't check for a nil | ||
| 9 | project twice. Run hooks after killing the buffer (if | ||
| 10 | applicable). | ||
| 11 | (timeclock-geometric-mean): Rename to `timeclock-mean' (it never | ||
| 12 | was geometric). All uses changed. | ||
| 13 | (timeclock-generate-report): Support prefix argument. | ||
| 14 | |||
| 1 | 2007-05-01 Romain Francoise <romain@orebokech.com> | 15 | 2007-05-01 Romain Francoise <romain@orebokech.com> |
| 2 | 16 | ||
| 3 | * dired-x.el: Revert 2007-04-06 change. | 17 | * dired-x.el: Revert 2007-04-06 change. |
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 398b2dd1de5..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 \ |
| 308 | timeclock 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)))) |
| @@ -375,8 +375,9 @@ discover the name of the project." | |||
| 375 | (setq timeclock-discrepancy | 375 | (setq timeclock-discrepancy |
| 376 | (- (or timeclock-discrepancy 0) workday)) | 376 | (- (or timeclock-discrepancy 0) workday)) |
| 377 | (if (not (= workday timeclock-workday)) | 377 | (if (not (= workday timeclock-workday)) |
| 378 | (timeclock-log "h" (and (numberp arg) | 378 | (timeclock-log "h" (number-to-string |
| 379 | (number-to-string arg)))))) | 379 | (/ workday (if (zerop (% workday (* 60 60))) |
| 380 | 60 60.0) 60)))))) | ||
| 380 | (timeclock-log "i" (or project | 381 | (timeclock-log "i" (or project |
| 381 | (and timeclock-get-project-function | 382 | (and timeclock-get-project-function |
| 382 | (or find-project (interactive-p)) | 383 | (or find-project (interactive-p)) |
| @@ -588,6 +589,38 @@ relative only to the time worked today, and not to past time." | |||
| 588 | (message "%s" string) | 589 | (message "%s" string) |
| 589 | string))) | 590 | string))) |
| 590 | 591 | ||
| 592 | (defun timeclock-make-hours-explicit (old-default) | ||
| 593 | "Specify all workday lengths in `timeclock-file'. | ||
| 594 | OLD-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 | |||
| 591 | ;;; Internal Functions: | 624 | ;;; Internal Functions: |
| 592 | 625 | ||
| 593 | (defvar timeclock-project-list nil) | 626 | (defvar timeclock-project-list nil) |
| @@ -651,31 +684,34 @@ that variable's documentation." | |||
| 651 | "Log the event CODE to the timeclock log, at the time of call. | 684 | "Log the event CODE to the timeclock log, at the time of call. |
| 652 | If PROJECT is a string, it represents the project which the event is | 685 | If PROJECT is a string, it represents the project which the event is |
| 653 | being logged for. Normally only \"in\" events specify a project." | 686 | being logged for. Normally only \"in\" events specify a project." |
| 654 | (with-current-buffer (find-file-noselect timeclock-file) | 687 | (let ((extant-timelog (find-buffer-visiting timeclock-file))) |
| 655 | (goto-char (point-max)) | 688 | (with-current-buffer (find-file-noselect timeclock-file t) |
| 656 | (if (not (bolp)) | 689 | (save-excursion |
| 657 | (insert "\n")) | 690 | (save-restriction |
| 658 | (let ((now (current-time))) | 691 | (widen) |
| 659 | (insert code " " | 692 | (goto-char (point-max)) |
| 660 | (format-time-string "%Y/%m/%d %H:%M:%S" now) | 693 | (if (not (bolp)) |
| 661 | (or (and project | 694 | (insert "\n")) |
| 662 | (stringp project) | 695 | (let ((now (current-time))) |
| 663 | (> (length project) 0) | 696 | (insert code " " |
| 664 | (concat " " project)) | 697 | (format-time-string "%Y/%m/%d %H:%M:%S" now) |
| 665 | "") | 698 | (or (and (stringp project) |
| 666 | "\n") | 699 | (> (length project) 0) |
| 667 | (if (equal (downcase code) "o") | 700 | (concat " " project)) |
| 668 | (setq timeclock-last-period | 701 | "") |
| 669 | (- (timeclock-time-to-seconds now) | 702 | "\n") |
| 670 | (timeclock-time-to-seconds | 703 | (if (equal (downcase code) "o") |
| 671 | (cadr timeclock-last-event))) | 704 | (setq timeclock-last-period |
| 672 | timeclock-discrepancy | 705 | (- (timeclock-time-to-seconds now) |
| 673 | (+ timeclock-discrepancy | 706 | (timeclock-time-to-seconds |
| 674 | timeclock-last-period))) | 707 | (cadr timeclock-last-event))) |
| 675 | (setq timeclock-last-event (list code now project))) | 708 | timeclock-discrepancy |
| 676 | (save-buffer) | 709 | (+ timeclock-discrepancy |
| 677 | (run-hooks 'timeclock-event-hook) | 710 | timeclock-last-period))) |
| 678 | (kill-buffer (current-buffer)))) | 711 | (setq timeclock-last-event (list code now project))))) |
| 712 | (save-buffer) | ||
| 713 | (unless extant-timelog (kill-buffer (current-buffer))))) | ||
| 714 | (run-hooks 'timeclock-event-hook)) | ||
| 679 | 715 | ||
| 680 | (defvar timeclock-moment-regexp | 716 | (defvar timeclock-moment-regexp |
| 681 | (concat "\\([bhioO]\\)\\s-+" | 717 | (concat "\\([bhioO]\\)\\s-+" |
| @@ -1147,8 +1183,8 @@ If optional argument TIME is non-nil, use that instead of the current time." | |||
| 1147 | (setcar (nthcdr 2 decoded) 0) | 1183 | (setcar (nthcdr 2 decoded) 0) |
| 1148 | (apply 'encode-time decoded))) | 1184 | (apply 'encode-time decoded))) |
| 1149 | 1185 | ||
| 1150 | (defun timeclock-geometric-mean (l) | 1186 | (defun timeclock-mean (l) |
| 1151 | "Compute the geometric mean of the values in the list L." | 1187 | "Compute the arithmetic mean of the values in the list L." |
| 1152 | (let ((total 0) | 1188 | (let ((total 0) |
| 1153 | (count 0)) | 1189 | (count 0)) |
| 1154 | (while l | 1190 | (while l |
| @@ -1163,7 +1199,7 @@ If optional argument TIME is non-nil, use that instead of the current time." | |||
| 1163 | "Generate a summary report based on the current timelog file. | 1199 | "Generate a summary report based on the current timelog file. |
| 1164 | By default, the report is in plain text, but if the optional argument | 1200 | By default, the report is in plain text, but if the optional argument |
| 1165 | HTML-P is non-nil, HTML markup is added." | 1201 | HTML-P is non-nil, HTML markup is added." |
| 1166 | (interactive) | 1202 | (interactive "P") |
| 1167 | (let ((log (timeclock-log-data)) | 1203 | (let ((log (timeclock-log-data)) |
| 1168 | (today (timeclock-day-base))) | 1204 | (today (timeclock-day-base))) |
| 1169 | (if html-p (insert "<p>")) | 1205 | (if html-p (insert "<p>")) |
| @@ -1295,14 +1331,10 @@ HTML-P is non-nil, HTML markup is added." | |||
| 1295 | ;; average statistics | 1331 | ;; average statistics |
| 1296 | (let ((i 0) (l 5)) | 1332 | (let ((i 0) (l 5)) |
| 1297 | (while (< i l) | 1333 | (while (< i l) |
| 1298 | (aset time-in i (timeclock-geometric-mean | 1334 | (aset time-in i (timeclock-mean (cdr (aref time-in i)))) |
| 1299 | (cdr (aref time-in i)))) | 1335 | (aset time-out i (timeclock-mean (cdr (aref time-out i)))) |
| 1300 | (aset time-out i (timeclock-geometric-mean | 1336 | (aset breaks i (timeclock-mean (cdr (aref breaks i)))) |
| 1301 | (cdr (aref time-out i)))) | 1337 | (aset workday i (timeclock-mean (cdr (aref workday i)))) |
| 1302 | (aset breaks i (timeclock-geometric-mean | ||
| 1303 | (cdr (aref breaks i)))) | ||
| 1304 | (aset workday i (timeclock-geometric-mean | ||
| 1305 | (cdr (aref workday i)))) | ||
| 1306 | (setq i (1+ i)))) | 1338 | (setq i (1+ i)))) |
| 1307 | ;; Output the HTML table | 1339 | ;; Output the HTML table |
| 1308 | (insert "<tr>\n") | 1340 | (insert "<tr>\n") |