On Tue, 24 Jul 2012 01:40:59 -0700 (PDT)
Josef <
joe...@gmx.net> wrote:
> To do so, I would need to be able to tell Okular how to jump into a
> particular source line of a particular file in Leo (via command line).
> Ideally this should not open a new Leo instance, but direct an already open
> Leo to the appropriate line. For Emacs I would enter this line in the
> Okular "Editor" setting:
>
> emacsclient -a emacs --no-wait +%l %f
A small python script controlling Leo through the leoserver interface
could do this. The one below (also somewhere in the contrib repo.?) is
one I wrote to open files in Leo, or select the file again if it's
already loaded, it would just need the line selection part added.
#!/usr/bin/python
import sys
sys.path.append("/home/tbrown/Package/leo/bzr/leo.repo/trunk")
from leo.external import lproto
import os
addr = open(os.path.expanduser('~/.leo/leoserv_sockname')).read()
pc = lproto.LProtoClient(addr)
pc.send("""
import os
fn = %s
c = g.app.commanders()[0]
h = "@edit "+fn
n = g.findNodeAnywhere(c, h)
if not n:
n = c.rootPosition().insertAfter()
n.moveToRoot(c.rootPosition())
n.h = h
if os.path.isfile(fn):
n.b = file(fn).read()
c.selectPosition(n)
c.redraw()
c.bringToFront()
""" % repr(os.path.join(os.getcwd(), sys.argv[1])) )