summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-07-07 17:26:33 -0700
committerFranck Cuny <franck@fcuny.net>2022-07-07 17:40:57 -0700
commita2219f46ba8079592ec4f920397c5b26345814eb (patch)
treee8ade371b4a5222bd66789e16aa217de5a114f6d
parentfeat(org-mode): get rid of some custom function (diff)
downloademacs.d-a2219f46ba8079592ec4f920397c5b26345814eb.tar.gz
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 <franck@fcuny.net>
-rw-r--r--emacs/custom/my-org.el22
1 files changed, 22 insertions, 0 deletions
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