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

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

[emacs-wiki-discuss] Re: culling completed tasks


From: Sacha Chua
Subject: [emacs-wiki-discuss] Re: culling completed tasks
Date: Thu, 16 Jun 2005 10:01:00 +0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Alex Polite <address@hidden> writes:

>> Create the SomethingCompleted page first (plannerCompleted, ...). You
>> may need to M-x emacs-wiki-refresh-file-alist to get it recognized.
>> The code will check all the links for Completed pages.
> Still no go.

Hmmm, how odd...

Are you using dev/patch-411? That's where I introduced
planner-mark-task-hook. You can use C-h v planner-mark-task-hook to
check if it's properly documented and if
alex/planner-move-completed-task is in there. Also, if you're using
this with the planner-remove-task-from-pool thing, you'll need a
save-excursion there as well.

Here's how I use it:

(defun sacha/planner-remove-task-from-pool (old-status new-status)
  "Remove completed tasks from the TaskPool if that still leaves them linked."
  (save-excursion
    (when (or (string= new-status "C")
              (string= new-status "X"))
      (let ((info (planner-current-task-info)))
        (when (planner-task-link-text info)
          ;; If it is linked to TaskPool _and_ at least one other thing
          (if (string-match planner-multi-separator (planner-task-link-text 
info))
              (planner-multi-replan-task
               (planner-multi-make-link
                (planner-multi-filter-links "^TaskPool$" 
(planner-multi-task-link-as-list info) t)))
            ;; Else if it has a date and is linked to TaskPool
            (if (and (planner-task-date info)
                     (string= (planner-task-link info) "TaskPool"))
                (planner-replan-task nil))))))))
(add-hook 'planner-mark-task-hook 'sacha/planner-remove-task-from-pool t)

(defun alex/planner-move-completed-task (old-status new-status)
  "Move completed tasks to FooCompleted if such a page exists.
Check all the pages mentioned in the task's links for possible archiving pages.
If a Completed page exists, replace the page with the link to the Completed 
page.
If no Completed pages exist, leave the task unchanged."
  (save-excursion
    (when (string= new-status "X")
      (let ((info (planner-current-task-info))
            (suffix "Completed"))
        (when (planner-task-link-text info)
          ;; If it is a multiple-linked task, check all the tasks
          (cond
           ((string-match planner-multi-separator (planner-task-link-text info))
            (let ((list (planner-multi-task-link-as-list info))
                  new-list
                  top)
              (while list
                ;; If there is a Completed link
                (setq top (planner-link-base (car list)))
                (add-to-list 'new-list
                             (if (assoc (concat top suffix) 
(planner-file-alist))
                                 (concat top suffix)
                               top)
                             t)
                (setq list (cdr list)))
              (planner-multi-replan-task (planner-multi-make-link new-list))))
           ((and (planner-task-plan info)
                 (assoc (concat (planner-task-plan info) suffix)
                        (planner-file-alist)))
            (planner-replan-task (concat (planner-task-plan info) 
suffix)))))))))
    
(add-hook 'planner-mark-task-hook 'alex/planner-move-completed-task t)

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




reply via email to

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