The following prototype code shows how to adapt the @shadow algorithm for 
use by @nosent files::

    def run(self,path,root):
        '''Main line.'''
        x = self.c.shadowController
        new_public_lines = self.read(path)
        old_private_lines = self.write(root,nosentinels=False)
        fn = g.shortFileName(path)
        marker = x.markerFromFileLines(old_private_lines,fn)
        new_private_lines = x.propagate_changed_lines(
            new_public_lines,old_private_lines,marker,p=root)

The read method just reads the external file created by @nosent.  We assume 
that the user may have updated this file outside of Leo.

The write method writes the @nosent tree (to a list of strings) as if it 
were an @file node. This recreates what in the @shadow world are called the 
lines of the old private file. These lines contain the sentinels that Leo 
would have written if the @nosent tree were an @file tree::

    def write(self,root,nosentinels):
        '''Return all lines of the @nosent tree at root.'''
        at = self.c.atFileCommands
        at.write(root,
            kind = '@nosent',
            nosentinels = nosentinels,
            perfectImportFlag = False,
            scriptWrite = True,
            thinFile = True,
            toString = True)
        return g.splitLines(at.stringOutput)

This is *much* faster than reading and writing hidden private @shadow files!

Still to do:

1. Fold the run code shown above into at.openFileForReading.

2. Replace the @nosent tree (in the outline) by the outline corresponding 
to the updated lines, preserving uA's in the @nosent tree.  This is surely 
possible because:

A. The @shadow algorithm preserves gnx's.
B. The to-be-preserved data exists in the original @nosent tree.

The details may be tricky, but they will be nowhere near as dire as with 
@persistence trees. The code will be fast because no external files need be 
read or written.

3. [Optional but desirable]  Improve the core @shadow code so that Leo can 
show the user all inserted, deleted or changed nodes.  This logging is a 
separate matter from what I have been discussing here. It can be delayed 
until everything else is thoroughly tested.

Unbelievable!  Very soon Leo will be able to update @nosent trees based on 
changes to the corresponding external files! The new scheme will *just 
work*.  I never dreamed this could be possible.

To summarize, here are the advantages:

1. A collapse in complexity: @auto, @persistence and @shadow may be 
deprecated or even eliminated!  This is a *big* advance in user 
friendliness.

2. A performance boost: the @shadow algorithm will not read or write 
auxiliary files. Note: caching ensures that Leo will run the full @shadow 
algorithm only if the external @nosent file has actually changed. 

3. A reduction in Leo's footprint: no need for hidden helper files in 
irritating .leo_shadow folders.

4. A reduced role for @auto importers. The user will likely create the 
*original* @nosent tree using Leo's import command.  The user will then 
change @auto to @nosent and off we go.  Alternatively, Leo's import 
commands could create @nosent nodes instead of @auto nodes.

This is a great day for Leo.  It will be at least several days before this 
scheme becomes fully operational.

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 post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to