Heads up: #1521 changes Leo's read code

50 views
Skip to first unread message

Edward K. Ream

unread,
Mar 3, 2020, 5:58:42 AM3/3/20
to leo-editor
#1521 fixes long-standing bugs with path expressions in @clean, @asis and @shadow nodes.

The new code is simpler than before. All unit tests pass, which is a significant set of tests.

However, all changes to Leo's file logic are significant. Please report any problems immediately.

Edward

jkn

unread,
Mar 3, 2020, 10:18:42 AM3/3/20
to leo-editor
Thanks Edward - I have possibly-seen issues around this (although with @file rather than the others...),
I will see if this changes things for me.

One this: the path expressions section you link to mentions using something like:

@file {{c.config.getString('my-dir')}}{{sep}}myFile.py

but is it possible to use environment variables in a similar way?

Actually, I really want to just use the homepage - either

@file {{home}}{{sep}}mydir{{sep}}myFile.py
or
@file {{c.config.getEnv('HOME')}}{{sep}}mydir{{sep}}myFile.py

Apologies if something like this already exists - I did look for it...

Thanks, Jon N




Thomas Passin

unread,
Mar 3, 2020, 11:11:00 AM3/3/20
to leo-editor
I'm not crazy about using {{sep}} here.  It's not very readable, and it's harder to type that a single character. Requiring matched double braces also promotes the chance of an unspotted typo. IMO, instead of {{sep}} Leo should accept any of the standard path separators and convert them itself to whatever platform it's running on.

I found a bug in another project that used "/", and they said that it wasn't supposed to be the actual path separator.  But then some downstream code treated it as if it were the real separator - and, of course, using programs just fed in real paths, not canonicalized ones, leading to failure to find the reference file.

So just do the conversion.  It hardly costs any code or processing time.

Edward K. Ream

unread,
Mar 3, 2020, 1:23:05 PM3/3/20
to leo-editor
On Tue, Mar 3, 2020 at 9:18 AM jkn <jkn...@nicorp.f9.co.uk> wrote:


> the path expressions section you link to mentions using something like:

@file {{c.config.getString('my-dir')}}{{sep}}myFile.py

but is it possible to use environment variables in a similar way?
You can do anything that is possible to do knowing c and g. And that's a lot. See g.os_path_finalize_join.
Edward

Edward K. Ream

unread,
Mar 3, 2020, 1:24:41 PM3/3/20
to leo-editor
On Tue, Mar 3, 2020 at 10:11 AM Thomas Passin <tbp1...@gmail.com> wrote:
I'm not crazy about using {{sep}} here. 

g.os_path_finalize_join will avoid the need for {{sep}}.

Edward

jkn

unread,
Mar 3, 2020, 3:22:55 PM3/3/20
to leo-editor
Thank you. It looks like

    {{g.app.homeDir}}

etc. is what I am after...

    Jon

Edward K. Ream

unread,
Mar 3, 2020, 6:49:36 PM3/3/20
to leo-editor
On Tue, Mar 3, 2020 at 2:22 PM jkn <jkn...@nicorp.f9.co.uk> wrote:

Thank you. It looks like

    {{g.app.homeDir}}

etc. is what I am after...

Glad to hear it.

Edward
Reply all
Reply to author
Forward
0 new messages