On Tuesday, August 8, 2023, Edward K. Ream wrote:


> PR #3473 <https://github.com/leo-editor/leo-editor/pull/3473> defines 
Leo's first VNode generator, v.self_and_subtree.


Here are some ENB-like notes. Feel free to ignore this post.


- v.self_and_subtree contains no recursion and no "yield from" statements. 
The PR will simplify other methods using this code pattern.


- v.self_and_subtree generator yields no duplicates. Duplicates would be 
useless because outline order is undefined in the vnode world. So methods 
such as v.parents_iter or v.self_and_parents would make no sense.


- Vitalije's *c.all_positions_for_v* method shows how to generate all 
*positions* p such that p.v == v. Yes, this *is* possible even in the 
unordered VNode world. Imo, this should be a VNode method. Yes, we'll 
retain the Commander method for compatibility.


- *c.all_unique_roots* contains code equivalent to 
c.hiddenRootNode.self_and_subtree(). The PR will simplify 
c.all_unique_roots accordingly.


- *g.getLanguageFromAncestorAtFileNode* contains an internal *v_and_parents* 
generator. 
The PR will replace this local generator with a new *v.self_and_parents*
 generator.


- Similarly, the PR will simplify *v.setAllAncestorAtFileNodesDirty*.


- *c.pasteAsTemplate* contains an internal *skip_root* generator that 
generates the outside set. The PR will remove this internal generator, 
replacing:


outside = {x.gnx for x in skip_root(c.hiddenRootNode)}


with:


outside = {x.gnx for x in c.hiddenRootNode.self_and_subtree()} 

outside.remove(c.hiddenRootNode.gnx)


If Leo defines *v.subtree*, this can become:


outside = {x.gnx for x in c.hiddenRootNode.subtree()}  


*Summary*


- v.self_and_subtree is not the first generator yielding VNodes, but the 
existing generators are fairly well hidden.


A (new?) PR will replace ad-hoc internal generators with new (official) 
VNode generators.


All these changes must wait until Leo 6.7.5.


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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/3a7df8d7-40e6-4c48-9e0b-be5219d56e4an%40googlegroups.com.

Reply via email to