[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Splitting a task onto a separate plan page
From: |
Sacha Chua |
Subject: |
[emacs-wiki-discuss] Splitting a task onto a separate plan page |
Date: |
Sat, 12 Nov 2005 16:22:27 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
Here is a totally hackish way to split a task onto a separate plan
page. Call roxy/planner-split-task while point is on the task, and
specify a page to split the task onto. Thanks to roxy_ for the
suggestion. planner-id _should_ keep it relatively safe from changes
in the task description, but I haven't quite figured out yet how to
search for the task ID if the task has been moved. If all else fails,
do a grep.
Task on TaskPool:
#A _ Foo bar
After roxy/planner-split-task to FooBar:
Original task:
#A _ Foo bar {{Tasks:1}} Split:FooBar
FooBar:
Foo bar {{Tasks:1}} Split:FooBar
#parent-task 1 (TaskPool) Complete project
After roxy/planner-complete-project on FooBar
#A X Foo bar {{Tasks:1}} Split:FooBar
(require 'planner-id)
(defun roxy/planner-split-task (page)
"Split the current task into a separate project PAGE."
(interactive (list (planner-read-non-date-page (planner-file-alist))))
(unless (planner-current-task-info) (error "Not on task"))
(unless page (error "Specify page to split to"))
(planner-id-add-task-id)
(planner-edit-task-description
(concat
(planner-task-description (planner-current-task-info))
" Split:" (planner-make-link page)))
(let* ((info (planner-current-task-info))
(description (planner-task-description info))
(id (planner-id-get-id-from-string description "Tasks"))
(plan (or (planner-task-plan info)
(planner-page-name))))
(unless id (error "Could not determine task ID"))
(planner-find-file page)
(goto-char (point-min))
(insert (format "%s\n#parent-task %s (%s) %s\n\n"
description
(cdr id)
(planner-make-link plan)
(if (featurep 'planner-lisp)
"[[lisp://(roxy/planner-complete-project)][Complete
project]]"
"")))))
(defun roxy/planner-complete-project ()
"Mark current project page as completed, updating the parent task."
(interactive)
(goto-char (line-beginning-position))
(when (or (looking-at "^#parent-task \\([0-9]+\\) (\\(.*?\\))")
(progn
(goto-char (point-min))
(re-search-forward "^#parent-task \\([0-9]+\\) (\\(.*?\\))")))
(let ((id (match-string-no-properties 1))
(link (match-string-no-properties 2)))
(planner-find-file (planner-link-target link))
(planner-id-find-task id)
(planner-task-done))))
--------------------------------------------------------------------------------
It will also need the following patch, which is generally useful and
might be nice to fold into the main tree.
* looking for address@hidden/planner-muse--mwolson--1.0--patch-95 to compare
with
* comparing to address@hidden/planner-muse--mwolson--1.0--patch-95
M planner-multi.el
M planner-id.el
M planner.el
* modified files
--- orig/planner-id.el
+++ mod/planner-id.el
@@ -70,9 +70,13 @@
(defvar planner-id-regexp "{{\\([^:]+\\):\\([0-9]+\\)}}"
"Regexp matching planner IDs.")
-(defun planner-id-get-id-from-string (string)
- "Return the planner ID in STRING as (identifier number)."
- (when (string-match planner-id-regexp string)
+(defun planner-id-get-id-from-string (string &optional key)
+ "Return the planner ID in STRING as (identifier number).
+If KEY is specified, match against that."
+ (when (string-match
+ (concat "{{\\("
+ (or key "[^:]+")
+ "\\):\\([0-9]+\\)}}") string)
(cons (planner-match-string-no-properties 1 string)
(planner-match-string-no-properties 2 string))))
@@ -87,14 +91,24 @@
(concat "{{" (car id) ":" (cdr id) "}}"))
;;;###autoload
+
(defun planner-id-find-task (task-info &optional point)
"Find task described by TASK-INFO. If POINT is non-nil, start from there.
If task is found, move point to line beginning and return non-nil.
If task is not found, leave point at POINT or the start of the buffer
and return nil."
(goto-char (or point (point-min)))
- (let ((task-id (planner-id-get-id-from-string
- (planner-task-description task-info)))
+ (let ((task-id
+ (cond
+ ;; Task ID
+ ((listp task-info)
+ (planner-id-get-id-from-string
+ (planner-task-description task-info)))
+ ;; Just the ID
+ ((numberp task-info)
+ (cons "Tasks" (number-to-string task-info)))
+ ;; ID as string
+ ((stringp task-info) (cons "Tasks" task-info))))
(found nil))
(when (re-search-forward
(concat planner-task-regexp ".*"
--- orig/planner-multi.el
+++ mod/planner-multi.el
@@ -169,6 +169,7 @@
(if (listp (nth 5 info))
(nth 5 info)
(list (nth 5 info))))
+(defalias 'planner-task-link-as-list 'planner-multi-task-link-as-list)
(defun planner-multi-task-xref (page)
"Copy the current task to PAGE."
--- orig/planner.el
+++ mod/planner.el
@@ -1868,6 +1868,9 @@
"Return the planner page of a task given INFO." (nth 7 info))
(defun planner-task-date (info)
"Return the planner date of a task given INFO." (nth 8 info))
+(defun planner-task-links-as-list (info)
+ "Return a list of all the pages this task is on."
+ (delq nil (list (nth 7 info) (nth 8 info))))
;;;_ + Creation
----------------------------------------------------------------
Time data:
i 2005/11/12 15:38:19 : Split tasks for roxy {{Tasks:40}}
o 2005/11/12 16:22:07
--
Sacha Chua <address@hidden> - open source, free software geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, public speaking
sachac on irc.freenode.net#emacs . YM: sachachua83
- [emacs-wiki-discuss] Splitting a task onto a separate plan page,
Sacha Chua <=