[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] Re: planner task syntax
From: |
Jim Ottaway |
Subject: |
Re: [emacs-wiki-discuss] Re: planner task syntax |
Date: |
Thu, 06 Apr 2006 20:33:56 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
>>>>> Torsten Anders <address@hidden> writes:
> Just to be a bit more specific: how can I change the function below
> such that it expects a page/file/buffer as an argument? How is such a
> page usually given (path? string of page content?). Thank you very
> much.
> (defun torsten/planner-schedule-sum-task-durations ()
> "Returns duration sum of all tasks in buffer (?). The duration is
> returned in seconds."
> (save-excursion
> (goto-char (point-min))
> (let ((result 0))
> (while (re-search-forward "^#[A-C]" nil t)
> (let* ((task (planner-current-task-info))
> (time (<get-duration> task)))
> (setq result (+ result time))))
> result)))
I think that planner-find-file would be suitable, something like this
[untested]:
(defun torsten/planner-schedule-sum-task-durations (page)
"Returns duration sum of all tasks in PAGE.
The duration is returned in seconds."
(planner-find-file page)
(save-excursion
(goto-char (point-min))
(let ((result 0))
(while (re-search-forward "^#[A-C]" nil t)
(let* ((task (planner-current-task-info))
(time (<get-duration> task)))
(setq result (+ result time))))
result)))
It would probably be a good idea to use `planner-task-regexp' for the
re-search-forward' regexp.
You might also want to wrap the body of this [or the loop that uses
this function] with `with-planner-update-setup' so that newly opened
files are cleaned up.
A suitable function to get a list of day pages is
planner-get-day-pages:
,----[ C-h f planner-get-day-pages RET ]
| planner-get-day-pages is a compiled Lisp function in `planner.el'.
| (planner-get-day-pages &optional FROM TO EXCLUDE-TEMP)
|
| Return a descending list of day pages from FROM to TO (inclusive).
| If EXCLUDE-TEMP is non-nil, ignore unsaved pages.
|
| [back]
`----
It returns an alist of (page-name . path) elements, so you would want
to just use the car of each element as arguments for planner-find-file.
I hope this helps.
--
Jim Ottaway
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/05
- [emacs-wiki-discuss] Re: planner task syntax, Michael Olson, 2006/04/05
- [emacs-wiki-discuss] Re: planner task syntax, Sacha Chua, 2006/04/05
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/06
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/06
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/06
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/06
- Re: [emacs-wiki-discuss] Re: planner task syntax,
Jim Ottaway <=
- Re: [emacs-wiki-discuss] Re: planner task syntax, Torsten Anders, 2006/04/07
- Re: [emacs-wiki-discuss] Re: planner task syntax, Jim Ottaway, 2006/04/07