On Wed, Aug 29, 2012 at 5:11 PM, Rand <
ran...@gmail.com> wrote:
> I want to add a tree of nodes to Leo via a python script.
> Can someone give me an example ?
If you know the minibuffer commands (easily discoverable due to tab
completion), then you can use those. For example:
c.executeMinibufferCommand('insert-node')
or
c.executeMinibufferCommand('insert-child')
Here's an example of creating a new command from multiple minibuffer commands:
def executeMinibufferCommands (c, cmds):
for cmd in cmds.strip().splitlines():
c.executeMinibufferCommand(cmd.strip())
@g.command("splice-insert")
def spliceInsert (event):
'''Inserts a new headline as a parent of the current headline'''
c.inCommand = False
executeMinibufferCommands (event.get('c'), '''
contract-node
insert-node
goto-prev-sibling
move-outline-down
move-outline-right
goto-parent
edit-headline
''')
That doesn't add a tree of nodes, but maybe it will give you the idea.
Though at some point it probably makes more sense to dive into the
lower level python methods and call them directly.
Brian