emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calendar/timeclock.el


From: Glenn Morris
Subject: [Emacs-diffs] Changes to emacs/lisp/calendar/timeclock.el
Date: Tue, 27 May 2003 14:36:40 -0400

Index: emacs/lisp/calendar/timeclock.el
diff -c emacs/lisp/calendar/timeclock.el:1.23 
emacs/lisp/calendar/timeclock.el:1.24
*** emacs/lisp/calendar/timeclock.el:1.23       Tue Feb  4 07:49:33 2003
--- emacs/lisp/calendar/timeclock.el    Tue May 27 14:36:40 2003
***************
*** 1,6 ****
  ;;; timeclock.el --- mode for keeping track of how much you work
  
! ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
  
  ;; Author: John Wiegley <address@hidden>
  ;; Created: 25 Mar 1999
--- 1,6 ----
  ;;; timeclock.el --- mode for keeping track of how much you work
  
! ;; Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
  
  ;; Author: John Wiegley <address@hidden>
  ;; Created: 25 Mar 1999
***************
*** 64,70 ****
  ;; `timeclock-ask-before-exiting' to t using M-x customize (this is
  ;; the default), or by adding the following to your .emacs file:
  ;;
! ;;   (add-hook 'kill-emacs-hook 'timeclock-query-out)
  
  ;; NOTE: If you change your .timelog file without using timeclock's
  ;; functions, or if you change the value of any of timeclock's
--- 64,70 ----
  ;; `timeclock-ask-before-exiting' to t using M-x customize (this is
  ;; the default), or by adding the following to your .emacs file:
  ;;
! ;;   (add-hook 'kill-emacs-query-functions 'timeclock-query-out)
  
  ;; NOTE: If you change your .timelog file without using timeclock's
  ;; functions, or if you change the value of any of timeclock's
***************
*** 135,142 ****
    "*If non-nil, ask if the user wants to clock out before exiting Emacs."
    :set (lambda (symbol value)
         (if value
!            (add-hook 'kill-emacs-hook 'timeclock-query-out)
!          (remove-hook 'kill-emacs-hook 'timeclock-query-out))
         (setq timeclock-ask-before-exiting value))
    :type 'boolean
    :group 'timeclock)
--- 135,142 ----
    "*If non-nil, ask if the user wants to clock out before exiting Emacs."
    :set (lambda (symbol value)
         (if value
!            (add-hook 'kill-emacs-query-functions 'timeclock-query-out)
!          (remove-hook 'kill-emacs-query-functions 'timeclock-query-out))
         (setq timeclock-ask-before-exiting value))
    :type 'boolean
    :group 'timeclock)
