1

Set every checkbox to state [ ]

From:

- [ ] One
- [-] Two
- [x] Three

To:

- [ ] One
- [ ] Two
- [ ] Three

2 Answers 2

2

Use 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.

0
0

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 '())))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.