@language python
def mark_first_parents():
"""mark the first parent of each node, moving up the tree
to the top level. print the list of marked parents."""
parent_lst = []
p = c.p
old_p = p
c.markHeadline(p)
for parent in p.parents():
if parent:
c.selectPosition(parent)
c.markHeadline(parent)
parent_lst.append(parent.h)
c.redraw()
if parent_lst:
g.es("marked: " + str(parent_lst))
c.selectPosition(old_p)
mark_first_parents()
@language python
def unmark_first_parents():
"""unmark the first parent of each node, moving up the tree
to the top level. print the list of unmarked parents."""
parent_lst = []
p = c.p
c.clearMarked(p)
for parent in p.parents():
if parent:
c.selectPosition(parent)
c.clearMarked(parent)
parent_lst.append(parent.h)
c.redraw()
if parent_lst:
g.es("unmarked: " + str(parent_lst))
unmark_first_parents()
As an afterthought, for those who are wary of .leo files from 'unknown' sources, here's the code:
@language python
def unmark_first_parents():
"""unmark the first parent of each node, moving up the tree
to the top level. print the list of unmarked parents."""
parent_lst = []
old_p = p = c.p
if p.isMarked():
c.clearMarked(p)
for nd in p.self_and_siblings():
if nd.v != old_p.v:
if nd.v.isMarked():
break
else:
for parent in p.parents():
if parent.isMarked():
After consulting Edward and Terry, the finished (I think) 'unmark-first-parents' command now works as intended.
This is on the list of things before Leo 5.7b2.