[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] Totally small-time dependency tracking
From: |
Jesse Alama |
Subject: |
Re: [emacs-wiki-discuss] Totally small-time dependency tracking |
Date: |
Mon, 10 Oct 2005 00:06:18 -0700 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (darwin) |
An "aha!" moment has indeed been sparked somewhere :->
Can you check this into the developer branch of the planner?
By the way, I've been tracking `planner-merge' more or less since the
announcement in your "The Great Merge" message. Is that the right
branch to follow? Are you checking things in to that branch? More
specifically: if you decide to commit the code you talk about below to
the planner, will you check it in to planner-merge?
Jesse
Sacha Chua <address@hidden> writes:
> The only thing this code does is gray out stuff that can't be done
> yet. For really cool stuff, we should be doing fancy sorting and
> whatnot, but I don't feel up to doing a topological sort in Emacs Lisp
> at 2 in the morning. =)
>
> It's easy to change the syntax. For example, we can use 2->1,5 to mean
> that this is task 2 and it's dependent on tasks 1 and 5. That might be
> fun.
>
> Hope this sparks an aha! moment somewhere. =)
>
> ----------------------------------------------------------------
>
> ;;; Task dependency tracking for Planner
>
> ;; #A X Do something {{Tasks:1}}
> ;; #B _ Do another thing {{Depends:1,5}} {{Tasks:2}}
> ;; #B _ Do yet another thing {{Depends:1}} {{Tasks:3}}
>
> ;; Task 3 depends on a completed task, so it will be okay. Task 2
> ;; still has an incomplete dependency, so it'll be grayed out after
> ;; (planner-depend-highlight-tasks).
>
> (defface planner-depend-invalid-face
> '((t (:foreground "gray")))
> "Face for tasks with incomplete dependencies."
> :group 'planner-depend)
>
> (defun planner-depend-highlight-tasks ()
> "Gray out all tasks with dependencies not satisfied on the current page."
> (goto-char (point-min))
> (let (found-ids)
> ;; Find all the completed IDs
> (while (re-search-forward "{{Tasks:\\(0-9+\\)}}" nil t)
> (let* ((task-id (number-to-string (match-string 1)))
> (info (planner-current-task-info)))
> (when (string= "X" (planner-task-status info))
> (setq found-ids (cons task-id found-ids)))))
> ;; Highlight everything else
> (goto-char (point-min))
> (while (re-search-forward planner-task-regexp nil t)
> (let ((info (planner-current-task-info))
> dependencies
> failed)
> (when (string-match "{{Depends:\\([0-9,]+\\)}}"
> (planner-task-description info))
> (setq dependencies (split-string (match-string 1
> (planner-task-description info)) ","))
> (while dependencies
> (if (memq (string-to-number (car dependencies)) found-ids)
> (setq dependencies (cdr dependencies))
> (setq dependencies nil
> failed t)))
> (when failed
> (planner-highlight-region (planner-line-beginning-position)
> (planner-line-end-position)
> 'dependency
> 100
> '(face
> planner-depend-invalid-face))))))))
--
Jesse Alama (address@hidden)