Set every checkbox to state [ ]
From:
- [ ] One
- [-] Two
- [x] Three
To:
- [ ] One
- [ ] Two
- [ ] Three
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityUse the command org-reset-checkbox-state-subtree
.
This resets the state of the checkboxes in the subtree under point.
In order to get the whole file, you need to walk the top-level headings and apply the function to each such heading. The function org-map-entries
is designed to do such walks and provides a very general setting for them. In this case, we need to specialize it to just the top-level headings in the file:
(org-map-entries #'org-reset-checkbox-state-subtree "LEVEL=1" 'file)
This walks all the top-level headings in the file and applies the function to each such heading.
More information about org-map-entries
can be found in the manual.
This feels a little awkward. This goes iterates over all the times, sets them all to [-], toggles that to [X] and then toggles that to [ ].
(org-element-map (org-element-parse-buffer)
'item (lambda (item)
(goto-char (org-element-property :begin item))
(org-toggle-checkbox '(16))
(org-toggle-checkbox '())
(org-toggle-checkbox '())))