***************
*** 252,258 ****
  `timeclock-last-period' instead.")
  
  (defvar timeclock-mode-string nil
!   "The timeclock string (optionally) displayed in the modeline.")
  
  (defvar timeclock-day-over nil
    "The date of the last day when notified \"day over\" for.")
--- 252,259 ----
  `timeclock-last-period' instead.")
  
  (defvar timeclock-mode-string nil
!   "The timeclock string (optionally) displayed in the modeline.
! The time is bracketed by <> if you are clocked in, otherwise by [].")
  
  (defvar timeclock-day-over nil
    "The date of the last day when notified \"day over\" for.")
***************
*** 262,285 ****
  ;;;###autoload
  (defun timeclock-modeline-display (&optional arg)
    "Toggle display of the amount of time left today in the modeline.
! If `timeclock-use-display-time' is non-nil, the modeline will be
! updated whenever the time display is updated.  Otherwise, the
! timeclock will use its own sixty second timer to do its updating.
! With prefix ARG, turn modeline display on if and only if ARG is
! positive.  Returns the new status of timeclock modeline display
! \(non-nil means on)."
    (interactive "P")
    (let ((on-p (if arg
                  (> (prefix-numeric-value arg) 0)
                (not timeclock-modeline-display))))
      (if on-p
!       (let ((list-entry (or (memq 'global-mode-string mode-line-format)
!                             ;; In Emacs 21.3 we must use assq
!                             (assq 'global-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))))
          (unless (memq 'timeclock-update-modeline timeclock-event-hook)
            (add-hook 'timeclock-event-hook 'timeclock-update-modeline))
          (when timeclock-update-timer
--- 263,287 ----
  ;;;###autoload
  (defun timeclock-modeline-display (&optional arg)
    "Toggle display of the amount of time left today in the modeline.
! If `timeclock-use-display-time' is non-nil (the default), then
! the function `display-time-mode' must be active, and the modeline
! will be updated whenever the time display is updated.  Otherwise,
! the timeclock will use its own sixty second timer to do its
! updating.  With prefix ARG, turn modeline display on if and only
! if ARG is positive.  Returns the new status of timeclock modeline
! display (non-nil means on)."
    (interactive "P")
+   ;; cf display-time-mode.
+   (setq timeclock-mode-string "")
+   (or global-mode-string (setq global-mode-string '("")))
    (let ((on-p (if arg
                  (> (prefix-numeric-value arg) 0)
                (not timeclock-modeline-display))))
      (if on-p
!         (progn
!           (or (memq 'timeclock-mode-string global-mode-string)
!               (setq global-mode-string
!                     (append global-mode-string '(timeclock-mode-string))))
          (unless (memq 'timeclock-update-modeline timeclock-event-hook)
            (add-hook 'timeclock-event-hook 'timeclock-update-modeline))
          (when timeclock-update-timer
***************
*** 288,298 ****
          (if (boundp 'display-time-hook)
              (remove-hook 'display-time-hook 'timeclock-update-modeline))
          (if timeclock-use-display-time
!             (add-hook 'display-time-hook 'timeclock-update-modeline)
            (setq timeclock-update-timer
                  (run-at-time nil 60 'timeclock-update-modeline))))
!       (setq mode-line-format
!           (delq 'timeclock-mode-string mode-line-format))
        (remove-hook 'timeclock-event-hook 'timeclock-update-modeline)
        (if (boundp 'display-time-hook)
          (remove-hook 'display-time-hook
--- 290,304 ----
          (if (boundp 'display-time-hook)
              (remove-hook 'display-time-hook 'timeclock-update-modeline))
          (if timeclock-use-display-time
!               (progn
!                 ;; Update immediately so there is a visible change
!                 ;; on calling this function.
!                 (if display-time-mode (timeclock-update-modeline))
!                 (add-hook 'display-time-hook 'timeclock-update-modeline))
            (setq timeclock-update-timer
                  (run-at-time nil 60 'timeclock-update-modeline))))
!       (setq global-mode-string 
!           (delq 'timeclock-mode-string global-mode-string))
        (remove-hook 'timeclock-event-hook 'timeclock-update-modeline)
        (if (boundp 'display-time-hook)
          (remove-hook 'display-time-hook
***************
*** 424,430 ****
  ;;;###autoload
  (defun timeclock-query-out ()
    "Ask the user before clocking out.
! This is a useful function for adding to `kill-emacs-hook'."
    (if (and (equal (car timeclock-last-event) "i")
           (y-or-n-p "You're currently clocking time, clock out? "))
        (timeclock-out)))
--- 430,436 ----
  ;;;###autoload
  (defun timeclock-query-out ()
    "Ask the user before clocking out.
! This is a useful function for adding to `kill-emacs-query-functions'."
    (if (and (equal (car timeclock-last-event) "i")
           (y-or-n-p "You're currently clocking time, clock out? "))
        (timeclock-out)))
***************
*** 583,590 ****
  (defun timeclock-update-modeline ()
    "Update the `timeclock-mode-string' displayed in the modeline."
    (interactive)
!   (let* ((remainder (timeclock-workday-remaining))
!        (last-in (equal (car timeclock-last-event) "i")))
      (when (and (< remainder 0)
               (not (and timeclock-day-over
                         (equal timeclock-day-over
--- 589,596 ----
  (defun timeclock-update-modeline ()
    "Update the `timeclock-mode-string' displayed in the modeline."
    (interactive)
!   (let ((remainder (timeclock-workday-remaining))
!         (last-in (equal (car timeclock-last-event) "i")))
      (when (and (< remainder 0)
               (not (and timeclock-day-over
                         (equal timeclock-day-over
***************
*** 594,603 ****
            (timeclock-time-to-date (current-time)))
        (run-hooks 'timeclock-day-over-hook))
      (setq timeclock-mode-string
!         (format "   %c%s%c"
!                 (if last-in ?< ?[)
!                 (timeclock-seconds-to-string remainder nil t)
!                 (if last-in ?> ?])))))
  
  (defun timeclock-log (code &optional project)
    "Log the event CODE to the timeclock log, at the time of call.
--- 600,613 ----
            (timeclock-time-to-date (current-time)))
        (run-hooks 'timeclock-day-over-hook))
      (setq timeclock-mode-string
!           (propertize
!            (format " %c%s%c "
!                    (if last-in ?< ?[)
!                  (timeclock-seconds-to-string remainder nil t)
!                  (if last-in ?> ?]))
!            'help-echo "timeclock: time remaining"))))
! 
! (put 'timeclock-mode-string 'risky-local-variable t)
  
  (defun timeclock-log (code &optional project)
    "Log the event CODE to the timeclock log, at the time of call.
***************
*** 1083,1089 ****
          (setq timeclock-discrepancy accum))))
      (unless timeclock-last-event-workday
        (setq timeclock-last-event-workday timeclock-workday))
!     (setq accum timeclock-discrepancy
          elapsed (or timeclock-elapsed elapsed))
      (if timeclock-last-event
        (if (equal (car timeclock-last-event) "i")
--- 1093,1099 ----
          (setq timeclock-discrepancy accum))))
      (unless timeclock-last-event-workday
        (setq timeclock-last-event-workday timeclock-workday))
!     (setq accum (or timeclock-discrepancy 0)
          elapsed (or timeclock-elapsed elapsed))
      (if timeclock-last-event
        (if (equal (car timeclock-last-event) "i")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]