On Wed, 6 Jul 2011 19:12:20 -0700 (PDT)
Largo84 <[email protected]> wrote:

> 
> > That depends what you use clones for.  If you use them for collecting a
> > short list of nodes of current interest from a larger tree, you can get
> > basically the same effect from the bookmarks.py and quickMove.py
> > plugins.  With those plugins enabled, create a node with a headline
> > containing `@bookmarks`.  It doesn't have to be at the start of the
> > headline.
> >
> That's not at all how I use clones. I use them for keeping persistent
> data persistent and in sync over multiple views and files. For
> example, in managing a multi-page  web site there are numerous text
> fragments that need to be duplicated across all pages. Cloning these
> text fragments makes that task so much easier than manually trying to
> update every instance, or even try to remember where every instance
> is.

Fair enough, that's an entirely different application.  What I was
describing was my alternative to clones in the context of python source
code writing.  For what you're doing I usually use a template language
like genshi or django-templates which has some sort of include
mechanism that can pull in often used pieces in multiple places.

> Many of my other document tasks are similar in need for duplicating
> text fragments and keeping them in sync. Leo is often described as a
> kind of database, that would be great if I could figure out how to
> make it be such. That would mean being able to reference the 'master'
> version of a piece of data and sync to that. Clones sort of do that as
> long as the reference is 'inside' the same .leo file. How is it
> possible to reference that data (node) from a different .leo file?
> 
> Someone mentioned something called a 'UNL'. I can't find any mention
> of UNLs in the docs glossary. I infer that it is a type of node
> reference. Where can I get more information about UNLs? Is this a
> possible answer to my earlier question of referencing a node from a
> different .leo file?

UNL = Universal Node Locater, I think.

They're a kind of special URL, such that in places where Leo accepts an
URL like  http://example.com/some/page.html it will also accept an UNL
like /path/to/file.leo#headline1-->headline2-->headline3 it should
shift to headline3 in file.leo, where headline3 is a child of
headline2 is a child of headline1.

Or if that target node's in the current .leo file, simply
headline1-->headline2-->headline3

Used to be implemented in the UNL.py plugin but moved into the core to
eliminate duplication of URL handling code.

Also note the right hand part of the status line at the bottom of the
Leo gui, that's the UNL for the current node within the current file.

You raise the interesting question, does this code work:

UNL="/home/tbrown/Desktop/Proj/BirdAtlas/db/birddb.leo#'SQL-->twp/blk to county"
path, UNL = UNL.split("#", 1)
ok,frame = g.openWithFileName(path, c)
new_c = frame.c
found, maxdepth, maxp = g.recursiveUNLSearch(UNL.split('-->'), new_c)
g.es(new_c.p.h)

that should open a different .leo file (birddb.leo), and select the
node 'blk to county' under the node 'SQL'.  It basically does that, but
birddb.leo becomes the active .leo file at the expense of whatever .leo
file was active when the script started, so there are some issues
there.  Not bugs, just not an area anyone's explored much.

There are a couple of other plugins and extensions which provide APIs
from accessing leo data from scripts, but it's not clear to me if you
are looking for a scriptish solution?

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to