Hello Jeff, thanks for all your work on calendar!
Please consider these timeclock.el features, which are already found
upstream in planner's development version of this file.
Best regards!
Adrian
packages ChangeLog patch:
Diff command: cvs -q diff -U 0
Files affected: xemacs-packages/calendar/ChangeLog
Index: xemacs-packages/calendar/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/ChangeLog,v
retrieving revision 1.43
diff -u -U0 -r1.43 ChangeLog
--- xemacs-packages/calendar/ChangeLog 19 Nov 2006 00:31:22 -0000 1.43
+++ xemacs-packages/calendar/ChangeLog 20 Nov 2006 19:51:39 -0000
@@ -0,0 +1,24 @@
+2006-10-16 Adrian Aichner <adrian(a)xemacs.org>
+
+ * timeclock.el: Typo fixes.
+ * timeclock.el (timeclock-history): New.
+ * timeclock.el (timeclock-use-history): New.
+ * timeclock.el (timeclock-log): Honor timeclock-use-history.
+ * timeclock.el (timeclock-read-moment): Provide error on
+ unexpected data in timeclock-file, going unnoticed until now.
+ * timeclock.el (timeclock-find-discrep): Report line number of
+ discrepancy to ease manual fixing.
+
+2006-08-01 Adrian Aichner <adrian(a)xemacs.org>
+
+ * timeclock.el: Keep timeclock-file buffer around, so that an
+ encrypted timeclock-file does not have to be opened on each
+ clocking operation (requiring entry of encryption key).
+ * timeclock.el (timeclock-get-timeclock-file-buffer): New.
+ * timeclock.el (timeclock-log): Don't kill timeclock-file buffer.
+ * timeclock.el (timeclock-log-data): Use
+ `timeclock-get-timeclock-file-buffer', which avoids reading
+ timeclock-file, if it's already in a live buffer.
+ * timeclock.el (timeclock-find-discrep): Ditto.
+ * timeclock.el (timeclock-visit-timelog): Ditto.
+
packages source patch:
Diff command: cvs -f -z3 -q diff -u -w -N
Files affected: xemacs-packages/calendar/timeclock.el
===================================================================
RCS
Index: xemacs-packages/calendar/timeclock.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/timeclock.el,v
retrieving revision 1.4
diff -u -w -r1.4 timeclock.el
--- xemacs-packages/calendar/timeclock.el 23 Oct 2006 01:25:30 -0000 1.4
+++ xemacs-packages/calendar/timeclock.el 20 Nov 2006 19:44:21 -0000
@@ -26,6 +26,8 @@
;; Boston, MA 02110-1301, USA.
;;; Synched up with: FSF Emacs 22.1 CVS 2006-09-15
+;;; and contrib/timeclock.el from
+;;;
http://arch.gna.org/planner-el/archive-2006/planner-el--devel--0/
;;; Commentary:
@@ -150,6 +152,19 @@
:type 'boolean
:group 'timeclock)
+(defvar timeclock-history '()
+ "History of previously used timeclock values.")
+
+(defcustom timeclock-use-history nil
+ "*If non-nil, user is prompted for timestamp, previous values are
+available via history mechanism.
+
+\\{minibuffer-local-map}.
+
+This variable only has effect if set with \\[customize]."
+:type 'boolean
+:group 'timeclock)
+
(defvar timeclock-update-timer nil
"The timer used to update `timeclock-mode-string'.")
@@ -607,6 +622,12 @@
(defvar timeclock-project-list nil)
(defvar timeclock-last-project nil)
+(defun timeclock-get-timeclock-file-buffer (file)
+ "Return the buffer visiting timeclock-file FILE."
+ (or
+ (get-file-buffer file)
+ (find-file-noselect file)))
+
(defun timeclock-completing-read (prompt alist &optional default)
"A version of `completing-read' that works on both Emacs and XEmacs."
(if (featurep 'xemacs)
@@ -619,7 +640,7 @@
(defun timeclock-ask-for-project ()
"Ask the user for the project they are clocking into."
(timeclock-completing-read
- (format "Clock into which project (default %s): "
+ (format "Clock into which project (default \"%s\"): "
(or timeclock-last-project
(car timeclock-project-list)))
(mapcar 'list timeclock-project-list)
@@ -665,13 +686,19 @@
"Log the event CODE to the timeclock log, at the time of call.
If PROJECT is a string, it represents the project which the event is
being logged for. Normally only \"in\" events specify a project."
- (with-current-buffer (find-file-noselect timeclock-file)
+ (with-current-buffer
+ (timeclock-get-timeclock-file-buffer timeclock-file)
(goto-char (point-max))
(if (not (bolp))
(insert "\n"))
(let ((now (current-time)))
(insert code " "
+ (if timeclock-use-history
+ (read-string "timeclock time: "
(format-time-string "%Y/%m/%d %H:%M:%S" now)
+ 'timeclock-history
+ (format-time-string "%Y/%m/%d %H:%M:%S" now))
+ (format-time-string "%Y/%m/%d %H:%M:%S" now))
(or (and project
(stringp project)
(> (length project) 0)
@@ -689,7 +716,10 @@
(setq timeclock-last-event (list code now project)))
(save-buffer)
(run-hooks 'timeclock-event-hook)
- (kill-buffer (current-buffer))))
+ ;; APA: Don't kill buffer to avoid having to read in (potentially
+ ;; encrypted) file.
+ ;; (kill-buffer (current-buffer))
+ ))
(defvar timeclock-moment-regexp
(concat "\\([bhioO]\\)\\s-+"
@@ -698,7 +728,8 @@
(defsubst timeclock-read-moment ()
"Read the moment under point from the timelog."
- (if (looking-at timeclock-moment-regexp)
+ (cond
+ ((looking-at timeclock-moment-regexp)
(let ((code (match-string 1))
(year (string-to-number (match-string 2)))
(mon (string-to-number (match-string 3)))
@@ -707,7 +738,13 @@
(min (string-to-number (match-string 6)))
(sec (string-to-number (match-string 7)))
(project (match-string 8)))
- (list code (encode-time sec min hour mday mon year) project))))
+ (list code (encode-time sec min hour mday mon year) project)))
+ ((not (eobp))
+ (error "unexpected data in %s: %s"
+ timeclock-file
+ (buffer-substring
+ (point-at-bol)
+ (point-at-eol))))))
(defun timeclock-last-period (&optional moment)
"Return the value of the last event period.
@@ -991,7 +1028,8 @@
last-date-limited last-date-seconds last-date
(line 0) last beg day entry event)
(with-temp-buffer
- (insert-file-contents (or filename timeclock-file))
+ (insert-buffer
+ (timeclock-get-timeclock-file-buffer (or filename timeclock-file)))
(when recent-only
(goto-char (point-max))
(unless (re-search-backward "^b\\s-+" nil t)
@@ -1085,7 +1123,8 @@
timeclock-reason-list nil
timeclock-elapsed 0)
(with-temp-buffer
- (insert-file-contents timeclock-file)
+ (insert-buffer
+ (timeclock-get-timeclock-file-buffer timeclock-file))
(goto-char (point-max))
(unless (re-search-backward "^b\\s-+" nil t)
(goto-char (point-min)))
@@ -1375,7 +1414,8 @@
(defun timeclock-visit-timelog ()
"Open the file named by `timeclock-file' in another window."
(interactive)
- (find-file-other-window timeclock-file))
+ (switch-to-buffer-other-window
+ (timeclock-get-timeclock-file-buffer timeclock-file)))
(provide 'timeclock)
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches