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

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

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


From: Sacha Chua
Subject: [emacs-wiki-discuss] Re: Mark Task (hooks and fixin's)
Date: Fri, 17 Jun 2005 11:38:21 +0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Peter K.Lee <address@hidden> writes:

> 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.

Aha! Please try out dev/416, which now wraps planner-mark-task within
a with-planner-update-setup. This could cause lots of thrashing for
people who keep planner-tasks-file-behavior to 'save or 'close,
though, so tell me if I should change the default.

Sorry about the inconvenience. <sheepish grin>

If that still doesn't work, use the following function with dev/416:

(defun peter/planner-fix-tasks-after-marking (old-status new-status)
  "Always fix tasks."
  (unless (string= old-status new-status)
    (save-window-excursion
      (let ((info (planner-current-task-info)))
        (planner-fix-tasks)
        (when (planner-task-link-text info)
          (if (string-match planner-multi-separator (planner-task-link-text 
info))
              (let ((links (planner-multi-task-link-as-list info)))
                (while links
                  (planner-find-file (car links))
                  (planner-fix-tasks)
                  (setq links (cdr links))))
            (planner-find-file (planner-task-link info))
            (planner-fix-tasks)))
        (planner-find-file (planner-task-page info))
        (planner-find-task info))))
  t)

(add-hook 'planner-mark-task-hook 'peter/planner-fix-tasks-after-marking t)

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

A hook is a list of functions. Feel free to add-hook to it. =)

> 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.

Good point! I've rewritten the planner-mark-task-hook functions in
http://sacha.free.net.ph/notebook/emacs/planner-config.el to be
careful about where I'm leaving the point.

> 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.

You can still do before or around advice with planner-mark-task. =)

Thanks for the feedback!
-- 
Sacha Chua <address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

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