From a2219f46ba8079592ec4f920397c5b26345814eb Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 7 Jul 2022 17:26:33 -0700 Subject: feat(org-mode): reset check boxes for repeated tasks Add a couple of functions in order to reset the check boxes for repeated tasks. If the tasks has the property `RESET_CHECK_BOXES', when it's marked as completed, the check boxes are unset. Also configure the capture template for emails to only show when I'm in a notmuch buffer. Change-Id: I3511a0bb035ab57722b4409a19feb9a14dc85298 Reviewed-on: https://cl.fcuny.net/c/emacs.d/+/618 Tested-by: CI Reviewed-by: Franck Cuny --- emacs/custom/my-org.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'emacs/custom') diff --git a/emacs/custom/my-org.el b/emacs/custom/my-org.el index 05990d3..759af7b 100644 --- a/emacs/custom/my-org.el +++ b/emacs/custom/my-org.el @@ -120,6 +120,28 @@ (file+olp+datetree "journal.org") "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n" :tree-type day))) +(setq org-capture-templates-contexts + ;; only show the capture template for emails when in a notmuch + ;; buffer + '(("m" ((in-mode . "notmuch-search-mode") + (in-mode . "notmuch-show-mode") + (in-mode . "notmuch-tree-mode"))))) + +;; https://stackoverflow.com/questions/20164918/how-to-untick-checkboxes-in-org-mode-for-the-next-cyclic-repetitive-task +(defun my/org-reset-checkbox-state-maybe () + "Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set." + (interactive "*") + (if (org-entry-get (point) "RESET_CHECK_BOXES") + (org-reset-checkbox-state-subtree))) + +(defun my/org-reset-checkbox-when-done () + "Reset all checkboxes in an entry when the state is DONE." + (when (member org-state org-done-keywords) ;; org-state dynamically bound in org.el/org-todo + (my/org-reset-checkbox-state-maybe))) + +(add-hook 'org-after-todo-state-change-hook 'my/org-reset-checkbox-when-done) + + (provide 'my-org) ;;; my-org.el ends here -- cgit 1.4.1