Last active
December 25, 2015 14:39
-
-
Save mrvdb/6992195 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment