Hi!

I would like to offer following contribution, which has made it
hassle-free for me to work with a gpg-encrypted timeclock-file.

Best regards!

Adrian

ChangeLog addition:

2006-08-01  Adrian Aichner  <[EMAIL PROTECTED]>

        * 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.

diff -u c:\progra~1\xemacs\xemacs-packages\lisp\calendar\timeclock.el.orig 
c:\progra~1\xemacs\xemacs-packages\lisp\calendar\timeclock.el
--- c:\progra~1\xemacs\xemacs-packages\lisp\calendar\timeclock.el.orig  
2006-08-01 21:47:12.421375000 +0200
+++ c:\progra~1\xemacs\xemacs-packages\lisp\calendar\timeclock.el       
2006-08-01 21:47:12.437000000 +0200
@@ -588,6 +588,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)
@@ -643,7 +649,8 @@
   "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"))
@@ -667,7 +674,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-+"
@@ -969,7 +979,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)
@@ -1063,7 +1074,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)))
@@ -1353,7 +1365,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:[EMAIL PROTECTED]
 http://www.xemacs.org/


_______________________________________________
Planner-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/planner-el-discuss

Reply via email to