diff options
| author | Glenn Morris | 2003-05-27 18:36:40 +0000 |
|---|---|---|
| committer | Glenn Morris | 2003-05-27 18:36:40 +0000 |
| commit | 9d1137ce044c1aa65087dd921f78819b81661cbd (patch) | |
| tree | 6415bd2e32906689ec7dfafd08e0e060e9289f4f | |
| parent | 5740acbaeb67583e4cd56f7335ce412c6439c9af (diff) | |
| download | emacs-9d1137ce044c1aa65087dd921f78819b81661cbd.tar.gz emacs-9d1137ce044c1aa65087dd921f78819b81661cbd.zip | |
Update copyright.
(timeclock-ask-before-exiting): Put `timeclock-query-out' on
`kill-emacs-query-functions' rather than `kill-emacs-hook'.
(timeclock-mode-string): Doc fix.
(timeclock-modeline-display): Doc fix. Use `global-mode-string' rather
than `mode-line-format'.
(timeclock-query-out): Doc fix.
(timeclock-update-modeline): No need for `let*', so use `let'.
Add some help-echo text to `timeclock-mode-string'.
(timeclock-mode-string): Give it the risky-local-variable property,
so that help-echo text will display.
(timeclock-find-discrep): Set `accum' to 0 if `timeclock-discrepancy' is nil.
| -rw-r--r-- | lisp/calendar/timeclock.el | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 2d1bd25ebec..010a5aa89cc 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; timeclock.el --- mode for keeping track of how much you work | 1 | ;;; timeclock.el --- mode for keeping track of how much you work |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: John Wiegley <johnw@gnu.org> | 5 | ;; Author: John Wiegley <johnw@gnu.org> |
| 6 | ;; Created: 25 Mar 1999 | 6 | ;; Created: 25 Mar 1999 |
| @@ -64,7 +64,7 @@ | |||
| 64 | ;; `timeclock-ask-before-exiting' to t using M-x customize (this is | 64 | ;; `timeclock-ask-before-exiting' to t using M-x customize (this is |
| 65 | ;; the default), or by adding the following to your .emacs file: | 65 | ;; the default), or by adding the following to your .emacs file: |
| 66 | ;; | 66 | ;; |
| 67 | ;; (add-hook 'kill-emacs-hook 'timeclock-query-out) | 67 | ;; (add-hook 'kill-emacs-query-functions 'timeclock-query-out) |
| 68 | 68 | ||
| 69 | ;; NOTE: If you change your .timelog file without using timeclock's | 69 | ;; NOTE: If you change your .timelog file without using timeclock's |
| 70 | ;; functions, or if you change the value of any of timeclock's | 70 | ;; functions, or if you change the value of any of timeclock's |
| @@ -135,8 +135,8 @@ that day has a different length from the norm." | |||
| 135 | "*If non-nil, ask if the user wants to clock out before exiting Emacs." | 135 | "*If non-nil, ask if the user wants to clock out before exiting Emacs." |
| 136 | :set (lambda (symbol value) | 136 | :set (lambda (symbol value) |
| 137 | (if value | 137 | (if value |
| 138 | (add-hook 'kill-emacs-hook 'timeclock-query-out) | 138 | (add-hook 'kill-emacs-query-functions 'timeclock-query-out) |
| 139 | (remove-hook 'kill-emacs-hook 'timeclock-query-out)) | 139 | (remove-hook 'kill-emacs-query-functions 'timeclock-query-out)) |
| 140 | (setq timeclock-ask-before-exiting value)) | 140 | (setq timeclock-ask-before-exiting value)) |
| 141 | :type 'boolean | 141 | :type 'boolean |
| 142 | :group 'timeclock) | 142 | :group 'timeclock) |
| @@ -252,7 +252,8 @@ Note that you shouldn't access this value, but should use the function | |||
| 252 | `timeclock-last-period' instead.") | 252 | `timeclock-last-period' instead.") |
| 253 | 253 | ||
| 254 | (defvar timeclock-mode-string nil | 254 | (defvar timeclock-mode-string nil |
| 255 | "The timeclock string (optionally) displayed in the modeline.") | 255 | "The timeclock string (optionally) displayed in the modeline. |
| 256 | The time is bracketed by <> if you are clocked in, otherwise by [].") | ||
| 256 | 257 | ||
| 257 | (defvar timeclock-day-over nil | 258 | (defvar timeclock-day-over nil |
| 258 | "The date of the last day when notified \"day over\" for.") | 259 | "The date of the last day when notified \"day over\" for.") |
| @@ -262,24 +263,25 @@ Note that you shouldn't access this value, but should use the function | |||
| 262 | ;;;###autoload | 263 | ;;;###autoload |
| 263 | (defun timeclock-modeline-display (&optional arg) | 264 | (defun timeclock-modeline-display (&optional arg) |
| 264 | "Toggle display of the amount of time left today in the modeline. | 265 | "Toggle display of the amount of time left today in the modeline. |
| 265 | If `timeclock-use-display-time' is non-nil, the modeline will be | 266 | If `timeclock-use-display-time' is non-nil (the default), then |
| 266 | updated whenever the time display is updated. Otherwise, the | 267 | the function `display-time-mode' must be active, and the modeline |
| 267 | timeclock will use its own sixty second timer to do its updating. | 268 | will be updated whenever the time display is updated. Otherwise, |
| 268 | With prefix ARG, turn modeline display on if and only if ARG is | 269 | the timeclock will use its own sixty second timer to do its |
| 269 | positive. Returns the new status of timeclock modeline display | 270 | updating. With prefix ARG, turn modeline display on if and only |
| 270 | \(non-nil means on)." | 271 | if ARG is positive. Returns the new status of timeclock modeline |
| 272 | display (non-nil means on)." | ||
| 271 | (interactive "P") | 273 | (interactive "P") |
| 274 | ;; cf display-time-mode. | ||
| 275 | (setq timeclock-mode-string "") | ||
| 276 | (or global-mode-string (setq global-mode-string '(""))) | ||
| 272 | (let ((on-p (if arg | 277 | (let ((on-p (if arg |
| 273 | (> (prefix-numeric-value arg) 0) | 278 | (> (prefix-numeric-value arg) 0) |
| 274 | (not timeclock-modeline-display)))) | 279 | (not timeclock-modeline-display)))) |
| 275 | (if on-p | 280 | (if on-p |
| 276 | (let ((list-entry (or (memq 'global-mode-string mode-line-format) | 281 | (progn |
| 277 | ;; In Emacs 21.3 we must use assq | 282 | (or (memq 'timeclock-mode-string global-mode-string) |
| 278 | (assq 'global-mode-string mode-line-format)))) | 283 | (setq global-mode-string |
| 279 | (unless (or (null list-entry) | 284 | (append global-mode-string '(timeclock-mode-string)))) |
| 280 | (memq 'timeclock-mode-string mode-line-format)) | ||
| 281 | (setcdr list-entry (cons 'timeclock-mode-string | ||
| 282 | (cdr list-entry)))) | ||
| 283 | (unless (memq 'timeclock-update-modeline timeclock-event-hook) | 285 | (unless (memq 'timeclock-update-modeline timeclock-event-hook) |
| 284 | (add-hook 'timeclock-event-hook 'timeclock-update-modeline)) | 286 | (add-hook 'timeclock-event-hook 'timeclock-update-modeline)) |
| 285 | (when timeclock-update-timer | 287 | (when timeclock-update-timer |
| @@ -288,11 +290,15 @@ positive. Returns the new status of timeclock modeline display | |||
| 288 | (if (boundp 'display-time-hook) | 290 | (if (boundp 'display-time-hook) |
| 289 | (remove-hook 'display-time-hook 'timeclock-update-modeline)) | 291 | (remove-hook 'display-time-hook 'timeclock-update-modeline)) |
| 290 | (if timeclock-use-display-time | 292 | (if timeclock-use-display-time |
| 291 | (add-hook 'display-time-hook 'timeclock-update-modeline) | 293 | (progn |
| 294 | ;; Update immediately so there is a visible change | ||
| 295 | ;; on calling this function. | ||
| 296 | (if display-time-mode (timeclock-update-modeline)) | ||
| 297 | (add-hook 'display-time-hook 'timeclock-update-modeline)) | ||
| 292 | (setq timeclock-update-timer | 298 | (setq timeclock-update-timer |
| 293 | (run-at-time nil 60 'timeclock-update-modeline)))) | 299 | (run-at-time nil 60 'timeclock-update-modeline)))) |
| 294 | (setq mode-line-format | 300 | (setq global-mode-string |
| 295 | (delq 'timeclock-mode-string mode-line-format)) | 301 | (delq 'timeclock-mode-string global-mode-string)) |
| 296 | (remove-hook 'timeclock-event-hook 'timeclock-update-modeline) | 302 | (remove-hook 'timeclock-event-hook 'timeclock-update-modeline) |
| 297 | (if (boundp 'display-time-hook) | 303 | (if (boundp 'display-time-hook) |
| 298 | (remove-hook 'display-time-hook | 304 | (remove-hook 'display-time-hook |
| @@ -424,7 +430,7 @@ project you were working on." | |||
| 424 | ;;;###autoload | 430 | ;;;###autoload |
| 425 | (defun timeclock-query-out () | 431 | (defun timeclock-query-out () |
| 426 | "Ask the user before clocking out. | 432 | "Ask the user before clocking out. |
| 427 | This is a useful function for adding to `kill-emacs-hook'." | 433 | This is a useful function for adding to `kill-emacs-query-functions'." |
| 428 | (if (and (equal (car timeclock-last-event) "i") | 434 | (if (and (equal (car timeclock-last-event) "i") |
| 429 | (y-or-n-p "You're currently clocking time, clock out? ")) | 435 | (y-or-n-p "You're currently clocking time, clock out? ")) |
| 430 | (timeclock-out))) | 436 | (timeclock-out))) |
| @@ -583,8 +589,8 @@ non-nil." | |||
| 583 | (defun timeclock-update-modeline () | 589 | (defun timeclock-update-modeline () |
| 584 | "Update the `timeclock-mode-string' displayed in the modeline." | 590 | "Update the `timeclock-mode-string' displayed in the modeline." |
| 585 | (interactive) | 591 | (interactive) |
| 586 | (let* ((remainder (timeclock-workday-remaining)) | 592 | (let ((remainder (timeclock-workday-remaining)) |
| 587 | (last-in (equal (car timeclock-last-event) "i"))) | 593 | (last-in (equal (car timeclock-last-event) "i"))) |
| 588 | (when (and (< remainder 0) | 594 | (when (and (< remainder 0) |
| 589 | (not (and timeclock-day-over | 595 | (not (and timeclock-day-over |
| 590 | (equal timeclock-day-over | 596 | (equal timeclock-day-over |
| @@ -594,10 +600,14 @@ non-nil." | |||
| 594 | (timeclock-time-to-date (current-time))) | 600 | (timeclock-time-to-date (current-time))) |
| 595 | (run-hooks 'timeclock-day-over-hook)) | 601 | (run-hooks 'timeclock-day-over-hook)) |
| 596 | (setq timeclock-mode-string | 602 | (setq timeclock-mode-string |
| 597 | (format " %c%s%c" | 603 | (propertize |
| 598 | (if last-in ?< ?[) | 604 | (format " %c%s%c " |
| 599 | (timeclock-seconds-to-string remainder nil t) | 605 | (if last-in ?< ?[) |
| 600 | (if last-in ?> ?]))))) | 606 | (timeclock-seconds-to-string remainder nil t) |
| 607 | (if last-in ?> ?])) | ||
| 608 | 'help-echo "timeclock: time remaining")))) | ||
| 609 | |||
| 610 | (put 'timeclock-mode-string 'risky-local-variable t) | ||
| 601 | 611 | ||
| 602 | (defun timeclock-log (code &optional project) | 612 | (defun timeclock-log (code &optional project) |
| 603 | "Log the event CODE to the timeclock log, at the time of call. | 613 | "Log the event CODE to the timeclock log, at the time of call. |
| @@ -1083,7 +1093,7 @@ See the documentation for the given function if more info is needed." | |||
| 1083 | (setq timeclock-discrepancy accum)))) | 1093 | (setq timeclock-discrepancy accum)))) |
| 1084 | (unless timeclock-last-event-workday | 1094 | (unless timeclock-last-event-workday |
| 1085 | (setq timeclock-last-event-workday timeclock-workday)) | 1095 | (setq timeclock-last-event-workday timeclock-workday)) |
| 1086 | (setq accum timeclock-discrepancy | 1096 | (setq accum (or timeclock-discrepancy 0) |
| 1087 | elapsed (or timeclock-elapsed elapsed)) | 1097 | elapsed (or timeclock-elapsed elapsed)) |
| 1088 | (if timeclock-last-event | 1098 | (if timeclock-last-event |
| 1089 | (if (equal (car timeclock-last-event) "i") | 1099 | (if (equal (car timeclock-last-event) "i") |