On Wed, 19 Jun 2019 00:52:54 -0500
"Edward K. Ream" <edream...@gmail.com> wrote:

> On Tue, Jun 18, 2019 at 6:27 PM Terry Brown <terrynbr...@gmail.com>
> wrote:
> 
> Then I'm not sure that there's really anything to do.   Python's
> > well integrated into vim, so you can just use leoBridge as usual.
> 
> 
> Cool.
> 
> > I guess I can do something to verify that, but I can't see why it
> > wouldn't work.
> >
> 
> Please do.  That would be helpful.

Ok, this script appends the outline headlines, indented, to the current
vim buffer:

import leo.core.leoBridge as leoBridge
import vim

controller = leoBridge.controller(
    gui='nullGui',
    loadPlugins=True,  # True: attempt to load plugins.
    readSettings=True,  # True: read standard settings files.
    silent=True,  # True: don't print signon messages.
    verbose=False,  # True: print informational messages.
)

g = controller.globals()
c = controller.openLeoFile("/home/tbrown/.leo/del.leo")


def dent(node, result, level=0):
    result.append('  ' * level + node.h)
    for child in node.children:
        dent(child, result, level + 1)
    return result


result = []
dent(c.hiddenRootNode, result)

vim.current.buffer[-1:] = result


It can be invoked with

:py import leodent

assuming it's in a file leodent.py and on the Python path.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/20190619073845.72437544%40lakeview.
For more options, visit https://groups.google.com/d/optout.

Reply via email to