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

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

Re: [emacs-wiki-discuss] Mark Task (hooks and fixin's)


From: Peter K . Lee
Subject: Re: [emacs-wiki-discuss] Mark Task (hooks and fixin's)
Date: Thu, 16 Jun 2005 12:41:10 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/22.0.50 (gnu/linux)

Sacha Chua <address@hidden> writes:

> Peter K.Lee <address@hidden> writes:
>
>> Just wondering, is there a way to force the update-fixing to become a
>> defadvice that always runs *last* around planner-task-done?
>
> Use the new planner-mark-task-hook variable introduced in dev-411. =)
> This will probably work:
>
> (defun peter/planner-fix-tasks (old-status new-status)
>  "Fix tasks whenever a task's status changes.
> NOTE: Make this the last function in `planner-mark-task-hook'."
>  (planner-fix-tasks))

Sacha,

I took a look at the `planner-mark-task-hook' stuff, but I don't think
it addresses the concern I had with 'update-fixing' to become
something that *always* runs last.

,----[ excerpt from planner-mark-task ]
|         (delete-char 1)
|         (insert mark)
|         (unless this-only
|           (planner-update-task))
|         (run-hook-with-args 'planner-mark-task-hook
|                             (planner-task-status info)
|                             mark)))))
`----

As you can see above, planner-update-task runs *before* the hooks are
run.

** BTW, is that _A_ hook?  Can it be changed into list instead?

This is an issue since planner-update-task runs inside
with-planner-update-setup:

,----[ excerpt from planner-update-task ]
|   (interactive)
|   (with-planner-update-setup
|    (beginning-of-line)
|    (let* ((task-info (planner-current-task-info))
|         (task-link (and task-info
`----

And that is a macro which calls planner-save-buffers before it exits.

,----[ excerpt from planner-save-buffers ]
|   (interactive)
|   (setq suppress-fixing (and (not planner-tasks-never-suppress-fixing-flag)
|                              suppress-fixing))
|   (mapcar
|    (lambda (buffer)
|      (with-current-buffer buffer
`----

See, this is where if `planner-tasks-never-suppress-fixing-flag' is
turned on, it goes through RESORTING and FIXING up the tasks.

Using a hook doesn't go around the fact that if you did a defadvice
"after" i.e. planner-task-done, the code that runs after may have the
'point' point at some random task that is NOT done.

Same thing will happen with hook.  It's actually worse with the hook
since atleast with defadvice, you can do a "before" or even "around"
to get it to work.

What you really want is something like:

1. run planner-update-task (update the task and it's linked parts)
2. run the hooks
3. finally call planner-save-buffers (which may sort, fix etc.)

Otherwise, we need to kiss `planner-tasks-never-suppress-fixing-flag'
good bye...

-Peter




reply via email to

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