CVS update by jmiller packages/xemacs-packages/calendar ...
xemacs-cvs at xemacs.org
xemacs-cvs at xemacs.org
Wed Nov 22 19:12:00 EST 2006
User: jmiller
Date: 06/11/23 01:12:00
Modified: packages/xemacs-packages/calendar ChangeLog timeclock.el
Log:
commit Adrian's timeclock.el contribution
Revision Changes Path
1.45 +24 -0 XEmacs/packages/xemacs-packages/calendar/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/ChangeLog,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -r1.44 -r1.45
--- ChangeLog 2006/11/20 05:23:02 1.44
+++ ChangeLog 2006/11/23 00:11:58 1.45
@@ -1,3 +1,27 @@
+2006-11-22 Adrian Aichner <adrian at 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-11-22 Adrian Aichner <adrian at 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.
+
2006-11-20 Norbert Koch <viteno at xemacs.org>
* Makefile (VERSION): XEmacs package 1.29 released.
1.5 +48 -8 XEmacs/packages/xemacs-packages/calendar/timeclock.el
Index: timeclock.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/calendar/timeclock.el,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- timeclock.el 2006/10/23 01:25:30 1.4
+++ timeclock.el 2006/11/23 00:11:58 1.5
@@ -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 @@ This variable only has effect if set wit
: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 @@ relative only to the time worked today,
(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 @@ relative only to the time worked today,
(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 @@ that variable's documentation."
"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 @@ being logged for. Normally only \"in\"
(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 @@ being logged for. Normally only \"in\"
(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 @@ being logged for. Normally only \"in\"
(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 @@ See the documentation for the given func
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 @@ discrepancy, today's discrepancy, and th
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 @@ HTML-P is non-nil, HTML markup is added.
(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)
More information about the XEmacs-CVS
mailing list