Ever have a clone that is difficult to understand outside the context of its original parent? Here's some code to help. It displays the headline of the current node plus the headlines of all the parents of all the clones of the current node. Selecting a displayed parent headline moves the current node to the corresponding clone in the outline.

The idea is to be able to quickly see the context of all the clones of the current node and to be able to easily navigate from one clone instance to the next.

Paste the following into a leo outline and create a script button from the "Show other clones" node. Navigate to a clone and click the "Show other clones" button. A clones tab will be created in the log pane.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet ekr_stylesheet?>
<leo_file>
<leo_header file_format="1" tnodes="7" max_tnode_index="7"/>
<vnodes>
<v t="btheado.20060329204930" a="EV"><vh>@button Show other clones</vh>
<v t="btheado.20060329204930.1" a="E"><vh>class cloneNavigator</vh>
<v t="btheado.20060329204930.2"><vh>init</vh></v>
<v t="btheado.20060329204930.3" a="E"><vh>getAllClones</vh></v>
<v t="btheado.20060329204930.4"><vh>displayClones</vh>
<v t="btheado.20060329204930.6"><vh>&lt;&lt;Fill listbox with clone parent headlines&gt;&gt;</vh></v>
<v t="btheado.20060329204930.5"><vh>&lt;&lt;Goto selected position when listbox selection changes&gt;&gt;</vh></v>
</v>
</v>
</v>
</vnodes>
<tnodes>
<t tx="btheado.20060329204930">@others
c.cn = cloneNavigator(c)
c.cn.displayClones(c)
</t>
<t tx="btheado.20060329204930.1">class cloneNavigator:
    '''
       Displays the headline of the current node plus the headlines of
       all the parents of all the clones of the current node.  Selecting
       a displayed parent headline moves the current node to the
       corresponding clone in the outline.

       The idea is to be able to quickly see the context of all the clones
       of the current node and to be able to easily navigate from one clone
       instance to the next.
    '''
    @others</t>
<t tx="btheado.20060329204930.2">def __init__ (self,c):
    self.c = c
    import Tkinter as Tk
    if 0:
        f = Tk.Toplevel()
    else:
        log = c.frame.log
        log.selectTab('Clones')
        f = log.tabFrame
        for w in f.winfo_children():
            w.destroy()

    # Create and pack empty label and listbox
    self.title = Tk.Label(f)
    self.title.pack(anchor="nw")
    self.lb = Tk.Listbox(f)
    self.lb.pack(expand=1,fill="both")</t>
<t tx="btheado.20060329204930.3">def getAllClones(self,p):
    c = self.c
    def clonesOf(p,p1=p):
        return p.v.t == p1.v.t
    return filter(clonesOf, c.allNodes_iter(copy=True))</t>
<t tx="btheado.20060329204930.4">def displayClones(self,c):
    '''Displays the parent headline for all the clones of the current position'''
    cp = c.currentPosition()

    # "Title" is the headline of the current node
    self.title.configure(text=cp.headString())

    # Initialize listbox and clone list
    clones = self.getAllClones(cp)
    self.lb.delete(0,self.lb.size()-1)

    &lt;&lt;Fill listbox with clone parent headlines&gt;&gt;
    &lt;&lt;Goto selected position when listbox selection changes&gt;&gt;
</t>
<t tx="btheado.20060329204930.5"># Callback for when a listbox entry is selected
def gotoSelectedPosition(event,lb=self.lb,c=c,positions=clones):
    idx = int(lb.curselection()[0])
    p = positions[idx]
    c.frame.tree.expandAllAncestors(p)
    c.selectPosition(p)
    return
self.lb.bind(g.angleBrackets("ListboxSelect"), gotoSelectedPosition)</t>
<t tx="btheado.20060329204930.6"># Add the headlines of all the clone parents to the listbox
for p in clones:
    if p.parent():
        text = p.parent().headString()
    else:
        text = "&lt;root&gt;"
    self.lb.insert(self.lb.size(),text)

    # Initial listbox selection corresponds to current position
    if p.v == cp.v:
        self.lb.selection_set(self.lb.size()-1)</t>
</tnodes>
</leo_file>