From 3dc630b9e18cac41246c81e2d7d11c25857f4e58 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 24 Apr 2001 01:39:55 +0000 Subject: [PATCH] (timeclock-day-required): If the time required for a particular day is not set, use `timeclock-workday'. (timeclock-find-discrep): Added some sample code in a comment. --- lisp/ChangeLog | 31 +++++++++++ lisp/calendar/timeclock.el | 102 ++++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 47 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index edc8d51a1e4..b47aa3576f3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,34 @@ +2001-04-23 John Wiegley + + * calendar/timeclock.el (timeclock-day-required): If the time + required for a particular day is not set, use `timeclock-workday'. + (timeclock-find-discrep): Added some sample code in a comment. + + * eshell/eshell.el (eshell-command): Made a few changes so that + `eshell-command' could be called programmatically. + + * eshell/esh-mode.el: Moved `eshell-non-interactive-p' to + eshell.el. + + * eshell/eshell.el (eshell-non-interactive-p): Moved this variable + here. + +2001-04-22 John Wiegley + + * calendar/timeclock.el: Updated copyright. + (timeclock-generate-report): Don't report the daily or two-week + total, if no time has been worked in that period. + (timeclock-find-discrep): Moved call to `file-readable-p'; removed + final computational form, which was unnecessary; corrected a + parsing problem when timeclock-relative was nil. + +2001-04-22 Kahlil Hodgson + + * calendar/timeclock.el (timeclock-modeline-display): Check if + `list-entry' is null. + (timeclock-use-display-time): The first argument to `set-variable' + must be a symbol. + 2001-04-23 Eli Zaretskii * calendar/calendar.el (diary-entry-marker) diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 82d1e4c3490..bb4976a1ca2 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el @@ -1,6 +1,6 @@ ;;; timeclock.el --- mode for keeping track of how much you work -;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Created: 25 Mar 1999 @@ -170,10 +170,10 @@ take effect." timeclock-update-timer))) (setq currently-displaying nil)) (and currently-displaying - (set-variable timeclock-modeline-display nil)) + (set-variable 'timeclock-modeline-display nil)) (setq timeclock-use-display-time value) (and currently-displaying - (set-variable timeclock-modeline-display t)) + (set-variable 'timeclock-modeline-display t)) timeclock-use-display-time)) :type 'boolean :group 'timeclock @@ -275,7 +275,8 @@ positive. Returns the new status of timeclock modeline display (if on-p (let ((list-entry (memq 'global-mode-string mode-line-format))) - (unless (memq 'timeclock-mode-string mode-line-format) + (unless (or (null list-entry) + (memq 'timeclock-mode-string mode-line-format)) (setcdr list-entry (cons 'timeclock-mode-string (cdr list-entry)))) @@ -712,7 +713,7 @@ This is only provided for coherency when used by (defsubst timeclock-day-required (day) - (car day)) + (or (car day) timeclock-workday)) (defsubst timeclock-day-length (day) (timeclock-entry-list-length (cdr day))) @@ -998,13 +999,23 @@ identical to what would be return if `timeclock-relative' were nil." ;; This is not implemented in terms of the functions above, because ;; it's a bit wasteful to read all of that data in, just to throw ;; away more than 90% of the information afterwards. - (when (file-readable-p timeclock-file) - (let* ((now (current-time)) - (todays-date (timeclock-time-to-date now)) - (first t) (accum 0) - event beg last-date avg - last-date-limited last-date-seconds) - (unless timeclock-discrepancy + ;; + ;; If it were implemented using those functions, it would look + ;; something like this: + ;; (let ((days (timeclock-day-alist (timeclock-log-data))) + ;; (total 0.0)) + ;; (while days + ;; (setq total (+ total (- (timeclock-day-length (cdar days)) + ;; (timeclock-day-required (cdar days)))) + ;; days (cdr days))) + ;; total) + (let* ((now (current-time)) + (todays-date (timeclock-time-to-date now)) + (first t) (accum 0) + event beg last-date avg + last-date-limited last-date-seconds) + (unless timeclock-discrepancy + (when (file-readable-p timeclock-file) (setq timeclock-project-list nil timeclock-last-project nil timeclock-reason-list nil @@ -1028,10 +1039,11 @@ identical to what would be return if `timeclock-relative' were nil." (add-to-list 'timeclock-project-list (nth 2 event)) (setq timeclock-last-project (nth 2 event))) (let ((date (timeclock-time-to-date (cadr event)))) - (if (and timeclock-relative - (if last-date - (not (equal date last-date)) - first)) + (if (if timeclock-relative + (if last-date + (not (equal date last-date)) + first) + (equal date todays-date)) (setq first nil accum (- accum (if last-date-limited @@ -1051,39 +1063,31 @@ identical to what would be return if `timeclock-relative' were nil." (if (not beg) (error "Error in format of timelog file!") (setq timeclock-last-period - (- (timeclock-time-to-seconds (cadr event)) - beg) + (- (timeclock-time-to-seconds (cadr event)) beg) accum (+ timeclock-last-period accum) - beg nil))) + beg nil)) + (setq beg nil)) (if (equal last-date todays-date) (setq timeclock-elapsed (+ timeclock-last-period timeclock-elapsed))))) (setq timeclock-last-event event timeclock-last-event-workday - (if (equal (timeclock-time-to-date now) - last-date-limited) + (if (equal (timeclock-time-to-date now) last-date-limited) last-date-seconds timeclock-workday)) (forward-line)) - (setq timeclock-discrepancy accum))) - (setq accum (if today-only - timeclock-elapsed - timeclock-discrepancy)) - (if timeclock-last-event - (if (equal (car timeclock-last-event) "i") - (setq accum (+ accum (timeclock-last-period now))) - (if (not (equal (timeclock-time-to-date - (cadr timeclock-last-event)) - (timeclock-time-to-date now))) - (setq accum (- accum timeclock-last-event-workday))))) - (setq accum - (- accum - (if (and timeclock-last-event - (equal (timeclock-time-to-date - (cadr timeclock-last-event)) - (timeclock-time-to-date now))) - timeclock-last-event-workday - timeclock-workday)))))) + (setq timeclock-discrepancy accum)))) + (setq accum (if today-only + timeclock-elapsed + timeclock-discrepancy)) + (if timeclock-last-event + (if (equal (car timeclock-last-event) "i") + (setq accum (+ accum (timeclock-last-period now))) + (if (not (equal (timeclock-time-to-date + (cadr timeclock-last-event)) + (timeclock-time-to-date now))) + (setq accum (- accum timeclock-last-event-workday))))) + accum)) ;;; A reporting function that uses timeclock-log-data @@ -1158,10 +1162,14 @@ identical to what would be return if `timeclock-relative' were nil." (if (null two-week-len) (setq two-week-len today-len)) (if html-p (insert "

")) - (insert "\nTime spent on this task today: " - (timeclock-seconds-to-string today-len) - ". In the last two weeks: " - (timeclock-seconds-to-string two-week-len)) + (if today-len + (insert "\nTime spent on this task today: " + (timeclock-seconds-to-string today-len) + ". In the last two weeks: " + (timeclock-seconds-to-string two-week-len)) + (if two-week-len + (insert "\nTime spent on this task in the last two weeks: " + (timeclock-seconds-to-string two-week-len)))) (if html-p (insert "
")) (insert "\n" (timeclock-seconds-to-string (timeclock-workday-elapsed)) @@ -1262,7 +1270,7 @@ identical to what would be return if `timeclock-relative' were nil." "\n") (setq i (1+ i)))) (insert "\n") - + (insert "\n") (insert "Time out\n") (let ((i 0) (l 5)) @@ -1272,7 +1280,7 @@ identical to what would be return if `timeclock-relative' were nil." "\n") (setq i (1+ i)))) (insert "\n") - + (insert "\n") (insert "Break\n") (let ((i 0) (l 5)) @@ -1282,7 +1290,7 @@ identical to what would be return if `timeclock-relative' were nil." "\n") (setq i (1+ i)))) (insert "\n") - + (insert "\n") (insert "Workday\n") (let ((i 0) (l 5)) -- 2.39.2