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

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

[emacs-wiki-discuss] planner, timeclock, and editing tasks


From: Sacha Chua
Subject: [emacs-wiki-discuss] planner, timeclock, and editing tasks
Date: Thu, 16 Dec 2004 17:16:43 +0900
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

I often update my task descriptions. We haven't found a neat way to do
this in-buffer, so I use planner-edit-task-description. However, if I
update the task description or replan a task, my timelog data gets out
of date. This code snippet updates all matching tasks in the timelog
when you use planner-replan-task or planner-edit-task-description .

(defadvice planner-replan-task (around sacha/planner-timeclock activate)
  "Edit the clocked in task as well."
  (let ((info (planner-current-task-info)))
    ad-do-it
    (with-current-buffer (find-file-noselect timeclock-file)
      (goto-char (point-min))
      (while (re-search-forward
              (concat
               "^. [^ ]+ [^ ]+ "
               "\\("
               (if (planner-task-plan info)
                   (regexp-quote (planner-task-plan info))
                 "")
               "\\)"
               ": "
               (regexp-quote (planner-task-description info))
               "$")
              nil t)
        (replace-match (concat " " (ad-get-arg 0)) t t nil 1))
      (save-buffer)
      (kill-buffer (current-buffer)))))

(defadvice planner-edit-task-description (around sacha/planner-timeclock 
activate)
  "Update the timelog as well. Warning! Do not have duplicate tasks!"
  (let ((info (planner-current-task-info)))
    ad-do-it
    (with-current-buffer (find-file-noselect timeclock-file)
      (goto-char (point-min))
      (while (re-search-forward
              (concat
               "^. [^ ]+ [^ ]+ "
               (if (planner-task-plan info)
                 (concat 
                  (regexp-quote (planner-task-plan info))
                  ": ")
                 "")
               "\\("
               (regexp-quote (planner-task-description info))
               "\\)"
               "$")
              nil t)
        (replace-match (ad-get-arg 0) t t nil 1))
      (setq planner-timeclock-current-task (ad-get-arg 0))
      (save-buffer)
      (kill-buffer (current-buffer)))))

-- 
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
applying as a Debian new maintainer | looking for a grad school




reply via email to

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