>The last part of the new @auto project will be saving and restore uas from an 
>@uas trees containing one @ua node for every node having an ua.

So far, the new @auto looks to be concerned with issues I don't encounter,
but this is exciting.

I work mostly with @auto nodes and put timestamps in the ua,
The big weakness here has always been lack of us persistence.

This is great!

Thanks,
Kent

On Sun, Jan 26, 2014 at 4:43 AM, Edward K. Ream <[email protected]> wrote:
> On Thursday, January 23, 2014 1:10:20 PM UTC-5, Edward K. Ream wrote:
>
>> The project now has met its original design goals!
>
>> Next up: restoring custom headlines.  It's tricky, but nowhere near as
>> tricky as moving nodes.
>
> This post documents yesterday's work.  It has two parts: 1) restoring
> headlines and 2) the at-file-to-at-auto command.
>
> ===== Restoring headlines: the easy part.
>
> Once an @auto file is created, restoring headlines is straightforward
> because all the data relates to the outline *after* it has been rearranged.
> So unls don't have to be munged.
>
> [Reading] vc.update_headlines_after_read, called from
> vc.update_after_read_at_auto_file, sets v._imported_headline for all vnodes
> to their *original* imported value.
>
> [Writing] vc.create_at_headlines, called from
> update_before_write_at_auto_file, makes an entry in the @headlines node for
> all nodes p whose present headlines do not match p.v._imported_headline.
>
> So, everything is very easy for *already existing* @auto nodes.
>
> ===== The at-file-to-at-auto command
>
> The bulk of the code is in the ConvertController class, contained within
> vc.convert_at_file_to_at_auto.
>
> Happily, the existing vc code was already perfectly factored to handle the
> new command. The main line of the code, in ConvertController.run, does the
> following:
>
> 1. cc.set_expected_imported_headlines *predictively* sets
> v._imported_headline for all vnodes.  This required new importer code,
> namely baseScannerClass.headlineForNode.  Given the body text of a node,
> headlineForNode attempts to predict what the importer will create as a
> headline when it actually generates the node.
>
> This is inherently an inexact science: it's not even guaranteed that the
> nodes created by the importer will match the nodes in the @file tree.  But
> we will do the best we can, and attempt not to crash if there are
> discrepancies ;-)
>
> 2. Calls vc.vc.update_before_write_at_auto_file **on the @file node** to
> create the appropriate @auto-view nodes and all its children **for the
> to-be-created @auto node**!!!  This is almost too good to be true, but it
> works.  Two hacks are needed, as described below.
>
> 3. Calls cc.strip_sentinels to write (to a string) the @file node as if it
> were an @auto node.  cc.strip_sentinels is straightforward: it calls
> atFile.writeOneAtAutoNode with the trialWrite keyword argument set to True
> to prevent calling vc.update_after_read_at_auto_file ;-)  cc.strip_sentinels
> returns the written string.
>
> 4. Calls cc.import_from_string creates the actual @auto node from the string
> returned from cc.strip_sentinels.  It calls the proper importer and returns
> p, the position of the newly created @auto node.
>
> 5. Now for the first hack I mentioned in step 2.  Now that we have the real
> @auto node, we must change the body text of the @auto-view node so that
> refers to the @auto node, not the @file node!  It's easy::
>
>     at_auto_view.b = vc.at_auto_view_body(p)
>
> 6. Finally, we call vc.update_after_read_at_auto_file(p) to do all the new
> @auto processing on the new @auto node using all the data in the @auto-view
> node that was created from the @file node.  It's very slick.
>
> HOWEVER, there is one more set of **switcheroos** that must be applied.
> This is the second hack I mentioned in step 2.
>
> Alas, the unls created in step two refer to the headlines as they exist in
> the @file tree, not the imported @auto tree.  To correct this, we must
> *dynamically munge* unls.  Again, the existing factoring of code turned out
> to be perfect.  The munging is done in two easy places: vc.relative_unl and
> vc.unl.  The munge uses:
>
>     getattr(p.v,self.headline_ivar,p.h)
>
> instead of just p.h.  It's almost too slick to be comprehensible ;-)  Note
> that vc.headline_ivar is the string '_imported_headline'.
>
> 7. That's all there is to it!  A few problems remain:
>
> - baseScannerClass.headlineForNode must be as accurate as possible.  I'm
> working on it.
>
> - An assert will fail if the corresponding position for an organizer node
> can't be found.  This is wrong.  The code must change in several places to
> allow for this possibility.
>
> I expect several hours of work remain before the at-file-to-at-auto command
> works on all of Leo's @file nodes.
>
> The last part of the new @auto project will be saving and restore uas from
> an @uas trees containing one @ua node for every node having an ua. That will
> be easy.
>
> 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 post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to