refactor(org-checklist): simplify advice code

This commit is contained in:
Kiana Sheibani 2024-07-22 13:32:06 -04:00
parent 9a9c140a70
commit f03848adf3
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -3054,7 +3054,7 @@ The simple package =org-checklist= from =org-contrib= makes it so that checkboxe
#+begin_src emacs-lisp #+begin_src emacs-lisp
(when (modulep! :lang org) (when (modulep! :lang org)
(use-package org-checklist (use-package! org-checklist
:commands (org-reset-checkbox-state-maybe :commands (org-reset-checkbox-state-maybe
org-make-checklist-export org-make-checklist-export
org-checklist) org-checklist)
@ -3068,11 +3068,7 @@ The simple package =org-checklist= from =org-contrib= makes it so that checkboxe
The ~org-checklist~ function will reset the checkboxes on any task, but I only want them reset when the task repeats. 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 #+begin_src emacs-lisp
(defadvice! ~/org-checklist-only-on-repeating (old-fn) (advice-add #'org-checklist :before-while #'org-get-repeat)
"Only reset checkboxes when marking repeater tasks as DONE."
:around #'org-checklist
(when (org-get-repeat)
(funcall old-fn)))
#+end_src #+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. 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.