On Sun, Mar 13, 2011 at 01:30, Aankhen <aank...@gmail.com> wrote: > I’ve been working on getting org-mode to automatically clock into an > item’s ancestor when clocking out of that item. The way I have it set > up now, it walks up the tree looking for an item that has a particular > property set. If that property is non-nil, it clocks in; if it’s nil, > it doesn’t. Either way, it stops looking at that point. Here’s what > I have so far: > > [snip] > > So given this structure: > > [snip] > > When I clock out of ‘Frob’, I’m automatically clocked into ‘Quux’, and > when I clock out of ‘Quux’, I’m automatically clocked into ‘Bar’. > This works pretty well, except for one problem: it happens *every > time* I clock out, meaning that if I’m clocked into ‘Quux’ and I then > hit C-c C-x C-i on ‘Frob’, I end up being clocked into both ‘Bar’ and > ‘Frob’, because I’m automatically clocked out of ‘Quux’; my code is > run, clocking me into ‘Bar’; and then the normal clocking mechanism > clocks me into ‘Frob’ (at least, I *think* the hook runs first). > > I guess what I’m wondering is, what’s a good way to avoid this > double-clocking? And while I’m asking for help, can anyone think of > some less obnoxious names for the functions, variables and property? > :-)
I think I managed to answer the first question myself. As ‘org-clock-in’ sets ‘org-clock-clocking-in’ before calling ‘org-clock-out’, checking the value of that variable before clocking into the parent item seems to have done the trick. Aankhen