On Fri, Mar 18, 2011 at 9:38 AM, Terry Brown <[email protected]> wrote:
> Should os.chdir() be called to set the current directory to match any
> @path directives in effect at the current node when a script is run or
> a button pushed?  Seems this would be useful.

There are several instances of os.chdir and g.chdir  in c.open,
c.save, the read, import, export logic and in several global
functions. Thus, Leo does not typically depend on the current
directory--it sets the current directory as needed. The **tentative**
conclusion is that setting os.chdir automatically in the
execute-script would be safe.

However, changing the execute-script logic could change the meaning of
existing scripts. I don't think it is wise.

 It should be easy enough to set the path explicitly in a script as
needed using::

    import os
    d = c.scanAllDirectives(p) # use c.p if p is omitted.
    path = d.get('path')
    if path: os.chdir(path)

However, c.scanDirectives returns a default if there is no @path, so
maybe this isn't so convenient, but that doesn't change my conclusion.

Edward

-- 
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