Discuss: remove support (later) for old unls in g.findUnl?

34 views
Skip to first unread message

Edward K. Ream

unread,
Jul 7, 2023, 7:36:26 PM7/7/23
to leo-editor
g.findUnl is the handler for path-based unls. It contains two regex patterns:

# (file_name):(comma-separated list of node indices)
old_pat = re.compile(r'^(.*):(\d+),?(\d+)?,?([-\d]+)?,?(\d+)?$')

# (file_name)::(line_number).
new_pat = re.compile(r'^(.*?)(::)([-\d]+)?$')


Leo's present unit tests cover only the new pattern.

Notice the inconsistencies in the old regex. Does anyone still use it?

Removing the old regex would eliminate other strange code. leoJS would benefit.

g.findUnl will remain unchanged for Leo 6.7.4.

Your comments, please.

Edward

Thomas Passin

unread,
Jul 7, 2023, 10:09:37 PM7/7/23
to leo-editor
I've never used g.findUnl() with patterns at all.  So as long as the newer one picks up legacy-style unls I'd be OK with it.

Edward K. Ream

unread,
Jul 8, 2023, 6:13:51 AM7/8/23
to leo-e...@googlegroups.com
On Fri, Jul 7, 2023 at 9:09 PM Thomas Passin <tbp1...@gmail.com> wrote:
I've never used g.findUnl() with patterns at all.  So as long as the newer one picks up legacy-style unls I'd be OK with it.

Hmm. Your plugins might be using g.findUnl indirectly.

Could you please put a trace at the start of g.findUnl to be sure? I'd like to know what you discover.

Edward

Thomas Passin

unread,
Jul 8, 2023, 7:47:23 AM7/8/23
to leo-editor
Using the ekr-tweak-unls branch breaks both the bookmarks and zettel tabbed apps.  I will look into what isn't working, but in the zettel browser, I see it's looking for and can't find expressions like 'unl://#tom.20220910123825.1', which is not a legacy unl.  In the case of the bookmarks manager, it can't find expressions like 'unl://tabbed_bookmarks_manager.leo:#@bookmark-collection (starter set)-->Python-->5 Python GUI Frameworks to Create Desktop, Web, and Even Mobile\xa0Apps. %7C Towards Data Science'.

The bookmark and zettel apps that I use every day don't use any of that code because I adapted the old code and wrote it into the apps.  So those apps don't call into Leo for these services.  However, the versions I shared in leo-editor-contrib are the ones I'm talking about here, and they don't work.

Edward K. Ream

unread,
Jul 8, 2023, 8:28:09 AM7/8/23
to leo-e...@googlegroups.com
On Sat, Jul 8, 2023 at 6:47 AM Thomas Passin <tbp1...@gmail.com> wrote:
Using the ekr-tweak-unls branch breaks both the bookmarks and zettel tabbed apps.  I will look into what isn't working, but in the zettel browser, I see it's looking for and can't find expressions like 'unl://#tom.20220910123825.1', which is not a legacy unl.

This is not proper new gnx-based unl, which must start with 'unl:gnx:'

'unl:gnx://#tom.20220910123825.1'

It's unlikely that Leo generated this unl.
In the case of the bookmarks manager, it can't find expressions like 'unl://tabbed_bookmarks_manager.leo:#@bookmark-collection (starter set)-->Python-->5 Python GUI Frameworks to Create Desktop, Web, and Even Mobile\xa0Apps. %7C Towards Data Science'.

Escapes may be the culprit here.

I don't see how Leo can be responsible for non-standard unls that various plugins generate.

Edward

Thomas Passin

unread,
Jul 8, 2023, 8:44:58 AM7/8/23
to leo-editor
These apps worked a week ago.  I had already adapted them for the big PR and checked that they work.  Part of that was handling an escape that hadn't needed to be handled previously (%3E for ">").  But here's another that doesn't have strange escaped characters and doesn't work either: 'unl://tabbed_bookmarks_manager.leo:#@bookmark-collection (starter set)-->Python-->Python IAQ Infrequently Answered Questions'.

These unls are constructed on the fly when the user makes a query.  I suppose it won't be too hard to make this work again.  I don't want to put in the work unless the code is going to be stable.  So far I've been chasing a moving target.

Edward K. Ream

unread,
Jul 8, 2023, 9:00:28 AM7/8/23
to leo-e...@googlegroups.com
On Sat, Jul 8, 2023 at 7:45 AM Thomas Passin <tbp1...@gmail.com> wrote:

These apps worked a week ago.  I had already adapted them for the big PR and checked that they work.  Part of that was handling an escape that hadn't needed to be handled previously (%3E for ">").  But here's another that doesn't have strange escaped characters and doesn't work either: 'unl://tabbed_bookmarks_manager.leo:#@bookmark-collection (starter set)-->Python-->Python IAQ Infrequently Answered Questions'.

These unls are constructed on the fly when the user makes a query.  I suppose it won't be too hard to make this work again.  I don't want to put in the work unless the code is going to be stable.  So far I've been chasing a moving target.

The PR is now frozen, pending comments from you.

The tweaks PR changes only g.findAnyUnl and g. openUNLFile.

Please let me know if you would like a change in either function.

I won't change the PR's code in any way except unless I hear from you.

Edward
Reply all
Reply to author
Forward
0 new messages