I want to archive all the DONE todo states in a file, The below code extends the function specified in the link (please look at the comment in the link to see why the answer provided does not work) How to archive all the DONE tasks using a single command as below
(defun my-org-archive-subtree ()
(if (string-match "^\*.* DONE" (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
(setq org-map-continue-from (point-at-bol))
(setq org-map-continue-from nil))
(org-archive-subtree))
(defun my-org-archive-done-tasks ()
(interactive)
(org-map-entries 'my-org-archive-subtree "/DONE" (list "/home/myhome/org/office.org")))
which seems to get in to infinite loop for the below contents in the file office.org while execting the s2 heading
* s1
** DONE ss1
* s2
** NEXT ss2
** sss3
Why does it goes in to infinite loop and how to solve the problem.
Update:- This was due to the bug in the org-scan-tags function which was called by org-map-entries fn. The bug has been reported and fixed. To view the discussions on the mailing list click here