refactor(org-checklist): combine advice and patch
This commit is contained in:
parent
cdd56bfafe
commit
848c27d1d0
1 changed files with 6 additions and 8 deletions
14
config.org
14
config.org
|
|
@ -3326,12 +3326,6 @@ The simple package =org-checklist= from =org-contrib= makes it so that checkboxe
|
|||
(add-hook 'org-after-todo-state-change-hook #'org-checklist)))
|
||||
#+end_src
|
||||
|
||||
The ~org-checklist~ function will reset the checkboxes on any task, but I only want them reset when the task repeats.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(advice-add #'org-checklist :before-while #'org-get-repeat)
|
||||
#+end_src
|
||||
|
||||
I don't want to have to specify the =RESET_CHECK_BOXES= property for every TODO I write, though. I would much prefer if it was on by default, and the system allowed me to turn it off if I wanted to. Luckily, the fine control Org gives you over property inheritance nicely fixes this problem.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
|
@ -3340,9 +3334,13 @@ I don't want to have to specify the =RESET_CHECK_BOXES= property for every TODO
|
|||
|
||||
(defpatch! org-checklist
|
||||
(defun org-reset-checkbox-state-maybe) ()
|
||||
"Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set"
|
||||
(el-patch-concat
|
||||
"Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set"
|
||||
(el-patch-add " and if the entry has a repeating timestamp."))
|
||||
(interactive "*")
|
||||
(if (org-entry-get (point) "RESET_CHECK_BOXES" (el-patch-add t))
|
||||
(if (el-patch-wrap 2
|
||||
(and (org-get-repeat)
|
||||
(org-entry-get (point) "RESET_CHECK_BOXES" (el-patch-add t))))
|
||||
(org-reset-checkbox-state-subtree)))
|
||||
#+end_src
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue