emacs-orgmode
[Top][All Lists]
Advanced

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

[O] org-add-note in adapted workflow always wants to be the last action


From: Marcel van der Boom
Subject: [O] org-add-note in adapted workflow always wants to be the last action
Date: Wed, 16 Oct 2013 11:41:36 +0200

Hi,

I have written a snippet of code with the goal to ask me if I want to
archive a TODO item when marking it DONE or CANCELLED.

The code I have so far is this:

#+BEGIN_SRC emacs-lisp
  (require 'org-habit)

  ;; I need a modified version of org-is-habit, which takes inheritance
  ;; in to account
  (defun mrb/org-is-habit-recursive-p (&optional pom)
    "Is the task at POM or point a habit, taking property
    inheritance into account?"
    (equalp "habit" (org-entry-get (or pom (point)) "STYLE" t)))

  (defun mrb/archive-done-item()
    ;; Determine if the item went to the DONE/CANCELLED state
    ;; if so, ask to archive it, but skip habits which have
    ;; their own logic.
    (when (and
         (or
          (equal org-state "DONE")
          (equal org-state "CANCELLED"))
         (not (mrb/org-is-habit-recursive-p)))
      ;; Try to use a dialog box to ask for confirmation
      (setq last-nonmenu-event nil)
      (org-archive-subtree-default-with-confirmation)))

  ;; Run archive for the item that changed state
  (add-hook 'org-after-todo-state-change-hook
          'mrb/archive-done-item)

#+END_SRC

The above works for marking items DONE. A dialog box pops up, I
(usually) hit enter and continue.

On marking items CANCELLED this does not work as expected because
the CANCELLED state is defined with the '@' postfix like so:

#+SEQ_TODO: WAITING TODO | DONE CANCELLED(@)

What happens now is that I first get the question on whether to
archive the item and after that I get asked to write a note.

This seems to be the case because the note is handled by adding it
to the post-command-hook through =org-add-log-setup= in the =org-todo=
command.

Is there anything I can do to reverse that order, i.e. Make sure
that the archiving question comes last?

My orgmode version is "8.1.1"

Thanks,
marcel
-- 
Marcel van der Boom  -- http://hsdev.com/mvdb.vcf
HS-Development BV    -- http://www.hsdev.com
We use bitcoin!      -- http://bitcoin.org



reply via email to

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