From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcel van der Boom Subject: org-add-note in adapted workflow always wants to be the last action Date: Wed, 16 Oct 2013 11:41:36 +0200 Message-ID: <87fvs15z8v.fsf@hsdev.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWNce-0004ip-36 for emacs-orgmode@gnu.org; Wed, 16 Oct 2013 05:42:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWNcY-0005I1-ME for emacs-orgmode@gnu.org; Wed, 16 Oct 2013 05:42:32 -0400 Received: from hawking.hsdev.com ([213.125.12.142]:33048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWNcY-0005Fr-Fh for emacs-orgmode@gnu.org; Wed, 16 Oct 2013 05:42:26 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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