Start a new topic

Org-Edna... I wonder...

Had a thought, but I'm not sure how to implement:


Org-Edna is an add-on MELPA package for Org to trigger some actions when a task is marked as DONE.  For instance, you could set the TODO for doing "program testing" to NEXT when mark the "fix bug" task as DONE.  It could be much more elaborate than that.  I'm sure there are other similar packages that trigger on "DONE".


My thought was, rather than implement (some of) Org-Edna in BeOrg, perhaps it would be simpler to define a "PRE-DONE" state in BeOrg that Emacs Org could trigger on when it reads an Org file and automatically change tasks with that state to "DONE" which would then trigger Org-Edna to do it's thing.  All we need is an Elisp package that could be loaded in Emacs to auto-search any Org file for the "PRE-DONE" state and change it (using proper Org commands) to "DONE".  Well, we'd also need BeOrg to recognize PRE-DONE as essentially a DONE state.


Make sense?  Anyone have an idea on how to do that in Elisp?


1 person likes this idea
1 Comment

This worked with limited testing. 


You have to specify "BEDONE" as a legal todo state in your config or within the file for this to work. Otherwise, "BEDONE" is just treated like arbitrary text, not a todo state, and the function won't work. 

(defun my/org-change-bedone-to-done ()
  "Change all 'BEDONE' states to 'DONE' in current buffer."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward org-heading-regexp nil t)
      (when (string= (org-get-todo-state) "BEDONE")
        (org-todo "DONE"))))) 
Text

 

Slightly dangerously:  

(add-hook 'org-mode-hook 'my/org-change-bedone-to-done)
Text

 

Then add "BEDONE" to the list of states in Beorg. 


Should be able to change the state to BEDONE in BeOrg, then, and when you get home and open the file, the hook runs and org-edna triggers. 


I tested this in use with org-gtd, which uses org-edna  to keep track of projects, where closing one task needs to transition the next task in line into a NEXT state. 


So glad you asked this. I  arrived here looking to solve this problem and your idea framed it up nicely. 


1 person likes this
Login or Signup to post a comment