This Engineering Notebook post suggests improvements to the code that reads 
outlines and pastes nodes.


These changes must wait until Leo 6.7.5. Recent changes automatically 
correct link errors in paste-retaining-clones. These changes suffice for 
Leo 6.7.4.


I propose the following two-pass strategy for code that reads outlines, 
including the code that handles paste-node and paste-retaining-clones:


A *prepass* will convert various file formats to a *descriptor dict*, 
similar to what p.archive returns. A *postpass* will create the outline 
from the descriptor dict.


*The prepass*


Leo's existing codebase contains four sets of duplicate code that handle 
reads and pastes in xml and json formats. The prepass will eliminate this 
code duplication.


The prepass will create a *descriptor dict* containing entries for each 
vnode *without* explicit structure data. In other words, outline structure 
will be *implicit *in the entries in the *parents_dict* and *children_dict* 
(see 
p.archive).


Pass one's most challenging task will be to create the parents_dict and 
children_dict entries in the descriptor dict. This task is tricky, just as 
in Leo's existing code.


Leo should support a new *flat json format *based on p.archive. This new 
format would make creating parents_dict and children_dict a trivial 
operation.


The descriptor dict will also contain a 'command' key, telling the postpass 
what command Leo is executing.


*The postpass*


The postpass will create vnodes from the descriptor dict. The postpass will 
have two phases.


*Phase one* will allocate all vnodes, assigning v.gnx. For read-outline and 
paste-node, this phase will recreate *all* vnodes. For 
paste-retaining-clones, this phase will create only *missing *vnodes.


*Phase two* will enforce the "pasted nodes rule" policy by *overwriting 
everything*: v.parents, p.children, v.h, v.b, and v.u.


*Summary*


A prepass will create a json-like dict *descriptor dict* containing 
parent/child links. Creating this dict will be a challenging task.


A postpass will allocate vnodes first and then *overwrite everything*, thus 
enforcing the pasted-nodes-rule requirement.


A new *flat **json format* would represent parent/child links explicitly, 
thereby collapsing the complexity of the prepass.


Your comments, please.


Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/550f3124-ec1f-4886-9d66-f2ec6e6b0dden%40googlegroups.com.

Reply via email to