UNL's are supposed to be a way of referring to nodes (positions). Alas, the machinery for handling such things is riddled with kwargs (keyword arguments) and other problems.
Imo, the present code is attempting to solve related problems by fiddling with kwargs. Instead, it would likely be better to solve the following tasks separately:
Task 1: clickable links
The mypy, pylint, and pyflakes commands create clickable links to erroneous lines. At present, the code that creates and handles these links uses the UNL machinery, but in fact this is not necessary. Indeed, these commands create callbacks bound to mouse-click events. There is no need to use UNL's at all.
The clickable links are "ephemeral". They exist in the log pane. Leo never saves them. The links are guaranteed to exist when they are created, and the links are unlikely to become unusable in normal practice. The necessary data are:
- The name of an external file.
- A line number (offset) within the entire external file.
Task 2: bookmarks and backlinks
Terry Brown's bookmarks and backlink plugins use UNL's to create more permanent data. The necessary data are:
- The name of the .leo file.
- A description of the position of the desired node.
Archived positions probably did not exist when Terry created these two plugins, but archived positions would be a natural alternative to UNL's.
Task 3: The status line
Leo displays the UNL of c.p in the status line. The format is:
- The path to the .leo file.
- A list of ancestor headlines, separated by "- - >" (without the spaces).
I don't recall whether Leo supports moving to other nodes based on control-clicking these text UNL's.
Plans
Imo, it would be best to use separate code and data for each task.
At present, all UNL's eventually become a plain string, with an arcane format for handling various offsets within lines, nodes, and files. It would be better to represent the necessary data in a task-specific way, possibly with a Python dict, just like JSON.
Summary
Leo's UNL-related code needs a thorough review. Callbacks probably do not need UNL's at all.
PR
#2406 will describe the work. Issue
#2376 must wait until the dust clears.
All questions and suggestions are welcome.
Edward