How to use Windows Network location in @url lines

37 views
Skip to first unread message

jkn

unread,
Nov 14, 2024, 12:42:34 PM11/14/24
to leo-editor
Hi all
    simple question - on windows, is it possible to use @rl to open up File Explorer at a Network shortcut?

I usually run under Linux and have no problem with

or
@url file:///path/to/directory

under Windows, I can do

@url file:///c:/users/jkn/my/directory    # success

but it I have a network location, say '\\winlnx', I get a 'file XXX does not exist' error for all the combinations of 'winlnx' I can create for an @url line.

I don't know much about windows networking and file locations...

Thanks, J^n

Viktor Ransmayr

unread,
Nov 14, 2024, 1:00:58 PM11/14/24
to leo-e...@googlegroups.com
Hello J^n,

I guess the answer can be found here:
AFAIK there's no URL format for Windows Networking defined by IETF / W3C.

With kind regards,

Viktor

HaveF HaveF

unread,
Nov 14, 2024, 11:17:59 PM11/14/24
to leo-editor
but it I have a network location, say '\\winlnx', I get a 'file XXX does not exist' error for all the combinations of 'winlnx' I can create for an @url line.

jkn

unread,
Nov 15, 2024, 3:41:52 AM11/15/24
to leo-editor
Hi there
    no, that doesn't work - I get a 'file does not exist' error, although the path to the 'file' is a bit curious.

I think it must be down to what 'xdg-open' can use? I am looking into how that works...

    J^n

Viktor Ransmayr

unread,
Nov 15, 2024, 4:06:42 AM11/15/24
to leo-e...@googlegroups.com
Hello J^n,

Am Fr., 15. Nov. 2024 um 09:41 Uhr schrieb jkn <jkn...@nicorp.f9.co.uk>:
Hi there
    no, that doesn't work - I get a 'file does not exist' error, although the path to the 'file' is a bit curious.

I think it must be down to what 'xdg-open' can use? I am looking into how that works...

...


On Friday, November 15, 2024 at 4:17:59 AM UTC iamap...@gmail.com wrote:
but it I have a network location, say '\\winlnx', I get a 'file XXX does not exist' error for all the combinations of 'winlnx' I can create for an @url line.


Maybe this section from the RFC might help you in your investigations:
I can't help you more, since I do not have a Windows-based networking environment anymore ...

With kind regards,

Viktor

jkn

unread,
Nov 15, 2024, 4:37:36 AM11/15/24
to leo-editor
Hi Viktor
    update - I think this behaviour is down to Python's os.startfile(path, [...]) function. I am investigating...

    J^n

jkn

unread,
Nov 15, 2024, 4:52:48 PM11/15/24
to leo-editor
Actually, the "problem" seems to be more about "how to specify a network location" such that Leo can open it in a consistent way.

Leo's parsing for @url uses urlparse.urlparse(), and deals with strings like I list above - "file:///path/to/file etc.

And I can open File Explorer at the expected place via os.startfile("\\\\winlnx\\projects"), for instance

But how to link these two - to use an @url-like scheme to tell Leo that some version of that - say "\\winlnx\projects" should be opened like that.

One could concoct a special rule for Leo to use when parsing a URL whose 'netloc' field looks like this ... but I can well imagine Edward not liking that very much.

For now I am going to create a button command so that after selecting the name of the path with the cursor, the button runs os.startfile() using that text. Let's see how useful that is.

    J^n

Edward K. Ream

unread,
Nov 15, 2024, 7:44:23 PM11/15/24
to leo-e...@googlegroups.com
On Fri, Nov 15, 2024 at 3:52 PM jkn <jkn...@nicorp.f9.co.uk> wrote:
Actually, the "problem" seems to be more about "how to specify a network location" such that Leo can open it in a consistent way.
...
One could concoct a special rule for Leo to use when parsing a URL whose 'netloc' field looks like this ... but I can well imagine Edward not liking that very much.

Good guess :-)

For now I am going to create a button command so that after selecting the name of the path with the cursor, the button runs os.startfile() using that text. Let's see how useful that is.

Sounds like a plan.

Edward

jkn

unread,
Nov 16, 2024, 3:39:09 AM11/16/24
to leo-editor
Hi Edward

On Saturday, November 16, 2024 at 12:44:23 AM UTC Edward K. Ream wrote:
On Fri, Nov 15, 2024 at 3:52 PM jkn <jkn...@nicorp.f9.co.uk> wrote:
Actually, the "problem" seems to be more about "how to specify a network location" such that Leo can open it in a consistent way.
...
One could concoct a special rule for Leo to use when parsing a URL whose 'netloc' field looks like this ... but I can well imagine Edward not liking that very much.

Good guess :-)

Heh heh.

Actually, I think there is hope. I revisited this wiki page: https://en.wikipedia.org/wiki/File_URI_scheme

which discusses two schemes for how a windows UNC filename can be referenced as a URI. It seems that

    file:////server/folder/filename.ext   # four forward slashes

should/can work.

So I think my task ;-) is to improve/extend Leo's translation scheme so that this gets turned into os.startfile("\\server\folder\filename.ext")

    J^n
Reply all
Reply to author
Forward
0 new messages