On Sat, 18 Dec 2010 10:51:46 -0800 (PST)
aeromorrison <[email protected]> wrote:

> I've noticed an issue when using tabbed mode.  It seems that
> os.getcwd() always returns the working directory of the first file
> opened (first tab).  If any other scripts in other tabs use the
> getcwd() command to set up relative file/directory references, then
> they end up pointing to the wrong place and I get errors.  Is there a
> workaround or fix for this?

I don't think Leo makes any effort to set that to anything in particular.  
Better perhaps to use the path implied by the outline tree.  The API for this 
has advanced, but is perhaps not completely mature / clear / documented yet.

Basically Leo's concept of path is that the path at the top of the outline in 
the same as the path to the folder containing the .leo file.  This is probably 
the path you're hoping to get from os.getcwd(), and can be got from:

  c.getNodePath(c.topPosition())

and possibly other ways.

Note that this means the the meaning of paths changes when a file goes from new 
never saved to saved for the first time.

Further down the outline the path may be modified relatively or absolutely by 
@path nodes.  And of course if the node is part of a derived file (@file, 
@auto, @shadow, etc.) that file can specify it's own path in the node headline.

So given this outline in a file called /home/me/test.leo

1  ToDo
2     thing 1
3     thing 2
4  @path extra
5     notes
6     @file src/main.py
7        class Main

I would expect the following paths:

1  /home/me/
2  /home/me/
3  /home/me/
4  /home/me/extra
5  /home/me/extra
6  /home/me/extra/src (?)
7  /home/me/extra/src (?)

but I'm unclear as to the preferred methods for finding (a) the path in effect 
at the node, and (b) the path of the derived file of which the node is a part, 
if any.  Perhaps Edward can fill in those details.

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