Nick Dokos <nicholas.do...@hp.com> wrote: > > While the org-scan-tags funciton parses the first subheading(**DONE > > ss1) the match is > > successful and the function "my-org-archive-subtree" is called which > > sets the variable > > "org-map-continue-from" value to *beginning of line* and this variable > > is not set back to nil > > after the function call ends, which leads to infinite loop while > > parsing the subsequent headlines > > which does not match the "DONE" state(**NEXT ss2). > > > > I think it's a bit much to expect org to avoid all possible infinite loops > that a user function can get it into - it's up to you to write the function > properly so that it does *not* lead to infinite loops. > > In this case, I think you can write > > --8<---------------cut here---------------start------------->8--- > (defun my-org-archive-subtree () > (let ((org-map-continue-from (point-at-bol))) > (org-archive-subtree))) > --8<---------------cut here---------------end--------------->8--- > > and be done with it - no changes to org needed. AFAICT, it deals with > both of your examples without going into an infinite loop. > > What am I missing? >
Well, it doesn't go into an infinite loop but it doesn't work either, so scratch that. I'll need to think about it some more. Nick