Resetting All Checkboxes In An Org Buffer

Marcin Borkowski (Mbork) has a problem that many of we Org users have: He likes to use checkbox lists to organize tasks to ensure that he doesn’t forget any steps. An example that will resonate with most of us is using a checklist for things to pack for a vacation. So what’s the problem? The problem is how to reset those checkboxes to unchecked for the next time you want to use the checklist.

For a long time, he just did the obvious thing and performed a query-replace to change [x] to [ ]. The trouble with that solution is that it didn’t reset the checkbox cookies so he had to do that by hand. Since he knows a bit about Elisp, he decided to write his own solution. It turns out that Org already has a function, org-reset-checkbox-state-subtree, that almost does that. It will reset all the checkboxes in the current subtree so all Mbork needed to do was write a function to step down the subtrees and call org-reset-checkbox-state-subtree for each one.

It’s a surprising small amount of code and neatly solves the problem. As Mbork points out, there are some problems. His solution will sometimes call org-reset-checkbox-state-subtree for the same subtree more than once and it apparently can mess with header folding but most files you’re going to use his function on are probably sufficiently small that it doesn’t matter.

I’ve written a bunch of code like this. It may not be ready to ship but it solves a problem and I understand its limitations. It’s a win.

This entry was posted in General and tagged , . Bookmark the permalink.