emacs-wiki-discuss
[Top][All Lists]
Advanced

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

Re: [emacs-wiki-discuss] Timeclock reports Re: planner-mode for contract


From: micah milano
Subject: Re: [emacs-wiki-discuss] Timeclock reports Re: planner-mode for contractors (multi-layered planners?)
Date: Mon, 13 Jun 2005 21:00:53 -0500

Hi all!

I must excuse myself, for I am not a lisp programmer, so I need a little help.

On 6/9/05, Sacha Chua <address@hidden> wrote:
Hiya, everyone!

micah milano <address@hidden> writes:

> 2005.06.02 | Task I finished today (Completed) | 1:20
> 2005.06.02 | Task I did some work on today (Pending) | 2:45
> 2005.06.01 | Task I did work on yesterday (Pending) | 4:10
> 2005.05.31 | Task I did work on two days ago (Completed) | 0:30
> 2005.05.15 | Task I did work on two weeks ago (Pending) | 2:15

Progress! After much struggling with timeclock (that thing could
really use more documentation), I can use

(insert (planner-timeclock-summary-format-list
         (planner-timeclock-summary-get-day-list "2005.06.09" "planner")))

I've been trying to figure out how to use this. First what I did was to copy the lisp code you attach into a file ~/.elisp/planner-timeclock-micah.el and then I added to my ~/.emacs the line:

(provide 'planner-timeclock-micah)

I then tried to do the insert line you have above in a plan page by doing M-: and then the (insert...). This put a Total: 0:00 in my plan file, but nothing else happened.

 What am I missing? How do I use this?

(insert (planner-timeclock-summary-format-list
         (planner-timeclock-summary-get-day-list " 2005.06.09")))

to generate reports like

2005.06.09 | Make a breakdown for planner-timeclock-summary : E-Mail from micah milano | 1:04
2005.06.09 | Re-fix gnus-registry 5.9.0 issue : E-Mail from Patricia J. Hawkins | 0:02
2005.06.09 | Merge dryice/42 for planner-authz : E-Mail from Dryice Dong Liu | 0:46
2005.06.09 | Finish contact information and work history for nonimmigrant visa applicant | 0:19
2005.06.09 | Finish supplemental nonimmigrant visa application form | 0:15
2005.06.09 | Check on DHL package | 0:01
2005.06.09 | 1h Finish US embassy form | 0:03

Total: 2:33


This one did put the information in the plan file. I am not sure I understand the difference between the two (except for me, one works and one doesn't ;)

I haven't thought about how to include the completed/pending
information yet, but monkeying around with
planner-timeclock-summary-format-list should do the trick. Also, it
should be relatively easy to write a function that will let you run
this over a range of dates...

But its getting closer, that is very encouraging!

Thanks!
micah

----------------------------------------------------------------

(defun planner-timeclock-entry-task (entry)
  "Return the task associated with ENTRY."
  (when (listp entry) (setq entry (timeclock-entry-project entry)))
  (if (or (string-match
           (concat "^\\(?:" emacs-wiki-name-regexp "\\): ")
           entry)
          (and (featurep 'planner-multi)
               (string-match
                (concat "^\\(?:" emacs-wiki-name-regexp "\\)"
                        "\\(?:" planner-multi-separator
                        "\\(?:" emacs-wiki-name-regexp "\\)\\)*: ")
                entry))
          (string-match "^: " entry))
      (substring entry (match-end 0))
    entry))

(defun planner-timeclock-entry-plan (entry)
  "Return the plan page(s) associated with ENTRY."
  (when (listp entry) (setq entry (timeclock-entry-project entry)))
  (when (or (string-match
             (concat "^\\(" emacs-wiki-name-regexp "\\): ")
             entry)
            (and (featurep 'planner-multi)
                 (string-match
                  (concat "^\\(\\(?:" emacs-wiki-name-regexp "\\)"
                          "\\(?:" planner-multi-separator
                          "\\(?:" emacs-wiki-name-regexp "\\)\\)*\\): ")
                  entry)))
    (match-string 1 entry)))

(defun planner-timeclock-check-plan-p (plan task-plans)
  "Return non-nil if PLAN is associated with TASK-PLANS."
  (or (null plan)
      (string= plan task-plans)
      (and (featurep 'planner-multi)
           (planner-multi-link-member plan
                                      (planner-multi-split task-plans)))))

(defun planner-timeclock-summary-get-day-list (date &optional plan-query)
  "Return the summary for DATE.
If PLAN-QUERY is a function, call it with the complete text of the task.
If PLAN-QUERY is a string, match it against the plans for the task.
Only tasks matching PLAN-QUERY will be returned, or all if PLAN-QUERY is nil."
  (with-planner
    (let (timeclock-entries
          day-entries
          lookup)
      (setq timeclock-entries
            (cdr (assoc
                  (emacs-wiki-replace-regexp-in-string "\\." "/" date)
                  (timeclock-day-alist))))
      (while timeclock-entries
        (when (timeclock-entry-project (car timeclock-entries))
          (let ((task (planner-timeclock-entry-task (car timeclock-entries)))
                (length (timeclock-entry-length (car timeclock-entries))))
            (when
              (if (functionp plan-query)
                  (funcall plan-query (timeclock-entry-project
                                       (car timeclock-entries)))
                (planner-timeclock-check-plan-p
                 plan-query
                 (planner-timeclock-entry-plan (car timeclock-entries))))
              (setq lookup (assoc task day-entries))
              (if lookup
                  (setcdr (cdr lookup)
                          (cons (+ length (elt lookup 2)) nil))
                (add-to-list 'day-entries (list task date length))))))
        (setq timeclock-entries (cdr timeclock-entries)))
      day-entries)))

(defun planner-timeclock-summary-format-list (list)
  "Format LIST as a list of timeclock entries."
  (let ((total 0))
    (concat
     (mapconcat
      (lambda (entry)
        (setq total (+ total (elt entry 2)))
        (concat (elt entry 1) " | " ; date
                (elt entry 0) " | " ; task
                (timeclock-seconds-to-string (elt entry 2)) "\n"))
      list
      "")
     "\nTotal: " (timeclock-seconds-to-string total) "\n")))


--
Sacha Chua < address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83


_______________________________________________
emacs-wiki-discuss mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/emacs-wiki-discuss


reply via email to

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