This post explains why PR #3215 (gnx-based unls) is a milestone in Leo's history.
gnx-based unls are a fundamental resource comparable in importance to @clean and cff:
- Unls won't break if you rename or move a node.
- Leo supports platform-independent cross-file unls.
- Creating gnx-based unls is dead easy.
Leo now contains significant new resources related to gnx-based unls:
@data unl-path-prefixes helps resolve unls to different paths on different platforms. Most users need to know only about this setting.
Leo provides two other resources for plugins:
g.parsePathData parses such @data nodes to a python dict.
g.openUNLFile(c, s) resolves s (the file part of an unl) to a commander, defaulting to c if no resolution is possible. This function contains an Easter Egg. It will return c immediately if s specifies the active outline.
Plugins can monkey-patch g.openUNLFile to gain complete control over how Leo resolves unls.
Summary
gnx-based unls are a fundamental resource comparable in importance to `@clean` and cff. Creating unbreakable cross-file unls is dead easy.
Leonistas will likely find creative new uses for unls. For example, a script could scan a document, possibly contained in different outlines, converting unls to links for markup/reStructuredText.
Most users need to know only about the @data unl-path-prefixes setting. g.parsePathData parses such @data nodes to a python dict.
Plugins can monkey-patch g.openUNLFile to gain complete control over how Leo resolves unls.
All of your questions and comments are welcome.
Edward
P.S. Plugins can also alter @data unl-path-prefixes programmatically by calling c.config.set. Like this:
c.config.set(kind='data', name='unl-path-prefixes', val=lines)
Unit tests for leoGlobals do this using LeoUnitTest._set_setting. Take a look :-)
EKR
Apologies for not fully following all of the recent good work here. I meant to mention this earlier but just wanted to check this 'platform independent' part.On my Linux box, I get something in the lower 'status bar' like(*)unl:///home/jkn/path/to/myfile.leo#node-->subnode-->subnodebut when I run on my windows machine, the same file (shared via NextCloud) will not be like this, shurely? What happens if I move my .leo file to a different location? Apologies if I am missing something fundamental...
(*) slightly separate point - right click in that area shows 'copy/CTRL+C and 'select-all/CTRL+A'. It seems like I have to do CTRL+A followed by CTRL+C. I'd suggest that if you have no part of the ... gurl? ... selected, then CTRL+C should implicitly select the whole entity before copying
On my Linux box, I get something in the lower 'status bar' like(*)unl:///home/jkn/path/to/myfile.leo#node-->subnode-->subnodebut when I run on my windows machine, the same file (shared via NextCloud) will not be like this, shurely? What happens if I move my .leo file to a different location?
How does the current scheme address the situation of two identically-named files in different directories?
Everything will work provided you define @data unl-path-prefixes in your myLeoSettings.leo file on each platform. These data should define an absolute path (platform-specific) for various .leo files.
Everything will work provided you define @data unl-path-prefixes in your myLeoSettings.leo file on each platform. These data should define an absolute path (platform-specific) for various .leo files.
Does that means I can set @data unl-path-prefixes in my current leo file @settings node to specify a specific x.leo file path?
This is why I am sticking with the legacy format for the status bar.
Sorry, I realise my previous post was unclear.The status bar still shows legacy formatunl://G:/My Drive/editor/workbook.leo#Home
What do you mean by "This"?What @iamap wrote:"Btw, I do believe gnx-based unls is important, but the current display format lack some readability.Could it possible to add some readable path string to the end of the unls? just for human?
No, the local file does not have @string unl-status-kind = legacyOnly myLeoSettings.leo has @string unl-status-kind = gnxStrange. Both my desktop and laptop have this behaviour. I'll keep investigating.
I have @string unl-status-kind = legacy set in myLeoSettings.leo, and the status bar does show the path-based UNL. I added a setting @string unl-status-kind = gnx to my workbook, restarted Leo, and for that outline, I see gnx-style addresses in the status bar.
I updated to build 947ea935f5 and the status bar now shows gnx format.Previously build c4434257ff was installed.
I noticed myLeoSettings.leo file has node structure:
@settings
UNLs
>@string unl-status-kind = gnx
What is the reason for using clones in leoSetting.leo file?