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

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

[emacs-wiki-discuss] Re: planner-deadline


From: Edgar Gonçalves
Subject: [emacs-wiki-discuss] Re: planner-deadline
Date: Mon, 31 Oct 2005 00:52:23 +0000
User-agent: Gnus/5.110004 (No Gnus v0.4)

Yesterday morning, Michael Olson wrote:
> address@hidden (Edgar Gonçalves) writes:
>
>> .#1 planner-deadline: I had grown very fond of this package, but in
>> this planner-muse version if I have many tasks with deadlines, wait
>> a few days, and do a \M-x plan <RET> it gets only one deadlined-task
>> into the current day. If I repeat the command, another one comes up
>> to the current day. and so on and so forth, until I have all my
>> tasks present...
>
> This patch should fix the issue -- the main problem was some buggy
> behavior in the `planner-copy-or-move-region' function.  I also took
> special pains to make sure that the deadline is always updated when
> you type M-x plan, as well as when the deadline is changed manually.
>
> 2005-10-29 05:54:43 GMT       Michael Olson <address@hidden>  patch-81
>
>     Summary:
>       Tasks with deadlines will be moved properly from previous days.
>     Revision:
>       planner-muse--mwolson--1.0--patch-81
>
>     * planner-deadline.el: Whitespace munging.  Make sure
>      planner-deadline-update to planner-goto-hook -- it's a sure thing that
>      this behavior will be desired if you have deadlines!
>      (planner-deadline-change-hook): Add planner-deadline-update as the
>      default value.
>     
>     * planner.el (planner-copy-or-move-region): Optimize.  Only move upwards
>       if no tasks exists at this line, or if we encounter an error.  This
>       should prevent planner from playing Russian Roulette with tasks from
>       previous days, such as deadlines.
>       (plan): Use point-min and point-max for the sake of clarity.
>
>     modified files:
>      ChangeLog planner-deadline.el planner.el

Thanks for the fix. I just noticed one more issue (I thought it was an error,
but, as usual, the code was right, and I wasn't!). When I used dates such as
"2005.11.8", instead of "2005.11.08", planner-filename-to-calendar-date would
produce an args-out-of-range error. So I suggest a couple of solutions (not
mutually exclusive!):
- accept incomplete dates (2005.3.6 is always easier to write than
  2005.03.06). This may not be useless (given the following point), as some
  people tend to edit tasks by hand. I'm not one of those (yet!), so I didn't
  bother hacking this out.
- make a planner-add-task-deadline command, that would prompt for a date in the
  calendar, such as planner-create-task. I jotted a function for that purpose,
  using the date-picking from p-c-task. Note that if I add a deadline to a task,
  i might want to change it, but i gess i usually don't want to remove
  it... Here's that function, tested under the latest planner-muse
  (patch-81). Feel free to comment, modify and/or add it to your config,
  obviously): 
<code>
(defun planner-add-task-deadline (date)
  "Adds or modifies a deadline to task under point.
If DATE is non-nil, makes a daily entry on DATE, else makes an
entry in today's planner page. It's assumed that the current Wiki
page is the page you're using to plan an activity. Any time
accrued to this task will be applied to that page's name in the
timelog file, assuming you use timeclock."
  (interactive
   (list
    (when planner-use-day-pages
      (cond
       ;; Universal prefix means pick up from current page
       ((and current-prefix-arg
             (planner-derived-mode-p 'planner-mode)
             (string-match planner-date-regexp (planner-page-name)))
        (planner-page-name))
       ;; Date selected in calendar
       ((condition-case nil (calendar-cursor-to-date) (error nil))
        (planner-date-to-filename (calendar-cursor-to-date)))
       ;; Prompt for date
       (t (let ((planner-expand-name-favor-future-p
                 (or planner-expand-name-favor-future-p
                     planner-task-dates-favor-future-p)))
            (planner-read-date)))))))

  (let ((description (planner-task-description (planner-current-task-info))))
    (if (string-match "\\({{Deadline:\.\*}}\\)" description)
        ;;update any existing {{Deadline: xxxx.xx.xx \.\*}}
        (setq description (replace-match (format "{{Deadline: %s}}" date) nil t 
description 0))
        ;;add {{Deadline: <date>}} to the end of the description
        (setq description (format "%s {{Deadline: %s}}" description date)))
    (planner-edit-task-description description))
  (planner-deadline-update))
</code>  


If you guys and gals think that it's usefull, then perhaps Michael could add it
to planner-deadline.el!

Cheers,
-- 
Edgar Gonçalves
Software Engineering Group @ INESC-ID
Portugal





reply via email to

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